-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[DirectX] Validate if Textures/TypedBuffers are being bound in Root Signatures #147573
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
joaosaffran
wants to merge
9
commits into
llvm:users/joaosaffran/146785
Choose a base branch
from
joaosaffran:validation/textures-not-bind-root-signatures
base: users/joaosaffran/146785
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
01a558b
add validation
43eb04e
adding validation
f67bec1
Merge branch 'validation/check-descriptors-are-bound' into validation…
d7b4cf4
format
c7d5be7
format
cc5afae
address changes
974d4bc
Merge branch 'refactoring/updating-return-root-sig-analysis' into val…
403b546
Merge branch 'validation/check-descriptors-are-bound' into validation…
aea75da
fix test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
clang/test/SemaHLSL/RootSignature-Validation-Textures.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: not %clang_dxc -T cs_6_6 -E CSMain %s 2>&1 | FileCheck %s | ||
|
||
// CHECK: error: register srv (space=0, register=0) is bound to a texture or typed buffer. | ||
|
||
RWStructuredBuffer<int> Out : register(u0); | ||
Buffer<float> B : register(t0); | ||
// Compute Shader for UAV testing | ||
[numthreads(8, 8, 1)] | ||
[RootSignature("SRV(t0), UAV(u0)")] | ||
void CSMain(uint id : SV_GroupID) | ||
{ | ||
Out[0] = B[0]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
llvm/test/CodeGen/DirectX/rootsignature-validation-textures.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
; RUN: not opt -S -passes='dxil-post-optimization-validation' -mtriple=dxil-pc-shadermodel6.6-compute %s 2>&1 | ||
; CHECK: error: register srv (space=0, register=0) is bound to a texture or typed buffer. | ||
|
||
; | ||
; Resource Bindings: | ||
; | ||
; Name Type Format Dim ID HLSL Bind Count | ||
; ------------------------------ ---------- ------- ----------- ------- -------------- --------- | ||
; B texture f32 buf T0 t0 1 | ||
; Out UAV struct r/w U0 u0 1 | ||
; | ||
; ModuleID = '../clang/test/SemaHLSL/RootSignature-Validation-Textures.hlsl' | ||
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64" | ||
target triple = "dxilv1.5-unknown-shadermodel6.5-compute" | ||
|
||
%"Buffer<float>" = type { float } | ||
%"RWStructuredBuffer<int32_t>" = type { i32 } | ||
|
||
@.str = private unnamed_addr constant [4 x i8] c"Out\00", align 1 | ||
@.str.2 = private unnamed_addr constant [2 x i8] c"B\00", align 1 | ||
@B = external constant %"Buffer<float>" | ||
@Out = external constant %"RWStructuredBuffer<int32_t>" | ||
|
||
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) | ||
define void @CSMain() local_unnamed_addr #0 { | ||
entry: | ||
%0 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 1, i32 0, i1 false, ptr nonnull @.str) | ||
%1 = tail call target("dx.TypedBuffer", float, 0, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_0_0_0t(i32 0, i32 0, i32 1, i32 0, i1 false, ptr nonnull @.str.2) | ||
%2 = call { float, i1 } @llvm.dx.resource.load.typedbuffer.f32.tdx.TypedBuffer_f32_0_0_0t(target("dx.TypedBuffer", float, 0, 0, 0) %1, i32 0) | ||
%3 = extractvalue { float, i1 } %2, 0 | ||
%conv.i = fptosi float %3 to i32 | ||
call void @llvm.dx.resource.store.rawbuffer.tdx.RawBuffer_i32_1_0t.i32(target("dx.RawBuffer", i32, 1, 0) %0, i32 0, i32 0, i32 %conv.i) | ||
ret void | ||
} | ||
|
||
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) | ||
declare target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32, i32, i32, i32, i1, ptr) #1 | ||
|
||
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) | ||
declare target("dx.TypedBuffer", float, 0, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_0_0_0t(i32, i32, i32, i32, i1, ptr) #1 | ||
|
||
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) | ||
declare ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0), i32) #1 | ||
|
||
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) | ||
declare ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_f32_0_0_0t(target("dx.TypedBuffer", float, 0, 0, 0), i32) #1 | ||
|
||
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read) | ||
declare { float, i1 } @llvm.dx.resource.load.typedbuffer.f32.tdx.TypedBuffer_f32_0_0_0t(target("dx.TypedBuffer", float, 0, 0, 0), i32) #2 | ||
|
||
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(write) | ||
declare void @llvm.dx.resource.store.rawbuffer.tdx.RawBuffer_i32_1_0t.i32(target("dx.RawBuffer", i32, 1, 0), i32, i32, i32) #3 | ||
|
||
attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) "approx-func-fp-math"="true" "frame-pointer"="all" "hlsl.numthreads"="8,8,1" "hlsl.shader"="compute" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) } | ||
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(read) } | ||
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(write) } | ||
|
||
!dx.rootsignatures = !{!0} | ||
!llvm.module.flags = !{!4, !5} | ||
!dx.valver = !{!6} | ||
!llvm.ident = !{!7} | ||
!dx.shaderModel = !{!8} | ||
!dx.version = !{!9} | ||
!dx.resources = !{!10} | ||
!dx.entryPoints = !{!17} | ||
|
||
!0 = !{ptr @CSMain, !1, i32 2} | ||
!1 = !{!2, !3} | ||
!2 = !{!"RootSRV", i32 0, i32 0, i32 0, i32 4} | ||
!3 = !{!"RootUAV", i32 0, i32 0, i32 0, i32 2} | ||
!4 = !{i32 1, !"wchar_size", i32 4} | ||
!5 = !{i32 7, !"frame-pointer", i32 2} | ||
!6 = !{i32 1, i32 8} | ||
!7 = !{!"clang version 21.0.0git (https://github.com/joaosaffran/llvm-project.git c16f15b4cd469a3f6efc2e4b0e098190d7fd0787)"} | ||
!8 = !{!"cs", i32 6, i32 5} | ||
!9 = !{i32 1, i32 5} | ||
!10 = !{!11, !14, null, null} | ||
!11 = !{!12} | ||
!12 = !{i32 0, ptr @B, !"B", i32 0, i32 0, i32 1, i32 10, i32 0, !13} | ||
!13 = !{i32 0, i32 9} | ||
!14 = !{!15} | ||
!15 = !{i32 0, ptr @Out, !"Out", i32 0, i32 0, i32 1, i32 12, i1 false, i1 false, i1 false, !16} | ||
!16 = !{i32 1, i32 4} | ||
!17 = !{ptr @CSMain, !"CSMain", null, !10, !18} | ||
!18 = !{i32 0, i64 16, i32 4, !19} | ||
!19 = !{i32 8, i32 8, i32 1} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the right place for this test - we can't have clang tests for llvm backend behaviour. We'll need something in
llvm/test/CodeGen/DirectX
instead.