-
Notifications
You must be signed in to change notification settings - Fork 844
[SPIR-V][vk::SampledTexture] #11. Support vk::SampledTexture1D and vk::SampledTexture1DArray type.
#8212
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
base: main
Are you sure you want to change the base?
[SPIR-V][vk::SampledTexture] #11. Support vk::SampledTexture1D and vk::SampledTexture1DArray type.
#8212
Changes from all commits
ccb25ca
8846cd8
0c2fe8d
27e3e73
b8ebfeb
a228113
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // RUN: %dxc -T ps_6_7 -E main -fcgl %s -spirv | FileCheck %s | ||
| // RUN: not %dxc -T ps_6_7 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
|
||
| // CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown | ||
| // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image | ||
|
|
||
| vk::SampledTexture1D<float4> tex1d; | ||
|
|
||
| struct S { int a; }; | ||
|
|
||
| void main() { | ||
| // CHECK: OpStore %pos1 %uint_1 | ||
| uint pos1 = 1; | ||
|
|
||
| // CHECK: [[pos1:%[a-zA-Z0-9_]+]] = OpLoad %uint %pos1 | ||
| // CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d | ||
| // CHECK: [[tex_image:%[a-zA-Z0-9_]+]] = OpImage %type_1d_image [[tex1_load]] | ||
| // CHECK: [[fetch_result:%[a-zA-Z0-9_]+]] = OpImageFetch %v4float [[tex_image]] [[pos1]] Lod %uint_0 | ||
| // CHECK: OpStore %a1 [[fetch_result]] | ||
| float4 a1 = tex1d[pos1]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add some amount of negative testing/implicit cast testing?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added similar negative test cases from |
||
|
|
||
| #ifdef ERROR | ||
| S s = { 1 }; | ||
| // CHECK-ERROR: error: no viable overloaded operator[] | ||
| // CHECK-ERROR: note: candidate function {{.*}} no known conversion from 'S' to 'unsigned int' for 1st argument | ||
| float4 val2 = tex1d[s]; | ||
|
|
||
| int2 i2 = int2(1, 2); | ||
| // CHECK-ERROR: error: no viable overloaded operator[] | ||
| // CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int2|vector<int, 2>}}' to 'unsigned int' for 1st argument | ||
| float4 val3 = tex1d[i2]; | ||
|
|
||
| int3 i3 = int3(1, 2, 3); | ||
| // CHECK-ERROR: error: no viable overloaded operator[] | ||
| // CHECK-ERROR: note: candidate function {{.*}} no known conversion from '{{int3|vector<int, 3>}}' to 'unsigned int' for 1st argument | ||
| float4 val4 = tex1d[i3]; | ||
| #endif | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // RUN: %dxc -T ps_6_8 -E main -fcgl %s -spirv | FileCheck %s | ||
|
|
||
| // CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown | ||
| // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image | ||
|
|
||
| vk::SampledTexture1D<float4> tex1d; | ||
|
|
||
| void main() { | ||
| // CHECK: OpStore %x %float_0_5 | ||
| float x = 0.5; | ||
|
|
||
| // CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d | ||
| // CHECK: [[x:%[a-zA-Z0-9_]+]] = OpLoad %float %x | ||
| // CHECK: [[lod_query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[x]] | ||
| // CHECK: [[unclamped_lod:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[lod_query]] 1 | ||
| // CHECK: OpStore %lod1 [[unclamped_lod]] | ||
| float lod1 = tex1d.CalculateLevelOfDetailUnclamped(x); | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s | ||
|
|
||
| // CHECK: %type_1d_image = OpTypeImage %float 1D 0 0 0 1 Unknown | ||
| // CHECK: %type_sampled_image = OpTypeSampledImage %type_1d_image | ||
|
|
||
| vk::SampledTexture1D<float4> tex1d; | ||
|
|
||
| void main() { | ||
| // CHECK: OpStore %x %float_0_5 | ||
| float x = 0.5; | ||
|
|
||
| // CHECK: [[tex1_load:%[a-zA-Z0-9_]+]] = OpLoad %type_sampled_image %tex1d | ||
| // CHECK: [[x:%[a-zA-Z0-9_]+]] = OpLoad %float %x | ||
| // CHECK: [[lod_query:%[a-zA-Z0-9_]+]] = OpImageQueryLod %v2float [[tex1_load]] [[x]] | ||
| // CHECK: [[lod:%[a-zA-Z0-9_]+]] = OpCompositeExtract %float [[lod_query]] 0 | ||
| // CHECK: OpStore %lod [[lod]] | ||
| float lod = tex1d.CalculateLevelOfDetail(x); | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s | ||
| // RUN: not %dxc -T ps_6_0 -E main -fcgl %s -spirv -DERROR 2>&1 | FileCheck %s --check-prefix=ERROR | ||
|
|
||
| // CHECK: OpCapability ImageQuery | ||
|
|
||
| // CHECK: [[type_1d_image:%[a-zA-Z0-9_]+]] = OpTypeImage %float 1D 0 0 0 1 Unknown | ||
| // CHECK: [[type_1d_sampled_image:%[a-zA-Z0-9_]+]] = OpTypeSampledImage [[type_1d_image]] | ||
|
|
||
| vk::SampledTexture1D<float4> tex1d; | ||
|
|
||
| void main() { | ||
| uint mipLevel = 1; | ||
| uint width, height, numLevels, elements, numSamples; | ||
|
|
||
| // CHECK: [[t1_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d | ||
| // CHECK-NEXT: [[image1:%[0-9]+]] = OpImage [[type_1d_image]] [[t1_load]] | ||
| // CHECK-NEXT: [[query1:%[0-9]+]] = OpImageQuerySizeLod %uint [[image1]] %int_0 | ||
| // CHECK-NEXT: OpStore %width [[query1]] | ||
| tex1d.GetDimensions(width); | ||
|
|
||
| // CHECK: [[t2_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d | ||
| // CHECK-NEXT: [[image2:%[0-9]+]] = OpImage [[type_1d_image]] [[t2_load]] | ||
| // CHECK-NEXT: [[mip:%[0-9]+]] = OpLoad %uint %mipLevel | ||
| // CHECK-NEXT: [[query2:%[0-9]+]] = OpImageQuerySizeLod %uint [[image2]] [[mip]] | ||
| // CHECK-NEXT: OpStore %width [[query2]] | ||
| // CHECK-NEXT: [[query_level_2:%[0-9]+]] = OpImageQueryLevels %uint [[image2]] | ||
| // CHECK-NEXT: OpStore %numLevels [[query_level_2]] | ||
| tex1d.GetDimensions(mipLevel, width, numLevels); | ||
|
|
||
| float f_width, f_height, f_numLevels; | ||
| // CHECK: [[t3_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d | ||
| // CHECK-NEXT: [[image3:%[0-9]+]] = OpImage [[type_1d_image]] [[t3_load]] | ||
| // CHECK-NEXT: [[query3:%[0-9]+]] = OpImageQuerySizeLod %uint [[image3]] %int_0 | ||
| // CHECK-NEXT: [[f_query3:%[0-9]+]] = OpConvertUToF %float [[query3]] | ||
| // CHECK-NEXT: OpStore %f_width [[f_query3]] | ||
| tex1d.GetDimensions(f_width); | ||
|
|
||
| // CHECK: [[t4_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d | ||
| // CHECK-NEXT: [[image4:%[0-9]+]] = OpImage [[type_1d_image]] [[t4_load]] | ||
| // CHECK-NEXT: [[mip4:%[0-9]+]] = OpLoad %uint %mipLevel | ||
| // CHECK-NEXT: [[query4:%[0-9]+]] = OpImageQuerySizeLod %uint [[image4]] [[mip4]] | ||
| // CHECK-NEXT: [[f_query4:%[0-9]+]] = OpConvertUToF %float [[query4]] | ||
| // CHECK-NEXT: OpStore %f_width [[f_query4]] | ||
| // CHECK-NEXT: [[query_level_4:%[0-9]+]] = OpImageQueryLevels %uint [[image4]] | ||
| // CHECK-NEXT: [[f_query_level_4:%[0-9]+]] = OpConvertUToF %float [[query_level_4]] | ||
| // CHECK-NEXT: OpStore %f_numLevels [[f_query_level_4]] | ||
| tex1d.GetDimensions(mipLevel, f_width, f_numLevels); | ||
|
|
||
| int i_width, i_height, i_numLevels; | ||
| // CHECK: [[t5_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d | ||
| // CHECK-NEXT: [[image5:%[0-9]+]] = OpImage [[type_1d_image]] [[t5_load]] | ||
| // CHECK-NEXT: [[query5:%[0-9]+]] = OpImageQuerySizeLod %uint [[image5]] %int_0 | ||
| // CHECK-NEXT: [[query5_i:%[0-9]+]] = OpBitcast %int [[query5]] | ||
| // CHECK-NEXT: OpStore %i_width [[query5_i]] | ||
| tex1d.GetDimensions(i_width); | ||
|
|
||
| // CHECK: [[t6_load:%[0-9]+]] = OpLoad [[type_1d_sampled_image]] %tex1d | ||
| // CHECK-NEXT: [[image6:%[0-9]+]] = OpImage [[type_1d_image]] [[t6_load]] | ||
| // CHECK-NEXT: [[mip6:%[0-9]+]] = OpLoad %uint %mipLevel | ||
| // CHECK-NEXT: [[query6:%[0-9]+]] = OpImageQuerySizeLod %uint [[image6]] [[mip6]] | ||
| // CHECK-NEXT: [[query6_i:%[0-9]+]] = OpBitcast %int [[query6]] | ||
| // CHECK-NEXT: OpStore %i_width [[query6_i]] | ||
| // CHECK-NEXT: [[query_level_6:%[0-9]+]] = OpImageQueryLevels %uint [[image6]] | ||
| // CHECK-NEXT: [[query_level_6_i:%[0-9]+]] = OpBitcast %int [[query_level_6]] | ||
| // CHECK-NEXT: OpStore %i_numLevels [[query_level_6_i]] | ||
| tex1d.GetDimensions(mipLevel, i_width, i_numLevels); | ||
|
|
||
| #ifdef ERROR | ||
| // ERROR: error: no matching member function for call to 'GetDimensions' | ||
| tex1d.GetDimensions(mipLevel, 0, height, numLevels); | ||
|
|
||
| // ERROR: error: no matching member function for call to 'GetDimensions' | ||
| tex1d.GetDimensions(width, 20); | ||
| #endif | ||
| } |
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.
Since the point here it to allow any SampledTexture, the 2 exact string match just after could be dropped no?
Uh oh!
There was an error while loading. Please reload this page.
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.
Here the util is checking whether it's a multi-sampling texture, so it's necessary we add this second check.