[SPIR-V][vk::SampledTexture] #10. Support vk::SampledTexture1D and vk::SampledTexture1DArray type. #8212
[SPIR-V][vk::SampledTexture] #10. Support vk::SampledTexture1D and vk::SampledTexture1DArray type. #8212luciechoi wants to merge 5 commits intomicrosoft:mainfrom
vk::SampledTexture1D and vk::SampledTexture1DArray type. #8212Conversation
d198142 to
7d4ff86
Compare
Keenuts
left a comment
There was a problem hiding this comment.
Overall looks good, but many overloads are not tested. I stopped checking after a few, but overall we should have at least one test for each overload.
| void [[]] GetDimensions(in uint x, out uint_only width, out $type2 elements, out $type2 levels) : resinfo_uint; | ||
| void [[]] GetDimensions(in uint x, out float_like width, out $type2 elements, out $type2 levels) : resinfo; |
| void [[]] GetDimensions(in uint x, out uint_only width, out $type2 elements, out $type2 levels) : resinfo_uint; | ||
| void [[]] GetDimensions(in uint x, out float_like width, out $type2 elements, out $type2 levels) : resinfo; | ||
| void [[]] GetDimensions(out uint_only width, out $type1 elements) : resinfo_uint_o; | ||
| void [[]] GetDimensions(out float_like width, out $type1 elements) : resinfo_o; |
| void [[]] GetDimensions(out uint_only width, out $type1 elements) : resinfo_uint_o; | ||
| void [[]] GetDimensions(out float_like width, out $type1 elements) : resinfo_o; | ||
| $classT [[ro]] Load(in int<3> x) : tex1d_t_load_array; | ||
| $classT [[ro]] Load(in int<3> x, in int<1> o) : tex1d_t_load_array_o; |
| void [[]] GetDimensions(out float_like width, out $type1 elements) : resinfo_o; | ||
| $classT [[ro]] Load(in int<3> x) : tex1d_t_load_array; | ||
| $classT [[ro]] Load(in int<3> x, in int<1> o) : tex1d_t_load_array_o; | ||
| $classT [[]] Load(in int<3> x, in int<1> o, out uint_only status) : tex1d_t_load_array_o_s; |
| $classT [[ro]] Load(in int<3> x, in int<1> o) : tex1d_t_load_array_o; | ||
| $classT [[]] Load(in int<3> x, in int<1> o, out uint_only status) : tex1d_t_load_array_o_s; | ||
| $classT [[ro]] Sample(in float<2> x) : tex1d_t_array; | ||
| $classT [[ro]] Sample(in float<2> x, in int<1> o) : tex1d_t_array_o; |
| $classT [[]] Load(in int<3> x, in int<1> o, out uint_only status) : tex1d_t_load_array_o_s; | ||
| $classT [[ro]] Sample(in float<2> x) : tex1d_t_array; | ||
| $classT [[ro]] Sample(in float<2> x, in int<1> o) : tex1d_t_array_o; | ||
| $classT [[ro]] SampleBias(in float<2> x, in float bias) : tex1d_t_bias_array; |
| $classT [[ro]] SampleBias(in float<2> x, in float bias) : tex1d_t_bias_array; | ||
| $classT [[ro]] SampleBias(in float<2> x, in float bias, in int<1> o) : tex1d_t_bias_array_o; | ||
| float_like [[ro]] SampleCmp(in float<2> x, in float compareValue) : tex1d_t_comp_array; | ||
| float_like [[ro]] SampleCmp(in float<2> x, in float compareValue, in int<1> o) : tex1d_t_comp_array_o; |
Hmmm do you mean every function variant should have a test..? The overloads are tested with SampledTexture2D type, and adding a 1D type doesn't require code changes. I took a look at adding these, but noticed that the existing test coverage for the other texture types (like Texture2D, Texture2DMS, and their array counterparts) also doesn't exhaustively test every single overload. To keep the scope of this PR manageable and maintain parity with regular Texture types, I've mirrored the existing level of coverage for the 1D types. Let me know if there's a specific overload variant you are concerned about and I'd be happy to add a test just for that one. |
If something is not tested, something can be removed accidentally without us noticing. |
| const spv::Dim dimension = | ||
| name.count("1D") > 0 ? spv::Dim::Dim1D : spv::Dim::Dim2D; | ||
| const bool isArray = name.count("Array") > 0; | ||
| const bool isMS = name.count("MS") > 0; |
There was a problem hiding this comment.
count iterates over the whole string. You can use other member functions that might be more efficient.
I don't know all of the future cases we might need to handle.
Could we do:
// Drop the "SampledTexture" prefix.
1 StringRef suffix = name.drop_front(14);
2 const spv::Dim dimension =
3 suffix.startswith("1D") ? spv::Dim::Dim1D : spv::Dim::Dim2D;
4 const bool isArray = suffix.endswith("Array");
5 const bool isMS = suffix.find("MS") != StringRef::npos;
| if (name == "SampledTexture1D" || name == "SampledTexture1DArray" || | ||
| name == "SampledTexture2D" || name == "SampledTexture2DArray" || | ||
| name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") { |
There was a problem hiding this comment.
This is turning into a lot of string compares. Could we simplly do:
name.startswith("SampledTexture");
Part of #7979
The function definitions are equivalent to that of Texture1D counterparts, just without Sampler argument.