diff options
| author | Yong He <yonghe@outlook.com> | 2022-02-20 14:37:41 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-20 14:37:41 -0800 |
| commit | c4790309ec46ae2f4f7c49eb50699a950ee7a9a4 (patch) | |
| tree | e89f2a4a0a8a3fee16ebde5ce5b05ceb1d473398 /tools/gfx/renderer-shared.h | |
| parent | e272aec6a9ddb8b0af82f72c061f5393f2b2bdab (diff) | |
gfx: defer downstream shader compilation until draw/dispatch. (#2139)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/renderer-shared.h')
| -rw-r--r-- | tools/gfx/renderer-shared.h | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/tools/gfx/renderer-shared.h b/tools/gfx/renderer-shared.h index 8136d6735..a78113552 100644 --- a/tools/gfx/renderer-shared.h +++ b/tools/gfx/renderer-shared.h @@ -902,6 +902,72 @@ enum class PipelineType CountOf, }; +struct OwnedHitGroupDesc +{ + Slang::String hitGroupName; + Slang::String closestHitEntryPoint; + Slang::String anyHitEntryPoint; + Slang::String intersectionEntryPoint; + + void set(const HitGroupDesc& desc) + { + hitGroupName = desc.hitGroupName; + closestHitEntryPoint = desc.closestHitEntryPoint; + anyHitEntryPoint = desc.anyHitEntryPoint; + intersectionEntryPoint = desc.intersectionEntryPoint; + } + + HitGroupDesc get() + { + HitGroupDesc desc; + desc.hitGroupName = hitGroupName.getBuffer(); + desc.closestHitEntryPoint = closestHitEntryPoint.getBuffer(); + desc.anyHitEntryPoint = anyHitEntryPoint.getBuffer(); + desc.intersectionEntryPoint = intersectionEntryPoint.getBuffer(); + return desc; + } +}; + +struct OwnedRayTracingPipelineStateDesc +{ + Slang::RefPtr<ShaderProgramBase> program; + Slang::List<OwnedHitGroupDesc> hitGroups; + Slang::List<HitGroupDesc> hitGroupDescs; + int maxRecursion = 0; + int maxRayPayloadSize = 0; + int maxAttributeSizeInBytes = 8; + RayTracingPipelineFlags::Enum flags = RayTracingPipelineFlags::None; + + RayTracingPipelineStateDesc get() + { + RayTracingPipelineStateDesc desc; + desc.program = program.Ptr(); + desc.hitGroupCount = (int32_t)hitGroupDescs.getCount(); + desc.hitGroups = hitGroupDescs.getBuffer(); + desc.maxRecursion = maxRecursion; + desc.maxRayPayloadSize = maxRayPayloadSize; + desc.maxAttributeSizeInBytes = maxAttributeSizeInBytes; + desc.flags = flags; + return desc; + } + + void set(const RayTracingPipelineStateDesc& inDesc) + { + program = static_cast<ShaderProgramBase*>(inDesc.program); + for (int32_t i = 0; i < inDesc.hitGroupCount; i++) + { + OwnedHitGroupDesc ownedHitGroupDesc; + ownedHitGroupDesc.set(inDesc.hitGroups[i]); + hitGroups.add(ownedHitGroupDesc); + hitGroupDescs.add(ownedHitGroupDesc.get()); + } + maxRecursion = inDesc.maxRecursion; + maxRayPayloadSize = inDesc.maxRayPayloadSize; + maxAttributeSizeInBytes = inDesc.maxAttributeSizeInBytes; + flags = inDesc.flags; + } +}; + class PipelineStateBase : public IPipelineState , public Slang::ComObject @@ -915,7 +981,7 @@ public: PipelineType type; GraphicsPipelineStateDesc graphics; ComputePipelineStateDesc compute; - RayTracingPipelineStateDesc rayTracing; + OwnedRayTracingPipelineStateDesc rayTracing; ShaderProgramBase* getProgram() { switch (type) @@ -950,6 +1016,7 @@ public: } virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override; + virtual Result ensureAPIPipelineStateCreated() { return SLANG_OK; }; protected: void initializeBase(const PipelineStateDesc& inDesc); @@ -1439,5 +1506,4 @@ Result ShaderObjectBaseImpl<TShaderObjectImpl, TShaderObjectLayoutImpl, TShaderO } return SLANG_OK; } - } |
