Commit 2bb1f39f by steve-lunarg

WIP: HLSL: add ability to pass struct buffers with counters to fns

This modifies function parameter passing to pass the counter buffer associated with a struct buffer to a function as a hidden parameter. Similarly function declarations will have hidden parameters added to accept the associated counter buffers. There is a limitation: if a SB type may or may not have an associated counter, passing it as a function parameter will assume that it does, and the counter will appear in the linkage whether or not there is a counter method used on the object.
parent b29cc30c
// float4 Fn1(ConsumeStructuredBuffer<float4> arg_c)
// {
// return arg_c.Consume();
// }
float4 Fn2(AppendStructuredBuffer<float4> arg_a, ConsumeStructuredBuffer<float4> arg_c)
{
arg_a.Append(float4(1,2,3,4));
return arg_c.Consume();
}
AppendStructuredBuffer<float4> sbuf_a;
ConsumeStructuredBuffer<float4> sbuf_c;
AppendStructuredBuffer<float4> sbuf_unused;
float4 main(uint pos : FOO) : SV_Target0
{
// Fn1(sbuf_c);
return Fn2(sbuf_a, sbuf_c);
}
...@@ -255,6 +255,7 @@ INSTANTIATE_TEST_CASE_P( ...@@ -255,6 +255,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.structarray.flatten.geom", "main"}, {"hlsl.structarray.flatten.geom", "main"},
{"hlsl.structbuffer.frag", "main"}, {"hlsl.structbuffer.frag", "main"},
{"hlsl.structbuffer.append.frag", "main"}, {"hlsl.structbuffer.append.frag", "main"},
{"hlsl.structbuffer.append.fn.frag", "main"},
{"hlsl.structbuffer.atomics.frag", "main"}, {"hlsl.structbuffer.atomics.frag", "main"},
{"hlsl.structbuffer.byte.frag", "main"}, {"hlsl.structbuffer.byte.frag", "main"},
{"hlsl.structbuffer.coherent.frag", "main"}, {"hlsl.structbuffer.coherent.frag", "main"},
......
...@@ -275,6 +275,7 @@ protected: ...@@ -275,6 +275,7 @@ protected:
// Test method names // Test method names
bool isStructBufferMethod(const TString& name) const; bool isStructBufferMethod(const TString& name) const;
void counterBufferType(const TSourceLoc& loc, TType& type);
// Return standard sample position array // Return standard sample position array
TIntermConstantUnion* getSamplePosArray(int count); TIntermConstantUnion* getSamplePosArray(int count);
...@@ -283,6 +284,9 @@ protected: ...@@ -283,6 +284,9 @@ protected:
bool isStructBufferType(const TType& type) const { return getStructBufferContentType(type) != nullptr; } bool isStructBufferType(const TType& type) const { return getStructBufferContentType(type) != nullptr; }
TIntermTyped* indexStructBufferContent(const TSourceLoc& loc, TIntermTyped* buffer) const; TIntermTyped* indexStructBufferContent(const TSourceLoc& loc, TIntermTyped* buffer) const;
TIntermTyped* getStructBufferCounter(const TSourceLoc& loc, TIntermTyped* buffer); TIntermTyped* getStructBufferCounter(const TSourceLoc& loc, TIntermTyped* buffer);
TString getStructBuffCounterName(const TString&) const;
void addStructBuffArguments(const TSourceLoc& loc, TIntermAggregate*&);
void addStructBufferHiddenCounterParam(const TSourceLoc& loc, TParameter&, TIntermAggregate*&);
// Return true if this type is a reference. This is not currently a type method in case that's // Return true if this type is a reference. This is not currently a type method in case that's
// a language specific answer. // a language specific answer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment