-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit consists of the original changes made by s-perron that emits a relocatable entry for each descriptor load, instead of baking in a constant offset during initial compilation. The compiler patches up the compiled binary with actual descriptor offset at a later time when that info is available.
- Loading branch information
Yong He
committed
Mar 20, 2020
1 parent
428a1e2
commit 4a25fbe
Showing
8 changed files
with
526 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
67 changes: 67 additions & 0 deletions
67
llpc/test/shaderdb/PipelineCs_RelocCombinedTextureSampler.pipe
This file contains 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,67 @@ | ||
|
||
// This test case checks that two relocation entries are generated for a combined texture sampler descriptor, | ||
// one for the resource handle offset, and another for the sampler handle offset. | ||
; BEGIN_SHADERTEST | ||
; RUN: amdllpc -spvgen-dir=%spvgendir% -use-relocatable-shader-elf -o test_cs_pipeline_out_reloccombinedtex.elf %gfxip %s && llvm-objdump -triple=amdgcn -mcpu=gfx900 -d test_cs_pipeline_out_reloccombinedtex.elf | FileCheck -check-prefix=SHADERTEST %s && rm test_cs_pipeline_out_reloccombinedtex.elf | ||
// Test that correct relocated offsets are in the linked texture fetching code. | ||
; SHADERTEST-LABEL: 0000000000000000 _amdgpu_cs_main: | ||
// Matching the relocation entry for the resource descriptor | ||
; SHADERTEST-DAG: s_mov_b32 s[[RELOREG_RESOURCE:[0-9]+]], 16 //{{.*}} | ||
// Matching the relocation entry for the sampler descriptor | ||
; SHADERTEST-DAG: s_mov_b32 s[[RELOREG_SAMPLER:[0-9]+]], 48 //{{.*}} | ||
// Loading the resource descriptor | ||
; SHADERTEST: s_load_dwordx8 s[[RESOURCE_REG:\[[0-9]+:[0-9]+\]]], s[{{.*}}:{{.*}}], s[[RELOREG_RESOURCE]] //{{.*}} | ||
// Loading the sampler descriptor | ||
; SHADERTEST: s_load_dwordx4 s[[SAMPLER_REG:\[[0-9]+:[0-9]+\]]], s[{{.*}}:{{.*}}], s[[RELOREG_SAMPLER]] //{{.*}} | ||
// Sampling the texture | ||
; SHADERTEST: image_sample_lz v[0:3], v0, s[[RESOURCE_REG]], s[[SAMPLER_REG]] {{.*}} | ||
; END_SHADERTEST | ||
|
||
; BEGIN_SHADERTEST | ||
; RUN: amdllpc -spvgen-dir=%spvgendir% -use-relocatable-shader-elf -v %gfxip %s | FileCheck -check-prefix=SHADERTEST1 %s | ||
; SHADERTEST1-LABEL: {{^// LLPC}} pipeline patching results | ||
; SHADERTEST1: %[[RELOCONST:[0-9]+]] = call i32 @llvm.amdgcn.reloc.constant(metadata !{{.*}}) | ||
; SHADERTEST1: %[[RELOCONSTEXT:[0-9]+]] = zext i32 %[[RELOCONST]] to i64 | ||
; SHADERTEST1: %[[BUFFERDESCPTR:[0-9]+]] = getelementptr [4294967295 x i8], [4294967295 x i8] addrspace(4)* %{{.*}}, i64 0, i64 %[[RELOCONSTEXT]] | ||
; SHADERTEST1: %[[BUFFERADDR:[0-9]+]] = bitcast i8 addrspace(4)* %[[BUFFERDESCPTR]] to <4 x i32> addrspace(4)*, !amdgpu.uniform !{{.*}} | ||
; SHADERTEST1: %{{[0-9]+}} = load <4 x i32>, <4 x i32> addrspace(4)* %[[BUFFERADDR]], align 16, !invariant.load !{{.*}} | ||
; SHADERTEST1: AMDLLPC SUCCESS | ||
; END_SHADERTEST | ||
|
||
[CsGlsl] | ||
#version 450 | ||
#extension GL_ARB_separate_shader_objects : enable | ||
|
||
layout(binding = 0) uniform sampler2D texSampler; | ||
|
||
layout(set = 1, binding = 0, std430) buffer OUT | ||
{ | ||
vec4 o; | ||
}; | ||
|
||
layout(local_size_x = 2, local_size_y = 3) in; | ||
void main() { | ||
o = texture(texSampler, vec2(0.0, 0.0)); | ||
} | ||
|
||
|
||
[CsInfo] | ||
entryPoint = main | ||
userDataNode[0].type = DescriptorTableVaPtr | ||
userDataNode[0].offsetInDwords = 0 | ||
userDataNode[0].sizeInDwords = 1 | ||
userDataNode[0].set = 0 | ||
userDataNode[0].next[0].type = DescriptorCombinedTexture | ||
userDataNode[0].next[0].offsetInDwords = 4 | ||
userDataNode[0].next[0].sizeInDwords = 12 | ||
userDataNode[0].next[0].set = 0 | ||
userDataNode[0].next[0].binding = 0 | ||
userDataNode[1].type = DescriptorTableVaPtr | ||
userDataNode[1].offsetInDwords = 1 | ||
userDataNode[1].sizeInDwords = 1 | ||
userDataNode[1].set = 1 | ||
userDataNode[1].next[0].type = DescriptorBuffer | ||
userDataNode[1].next[0].offsetInDwords = 16 | ||
userDataNode[1].next[0].sizeInDwords = 8 | ||
userDataNode[1].next[0].set = 1 | ||
userDataNode[1].next[0].binding = 0 |
This file contains 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,58 @@ | ||
// This test case checks that descriptor offset relocation works for buffer descriptors in a compute pipeline. | ||
; BEGIN_SHADERTEST | ||
; RUN: amdllpc -spvgen-dir=%spvgendir% -use-relocatable-shader-elf -o test_cs_pipeline_out_relocconst.elf %gfxip %s && llvm-objdump -triple=amdgcn -mcpu=gfx900 -d test_cs_pipeline_out_relocconst.elf | FileCheck -check-prefix=SHADERTEST %s && rm test_cs_pipeline_out_relocconst.elf | ||
; SHADERTEST-LABEL: 0000000000000000 _amdgpu_cs_main: | ||
; SHADERTEST: s_mov_b32 s[[RELOREG:[0-9]+]], 16 //{{.*}} | ||
; SHADERTEST: s_load_dwordx4 s[{{.*}}:{{.*}}], s[{{.*}}:{{.*}}], s[[RELOREG]] //{{.*}} | ||
; END_SHADERTEST | ||
|
||
; BEGIN_SHADERTEST | ||
; RUN: amdllpc -spvgen-dir=%spvgendir% -use-relocatable-shader-elf -v %gfxip %s | FileCheck -check-prefix=SHADERTEST1 %s | ||
; SHADERTEST1-LABEL: {{^// LLPC}} pipeline patching results | ||
; SHADERTEST1: %[[RELOCONST:[0-9]+]] = call i32 @llvm.amdgcn.reloc.constant(metadata !{{.*}}) | ||
; SHADERTEST1: %[[RELOCONSTEXT:[0-9]+]] = zext i32 %[[RELOCONST]] to i64 | ||
; SHADERTEST1: %[[BUFFERDESCPTR:[0-9]+]] = getelementptr [4294967295 x i8], [4294967295 x i8] addrspace(4)* %{{.*}}, i64 0, i64 %[[RELOCONSTEXT]] | ||
; SHADERTEST1: %[[BUFFERADDR:[0-9]+]] = bitcast i8 addrspace(4)* %[[BUFFERDESCPTR]] to <4 x i32> addrspace(4)*, !amdgpu.uniform !{{.*}} | ||
; SHADERTEST1: %{{[0-9]+}} = load <4 x i32>, <4 x i32> addrspace(4)* %[[BUFFERADDR]], align 16, !invariant.load !{{.*}} | ||
; SHADERTEST1: AMDLLPC SUCCESS | ||
; END_SHADERTEST | ||
|
||
[CsGlsl] | ||
#version 450 | ||
#extension GL_ARB_separate_shader_objects : enable | ||
|
||
layout(binding = 0) uniform UniformBufferObject { | ||
vec4 i; | ||
} ubo; | ||
|
||
layout(set = 1, binding = 0, std430) buffer OUT | ||
{ | ||
vec4 o; | ||
}; | ||
|
||
layout(local_size_x = 2, local_size_y = 3) in; | ||
void main() { | ||
o = ubo.i; | ||
} | ||
|
||
|
||
[CsInfo] | ||
entryPoint = main | ||
userDataNode[0].type = DescriptorTableVaPtr | ||
userDataNode[0].offsetInDwords = 0 | ||
userDataNode[0].sizeInDwords = 1 | ||
userDataNode[0].set = 0 | ||
userDataNode[0].next[0].type = DescriptorBuffer | ||
userDataNode[0].next[0].offsetInDwords = 4 | ||
userDataNode[0].next[0].sizeInDwords = 8 | ||
userDataNode[0].next[0].set = 0 | ||
userDataNode[0].next[0].binding = 0 | ||
userDataNode[1].type = DescriptorTableVaPtr | ||
userDataNode[1].offsetInDwords = 1 | ||
userDataNode[1].sizeInDwords = 1 | ||
userDataNode[1].set = 1 | ||
userDataNode[1].next[0].type = DescriptorBuffer | ||
userDataNode[1].next[0].offsetInDwords = 4 | ||
userDataNode[1].next[0].sizeInDwords = 8 | ||
userDataNode[1].next[0].set = 1 | ||
userDataNode[1].next[0].binding = 0 |
This file contains 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,104 @@ | ||
|
||
// This test case checks that descriptor offset relocation works for buffer descriptors in a vs/fs pipeline. | ||
; BEGIN_SHADERTEST | ||
; RUN: amdllpc -spvgen-dir=%spvgendir% -use-relocatable-shader-elf -o test_pipeline_out_relocconst.elf %gfxip %s && llvm-objdump -triple=amdgcn -mcpu=gfx900 -d test_pipeline_out_relocconst.elf | FileCheck -check-prefix=SHADERTEST %s && rm test_pipeline_out_relocconst.elf | ||
; SHADERTEST-LABEL: 0000000000000000 _amdgpu_vs_main: | ||
; SHADERTEST: s_mov_b32 s[[RELOREG:[0-9]+]], 12 //{{.*}} | ||
; SHADERTEST: s_load_dwordx4 s[{{.*}}:{{.*}}], s[{{.*}}:{{.*}}], s[[RELOREG]] //{{.*}} | ||
; SHADERTEST: {{[0-9A-Za-z]+}} _amdgpu_ps_main: | ||
; END_SHADERTEST | ||
|
||
; BEGIN_SHADERTEST | ||
; RUN: amdllpc -spvgen-dir=%spvgendir% -use-relocatable-shader-elf -v %gfxip %s | FileCheck -check-prefix=SHADERTEST1 %s | ||
; SHADERTEST1-LABEL: {{^// LLPC}} pipeline patching results | ||
; SHADERTEST1: %[[RELOCONST:[0-9]+]] = call i32 @llvm.amdgcn.reloc.constant(metadata !{{.*}}) | ||
; SHADERTEST1: %[[RELOCONSTEXT:[0-9]+]] = zext i32 %[[RELOCONST]] to i64 | ||
; SHADERTEST1: %[[BUFFERDESCPTR:[0-9]+]] = getelementptr [4294967295 x i8], [4294967295 x i8] addrspace(4)* %{{.*}}, i64 0, i64 %[[RELOCONSTEXT]] | ||
; SHADERTEST1: %[[BUFFERADDR:[0-9]+]] = bitcast i8 addrspace(4)* %[[BUFFERDESCPTR]] to <4 x i32> addrspace(4)*, !amdgpu.uniform !{{.*}} | ||
; SHADERTEST1: %{{[0-9]+}} = load <4 x i32>, <4 x i32> addrspace(4)* %[[BUFFERADDR]], align 16, !invariant.load !{{.*}} | ||
; SHADERTEST1: AMDLLPC SUCCESS | ||
; END_SHADERTEST | ||
|
||
[VsGlsl] | ||
#version 450 | ||
#extension GL_ARB_separate_shader_objects : enable | ||
|
||
layout(binding = 0) uniform UniformBufferObject { | ||
mat4 model; | ||
mat4 view; | ||
vec4 proj; | ||
} ubo; | ||
|
||
layout(location = 0) in vec2 inPosition; | ||
layout(location = 1) in vec3 inColor; | ||
|
||
layout(location = 0) out vec3 fragColor; | ||
|
||
void main() { | ||
gl_Position = ubo.proj; | ||
fragColor = inColor; | ||
} | ||
|
||
|
||
[VsInfo] | ||
entryPoint = main | ||
userDataNode[0].type = IndirectUserDataVaPtr | ||
userDataNode[0].offsetInDwords = 0 | ||
userDataNode[0].sizeInDwords = 1 | ||
userDataNode[0].indirectUserDataCount = 0 | ||
userDataNode[1].type = DescriptorTableVaPtr | ||
userDataNode[1].offsetInDwords = 1 | ||
userDataNode[1].sizeInDwords = 4 | ||
userDataNode[1].set = 0 | ||
userDataNode[1].next[0].type = DescriptorBuffer | ||
userDataNode[1].next[0].offsetInDwords = 3 | ||
userDataNode[1].next[0].sizeInDwords = 8 | ||
userDataNode[1].next[0].set = 0 | ||
userDataNode[1].next[0].binding = 0 | ||
|
||
trapPresent = 0 | ||
debugMode = 0 | ||
enablePerformanceData = 0 | ||
vgprLimit = 0 | ||
sgprLimit = 0 | ||
maxThreadGroupsPerComputeUnit = 0 | ||
|
||
[FsGlsl] | ||
#version 450 | ||
#extension GL_ARB_separate_shader_objects : enable | ||
|
||
layout(location = 0) in vec3 fragColor; | ||
layout(location = 0) out vec4 outputColor; | ||
void main() { | ||
outputColor = vec4(fragColor, 1.0); | ||
} | ||
|
||
[FsInfo] | ||
entryPoint = main | ||
trapPresent = 0 | ||
debugMode = 0 | ||
enablePerformanceData = 0 | ||
vgprLimit = 0 | ||
sgprLimit = 0 | ||
maxThreadGroupsPerComputeUnit = 0 | ||
|
||
[GraphicsPipelineState] | ||
topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP | ||
patchControlPoints = 0 | ||
deviceIndex = 0 | ||
disableVertexReuse = 0 | ||
switchWinding = 0 | ||
enableMultiView = 0 | ||
depthClipEnable = 1 | ||
rasterizerDiscardEnable = 0 | ||
perSampleShading = 1 | ||
numSamples = 8 | ||
samplePatternIdx = 48 | ||
usrClipPlaneMask = 0 | ||
includeDisassembly = 0 | ||
alphaToCoverageEnable = 0 | ||
dualSourceBlendEnable = 1 | ||
colorBuffer[0].format = VK_FORMAT_R32G32B32A32_SFLOAT | ||
colorBuffer[0].channelWriteMask = 15 | ||
colorBuffer[0].blendEnable = 1 | ||
colorBuffer[0].blendSrcAlphaToColor = 1 |
This file contains 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 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
Oops, something went wrong.