Skip to content

Conversation

@bob80905
Copy link
Contributor

@bob80905 bob80905 commented Oct 17, 2025

This PR is the first step in bringing support to testing with partially mapped and unmapped resources.
It lays out the infrastructure necessary to initialize resources with only a certain number of tiles mapped.
The Load overload that takes the 2nd status argument is implemented in DXC, so we take advantage of that and test that when accessing data in an unmapped resource, we get 0'd data and the status integer is also 0.

The test is currently unsupported in Clang and Vulkan, but will be supported in the future.
Fixes #182

Copy link
Collaborator

@bogner bogner left a comment

Choose a reason for hiding this comment

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

This is great. We may want to revisit and see if we can do some code deduplication in a nice way at some point, but I think this makes sense as is for now.

A few of minor comments.

std::optional<VulkanBinding> VKBinding;
Buffer *BufferPtr = nullptr;
bool HasCounter;
int TilesMapped = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

std::optional<int> would be clearer than using -1 as a sigil here, and isn't really that much more expensive.

Comment on lines 12 to 13


Copy link
Collaborator

Choose a reason for hiding this comment

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

Some extra whitespace here

Comment on lines 16 to 17
// 32 S structs inside X or Y occupy 64KB of data. (32 * 512 ints * 4 bytes per int)
// So, any index into the buffer >= [32] will access a new "tile"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this might be over 80-column. It's a bit annoying to clang-format within these .test files (easiest is to paste in another file and clang-format that...), but please try to follow LLVM style regardless.

Comment on lines -756 to +1137
memset(ExtraData, 0, CBVSize - R.size() - 1);
memset(ExtraData, 0, CBVSize - R.size());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this an unrelated bug fix? I'm nervous about a change like this without accompanying tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is, but I won't be in the business of writing a test for this change here in this PR.
I'll undo this for now.
#477

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you still intending to undo this change, or did you find it is actually required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am intending to undo this change, it should already be undone right now.

Format: Int32
Stride: 2048 # S is 512 ints, 512*4 = 2048.
FillSize: 131072
FillValue: 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's easier to see what parts of the data are read if we use something more noticeable here (like 42, or 9001 or whatever)

Comment on lines 127 to 128
# XFAIL: Clang
# XFAIL: Vulkan
Copy link
Collaborator

Choose a reason for hiding this comment

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

These need comments like Unimplemented <link to issue> or Bug <link to issue> so that we can track why they're XFAIL'd and loop back appropriately.

@bob80905 bob80905 force-pushed the add_unmapped_resources_tests branch from 8d9cbbb to d3cbf91 Compare October 22, 2025 20:12
Comment on lines 735 to 740
// Tile mapping setup (optional if NumTiles > 0)
const UINT NumTiles = getNumTiles(R.TilesMapped, ResDesc.Width);

ComPtr<ID3D12Heap> Heap; // optional, only created if NumTiles > 0

if (NumTiles > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole block (up to the updateTileMappings call) looks identical to the SRV version. Can we pull out a helper function to call in both cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out I'll have to leave unmapped UAVs for another time, so I'll pull out a helper function in a future PR.

Comment on lines 580 to 581
// Tile mapping setup (optional if NumTiles > 0)
const UINT NumTiles = getNumTiles(R.TilesMapped, ResDesc.Width);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment feels a bit confusing - NumTiles being zero is the edge case given that it can only happen if we explicitly set zero tiles. "optional if NumTiles > 0" sounds to me like NumTiles will usually be zero.

@bob80905 bob80905 force-pushed the add_unmapped_resources_tests branch from afcbf1e to 3e78f39 Compare October 24, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for reserved resources to the offload tester

3 participants