Commit 13dcbece by Ben Clayton

src/Pipeline: Refactor ComputeProgram

• Split up ComputeProgram::emit() into a few smaller functions. • Calculate the subgroup count in C++, and pass it in as a parameter. • Add a firstSubgroup, this is currently always 0, but will be used in a later change. • Pass the workgroup ID as parameters instead of through Data. Data now holds fields common for all workgroups. This refactoring prepares the code for migrating to coroutines. Bug: b/131672705 Change-Id: Id3492adc0a7aedc3f16c0e37f135294862c55700 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30848Tested-by: 's avatarBen Clayton <bclayton@google.com> Presubmit-Ready: Ben Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 1c82c7b8
...@@ -37,7 +37,13 @@ namespace sw ...@@ -37,7 +37,13 @@ namespace sw
struct Constants; struct Constants;
// ComputeProgram builds a SPIR-V compute shader. // ComputeProgram builds a SPIR-V compute shader.
class ComputeProgram : public Function<Void(Pointer<Byte>)> class ComputeProgram : public Function<Void(
Pointer<Byte> data,
Int workgroupX,
Int workgroupY,
Int workgroupZ,
Int firstSubgroup,
Int subgroupCount)>
{ {
public: public:
ComputeProgram(SpirvShader const *spirvShader, vk::PipelineLayout const *pipelineLayout, const vk::DescriptorSet::Bindings &descriptorSets); ComputeProgram(SpirvShader const *spirvShader, vk::PipelineLayout const *pipelineLayout, const vk::DescriptorSet::Bindings &descriptorSets);
...@@ -59,6 +65,8 @@ namespace sw ...@@ -59,6 +65,8 @@ namespace sw
protected: protected:
void emit(); void emit();
void setWorkgroupBuiltins(Int workgroupID[3]);
void setSubgroupBuiltins(Int workgroupID[3], SIMD::Int localInvocationIndex, Int subgroupIndex);
void setInputBuiltin(spv::BuiltIn id, std::function<void(const SpirvShader::BuiltinMapping& builtin, Array<SIMD::Float>& value)> cb); void setInputBuiltin(spv::BuiltIn id, std::function<void(const SpirvShader::BuiltinMapping& builtin, Array<SIMD::Float>& value)> cb);
Pointer<Byte> data; // argument 0 Pointer<Byte> data; // argument 0
...@@ -67,8 +75,11 @@ namespace sw ...@@ -67,8 +75,11 @@ namespace sw
{ {
vk::DescriptorSet::Bindings descriptorSets; vk::DescriptorSet::Bindings descriptorSets;
vk::DescriptorSet::DynamicOffsets descriptorDynamicOffsets; vk::DescriptorSet::DynamicOffsets descriptorDynamicOffsets;
uint4 numWorkgroups; uint4 numWorkgroups; // [x, y, z, 0]
uint4 workgroupID; uint4 workgroupSize; // [x, y, z, 0]
uint32_t invocationsPerSubgroup; // SPIR-V: "SubgroupSize"
uint32_t subgroupsPerWorkgroup; // SPIR-V: "NumSubgroups"
uint32_t invocationsPerWorkgroup; // Total number of invocations per workgroup.
PushConstantStorage pushConstants; PushConstantStorage pushConstants;
const Constants *constants; const Constants *constants;
uint8_t* workgroupMemory; uint8_t* workgroupMemory;
......
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