Skip to content

[SPIR-V][vk::SampledTexture] #10. Support vk::SampledTexture1D and vk::SampledTexture1DArray type. #8212

Open
luciechoi wants to merge 5 commits intomicrosoft:mainfrom
luciechoi:texture1d
Open

[SPIR-V][vk::SampledTexture] #10. Support vk::SampledTexture1D and vk::SampledTexture1DArray type. #8212
luciechoi wants to merge 5 commits intomicrosoft:mainfrom
luciechoi:texture1d

Conversation

@luciechoi
Copy link
Collaborator

Part of #7979

The function definitions are equivalent to that of Texture1D counterparts, just without Sampler argument.

@luciechoi
Copy link
Collaborator Author

(@Keenuts @s-perron next SampledTexture PR for review)

Copy link
Collaborator

@Keenuts Keenuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1278 to +1279
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are not tested

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not tested.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not tested.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not tested.

$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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not tested

$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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not tested

$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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not tested

@github-project-automation github-project-automation bot moved this from New to In progress in HLSL Roadmap Mar 19, 2026
@luciechoi
Copy link
Collaborator Author

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.

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.

@luciechoi luciechoi requested a review from Keenuts March 20, 2026 00:50
@Keenuts
Copy link
Collaborator

Keenuts commented Mar 20, 2026

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.

If something is not tested, something can be removed accidentally without us noticing.
That's why some projects implement mutation testing or similar.
The test does not have to be complex, but we should make sure each overload is at least present through a test.

Copy link
Collaborator

@s-perron s-perron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we need to haves testing for all for all of the new functions, even if the code generating them is the same. I think you are working on that.

We can also improve some string checking, which can be slow.

Comment on lines +865 to +868
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Comment on lines +852 to 854
if (name == "SampledTexture1D" || name == "SampledTexture1DArray" ||
name == "SampledTexture2D" || name == "SampledTexture2DArray" ||
name == "SampledTexture2DMS" || name == "SampledTexture2DMSArray") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is turning into a lot of string compares. Could we simplly do:

name.startswith("SampledTexture");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants