Merge pull request #639 from KhronosGroup/fix-638
Properly track read dependencies for UAV access chain.
This commit is contained in:
commit
be7425ef70
@ -0,0 +1,19 @@
|
|||||||
|
RWByteAddressBuffer _4 : register(u0);
|
||||||
|
|
||||||
|
void comp_main()
|
||||||
|
{
|
||||||
|
uint _21 = _4.Load(_4.Load(0) * 4 + 4);
|
||||||
|
for (uint _23 = 0u; _23 < 64u; )
|
||||||
|
{
|
||||||
|
_4.Store(_23 * 4 + 4, 0u);
|
||||||
|
_23++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_4.Store(_4.Load(0) * 4 + 4, _21);
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
comp_main();
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
RWByteAddressBuffer _4 : register(u0);
|
||||||
|
|
||||||
|
void comp_main()
|
||||||
|
{
|
||||||
|
uint _21 = _4.Load(_4.Load(0) * 4 + 4);
|
||||||
|
for (uint _23 = 0u; _23 < 64u; )
|
||||||
|
{
|
||||||
|
_4.Store(_23 * 4 + 4, 0u);
|
||||||
|
_23++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_4.Store(_4.Load(0) * 4 + 4, _21);
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
comp_main();
|
||||||
|
}
|
61
shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp
Normal file
61
shaders-hlsl/asm/comp/access-chain-invalidate.asm.comp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
; SPIR-V
|
||||||
|
; Version: 1.0
|
||||||
|
; Generator: Google Shaderc over Glslang; 7
|
||||||
|
; Bound: 41
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint GLCompute %main "main"
|
||||||
|
OpExecutionMode %main LocalSize 1 1 1
|
||||||
|
OpSource GLSL 450
|
||||||
|
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
|
||||||
|
OpSourceExtension "GL_GOOGLE_include_directive"
|
||||||
|
OpName %main "main"
|
||||||
|
OpName %SSBO "SSBO"
|
||||||
|
OpMemberName %SSBO 0 "index"
|
||||||
|
OpMemberName %SSBO 1 "array"
|
||||||
|
OpName %_ ""
|
||||||
|
OpDecorate %_arr_uint_uint_64 ArrayStride 4
|
||||||
|
OpMemberDecorate %SSBO 0 Offset 0
|
||||||
|
OpMemberDecorate %SSBO 1 Offset 4
|
||||||
|
OpDecorate %SSBO BufferBlock
|
||||||
|
OpDecorate %_ DescriptorSet 0
|
||||||
|
OpDecorate %_ Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%uint_64 = OpConstant %uint 64
|
||||||
|
%_arr_uint_uint_64 = OpTypeArray %uint %uint_64
|
||||||
|
%SSBO = OpTypeStruct %uint %_arr_uint_uint_64
|
||||||
|
%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO
|
||||||
|
%_ = OpVariable %_ptr_Uniform_SSBO Uniform
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%main = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%18 = OpAccessChain %_ptr_Uniform_uint %_ %int_0
|
||||||
|
%19 = OpLoad %uint %18
|
||||||
|
%20 = OpAccessChain %_ptr_Uniform_uint %_ %int_1 %19
|
||||||
|
%21 = OpLoad %uint %20
|
||||||
|
OpBranch %24
|
||||||
|
%24 = OpLabel
|
||||||
|
%40 = OpPhi %uint %uint_0 %5 %35 %25
|
||||||
|
%31 = OpULessThan %bool %40 %uint_64
|
||||||
|
OpLoopMerge %26 %25 None
|
||||||
|
OpBranchConditional %31 %25 %26
|
||||||
|
%25 = OpLabel
|
||||||
|
%33 = OpAccessChain %_ptr_Uniform_uint %_ %int_1 %40
|
||||||
|
OpStore %33 %uint_0
|
||||||
|
%35 = OpIAdd %uint %40 %int_1
|
||||||
|
OpBranch %24
|
||||||
|
%26 = OpLabel
|
||||||
|
%37 = OpLoad %uint %18
|
||||||
|
%39 = OpAccessChain %_ptr_Uniform_uint %_ %int_1 %37
|
||||||
|
OpStore %39 %21
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
@ -6147,7 +6147,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
|||||||
if (ptr_expression)
|
if (ptr_expression)
|
||||||
ptr_expression->need_transpose = old_need_transpose;
|
ptr_expression->need_transpose = old_need_transpose;
|
||||||
|
|
||||||
// By default, suppress usage tracking since using same expressio multiple times does not imply any extra work.
|
// By default, suppress usage tracking since using same expression multiple times does not imply any extra work.
|
||||||
// However, if we try to load a complex, composite object from a flattened buffer,
|
// However, if we try to load a complex, composite object from a flattened buffer,
|
||||||
// we should avoid emitting the same code over and over and lower the result to a temporary.
|
// we should avoid emitting the same code over and over and lower the result to a temporary.
|
||||||
auto &type = get<SPIRType>(result_type);
|
auto &type = get<SPIRType>(result_type);
|
||||||
|
@ -3519,6 +3519,7 @@ void CompilerHLSL::emit_access_chain(const Instruction &instruction)
|
|||||||
if (need_byte_access_chain)
|
if (need_byte_access_chain)
|
||||||
{
|
{
|
||||||
uint32_t to_plain_buffer_length = static_cast<uint32_t>(type.array.size());
|
uint32_t to_plain_buffer_length = static_cast<uint32_t>(type.array.size());
|
||||||
|
auto *backing_variable = maybe_get_backing_variable(ops[2]);
|
||||||
|
|
||||||
string base;
|
string base;
|
||||||
if (to_plain_buffer_length != 0)
|
if (to_plain_buffer_length != 0)
|
||||||
@ -3557,6 +3558,7 @@ void CompilerHLSL::emit_access_chain(const Instruction &instruction)
|
|||||||
e.row_major_matrix = row_major_matrix;
|
e.row_major_matrix = row_major_matrix;
|
||||||
e.matrix_stride = matrix_stride;
|
e.matrix_stride = matrix_stride;
|
||||||
e.immutable = should_forward(ops[2]);
|
e.immutable = should_forward(ops[2]);
|
||||||
|
e.loaded_from = backing_variable ? backing_variable->self : 0;
|
||||||
|
|
||||||
if (chain)
|
if (chain)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user