Skip to content

Implement the GetRenderTargetSamplePosition HLSL Function #99103

@farzonl

Description

@farzonl
  • Implement GetRenderTargetSamplePosition clang builtin,
    Link GetRenderTargetSamplePosition clang builtin with hlsl_intrinsics.h
    Add sema checks for GetRenderTargetSamplePosition to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
    Add codegen for GetRenderTargetSamplePosition to EmitHLSLBuiltinExpr in CGBuiltin.cpp
    Add codegen tests to clang/test/CodeGenHLSL/builtins/GetRenderTargetSamplePosition.hlsl
    Add sema tests to clang/test/SemaHLSL/BuiltIns/GetRenderTargetSamplePosition-errors.hlsl
    Create the int_dx_GetRenderTargetSamplePosition intrinsic in IntrinsicsDirectX.td
    Create the DXILOpMapping of int_dx_GetRenderTargetSamplePosition to 76 in DXIL.td
    Create the GetRenderTargetSamplePosition.ll and GetRenderTargetSamplePosition_errors.ll tests in llvm/test/CodeGen/DirectX/

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
76 RenderTargetGetSamplePosition 6.0 ('pixel',)

SPIR-V

There is no support for GetRenderTargetSamplePosition when targeting SPIR-V.

Test Case(s)

Example 1

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

[numthreads(1, 1, 1)]
[shader("pixel")]
float2 fn( ) : SV_Target {
	int p1;
	return GetRenderTargetSamplePosition(p1);
}

HLSL:

Gets the sampling position (x,y) for a given sample index.

float<2> GetRenderTargetSamplePosition( in int<1> Index
);

Parameters

Item Description
Index
[in] A zero-based sample index.

Return Value

The (x,y) position of the given sample.

Remarks

Use this function and GetRenderTargetSampleCount to find out the number and position of the sampling locations for a render target.

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

See also

Intrinsic Functions (DirectX HLSL)

Activity

added
HLSLHLSL Language Support
metabugIssue to collect references to a group of similar or related issues.
on Jul 16, 2024
moved this to Ready in HLSL Supporton Oct 30, 2024
moved this from Ready to Planning in HLSL Supporton Oct 30, 2024
davidcook-msft

davidcook-msft commented on Nov 12, 2024

@davidcook-msft

@farzonl to create a new issue to track making this Op in SPIR-V

moved this from Planning to Ready in HLSL Supporton Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    HLSLHLSL Language Supportbackend:DirectXbot:HLSLmetabugIssue to collect references to a group of similar or related issues.

    Type

    No type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Development

    No branches or pull requests

      Participants

      @farzonl@davidcook-msft

      Issue actions

        Implement the `GetRenderTargetSamplePosition` HLSL Function · Issue #99103 · llvm/llvm-project