Skip to content

Implement the CheckAccessFullyMapped HLSL Function #99204

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

Open
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 1 comment
Open
Tracked by #99235

Implement the CheckAccessFullyMapped HLSL Function #99204

farzonl opened this issue Jul 16, 2024 · 1 comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

Implement the CheckAccessFullyMapped HLSL function in hlsl_intrinsics.h.

To match DXC when targeting DirectX, this operation can essentially just be a cast from uint to bool - the backend already handles inserting the DXIL op where necessary when the status of a load, gather, or sample is used, as per https://llvm.org/docs/DirectX/DXILResources.html#loads-samples-and-gathers.

For SPIR-V DXC maps this to OpImageSparseTexelsResident (See https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst). In this case it does not appear to behave simply as a cast to bool and might need more work.

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
71 CheckAccessFullyMapped 6.0 ()

SPIR-V

OpImageSparseTexelsResident:

Description:

Translates a Resident Code into a Boolean. Result is false if any
of the texels were in uncommitted texture memory, and true
otherwise.

Result Type must be a Boolean type scalar.

Resident Code is a value from an OpImageSparse…​ instruction that
results in a resident code.

Capability:
SparseResidency

Word Count Opcode Results Operands

4

316

<id>
Result Type

Result <id>

<id>
Resident Code

Test Case(s)

Example 1

//dxc CheckAccessFullyMapped_test.hlsl -T lib_6_8 -enable-16bit-types -O0

RWBuffer<float4> g_buffer;

[numthreads(1, 1, 1)]
[shader("pixel")]
bool fn( ) : SV_Target {
	uint p1;
	float4 data = g_buffer.Load(0, p1);
	return CheckAccessFullyMapped(p1);
}

HLSL:

Determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource.

Syntax

bool CheckAccessFullyMapped(
  in uint_only status
);

Parameters

status [in]

Type: uint_only

The status value that is returned from a Sample, Gather, or Load operation. Because you can't access this status value directly, you need to pass it to CheckAccessFullyMapped.

Return value

Type: bool

Returns a Boolean value that indicates whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource. Returns TRUE if all values from the operation accessed mapped tiles; otherwise, returns FALSE if any values were taken from an unmapped tile.

Remarks

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 5 and higher shader models yes

 

This function is supported in the following types of shaders:

Vertex Hull Domain Geometry Pixel Compute
x x

 

See also

Intrinsic Functions

@farzonl farzonl added backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
@damyanp damyanp moved this to Ready in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Ready to Planning in HLSL Support Oct 30, 2024
@bogner bogner removed the status in HLSL Support May 7, 2025
@damyanp damyanp moved this to Planning in HLSL Support May 7, 2025
@damyanp damyanp removed the status in HLSL Support May 7, 2025
@damyanp
Copy link
Contributor

damyanp commented May 7, 2025

This needs more planning work to figure out what we'll be doing for SPIR-V. Once that's done and the issue is updated we can take it back to refinement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: No status
Development

No branches or pull requests

2 participants