-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WGSL Validation tests for textureSampleCompare #3500
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just some nits.
src/webgpu/shader/validation/expression/call/builtin/textureSampleCompare.spec.ts
Outdated
Show resolved
Hide resolved
.fn(t => { | ||
const { textureType, arrayIndexType, value } = t.params; | ||
const arrayIndexArgType = kValuesTypes[arrayIndexType]; | ||
const args = [arrayIndexArgType.create(value)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a while to figure out why this was not causing failures for u32
. value
includes -9
, -8
, and I was expecting this to result in -9u
, -8u
which would result in: error: no matching overload for operator - (u32)
.
However, ScalarType.create()
calls u32(value)
, which is implemented as:
cts/src/webgpu/util/conversion.ts
Lines 1631 to 1635 in f1aa942
/** Create a u32 from a numeric value, a JS `number`. */ | |
export function u32(value: number) { | |
workingDataU32[0] = value; | |
return new U32Value(workingDataU32[0]); | |
} |
So, we end up with the two's complement. This is unexpected in this context.
We're not trying to test for unsigned integers handling negative numbers, so I'd suggest changing the value
range to just include positive numbers.
Same thing applies for the other tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you're saying about -8u
getting converted via Uint32Array
but I need negative numbers to test offset
which is required to generate an error for values < -8 and it will end up doing the same thing, passing -8
to offsetArgType.create()
with those values when offsetArgType
is u32
.
I switched to filtering out negative values with unsigned types
@group(0) @binding(2) var<uniform> u: ${offsetArgType}; | ||
@fragment fn fs(@builtin(position) p: vec4f) -> @location(0) vec4f { | ||
const c = 1; | ||
let l = ${offsetArgType}(${castWGSL}(p.x)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same test could be achieved with var l : ${offsetArgType};
, which would reduce the complexity of the shader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needed to be var l : ${offsetArgType.create(0).wgsl()};,
AFAICT. Just checking I'm not missing something.
d5d4a60
to
a5d91d5
Compare
I notice the offset option was missing in one case in the
textureSample
tests so that's included here. I can put it in another PR if it's important.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.