From c6f6ce12ec522b193b42bcd12d3a2540c7a6ff92 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 28 Jul 2021 12:24:12 -0700 Subject: Experimental DXR1.0 support in gfx. (#1915) * Experimental DXR1.0 support in gfx. - Add `dispatchRays` command. - Add `createRayTracingPipelineState` method to construct a D3D ray tracing state object from a linked slang program and user specified shader table. Limitations/simplifications: no local root signature support, shader table entries contains only shader identifiers and is specified at pipeline creation time, owned by the pipeline state object. * Root object binding for raytracing pipelines. * `maybeSpecializePipeline` implementation for raytracing pipelines. * Add ray-tracing-pipeline example. * Fixes. * Update README.md * Update comments on the lifespan of specialized pipelines Co-authored-by: Yong He Co-authored-by: jsmall-nvidia --- tools/gfx/renderer-shared.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tools/gfx/renderer-shared.h') diff --git a/tools/gfx/renderer-shared.h b/tools/gfx/renderer-shared.h index 1f0a3eaab..31a7566a2 100644 --- a/tools/gfx/renderer-shared.h +++ b/tools/gfx/renderer-shared.h @@ -766,7 +766,7 @@ public: auto bindingRangeIndex = offset.bindingRangeIndex; auto bindingRange = layout->getBindingRange(bindingRangeIndex); - auto objectIndex = bindingRange.subObjectIndex + offset.bindingArrayIndex; + Slang::Index objectIndex = bindingRange.subObjectIndex + offset.bindingArrayIndex; if (objectIndex >= m_userProvidedSpecializationArgs.getCount()) m_userProvidedSpecializationArgs.setCount(objectIndex + 1); if (!m_userProvidedSpecializationArgs[objectIndex]) @@ -816,7 +816,7 @@ public: subObjectIndexInRange++) { ExtendedShaderObjectTypeList typeArgs; - auto objectIndex = bindingRange.subObjectIndex + subObjectIndexInRange; + Slang::Index objectIndex = bindingRange.subObjectIndex + subObjectIndexInRange; auto subObject = m_objects[objectIndex]; if (!subObject) @@ -932,9 +932,19 @@ public: PipelineType type; GraphicsPipelineStateDesc graphics; ComputePipelineStateDesc compute; + RayTracingPipelineStateDesc rayTracing; ShaderProgramBase* getProgram() { - return static_cast(type == PipelineType::Compute ? compute.program : graphics.program); + switch (type) + { + case PipelineType::Compute: + return static_cast(compute.program); + case PipelineType::Graphics: + return static_cast(graphics.program); + case PipelineType::RayTracing: + return static_cast(rayTracing.program); + } + return nullptr; } } desc; @@ -1105,6 +1115,8 @@ public: public: ExtendedShaderObjectTypeList specializationArgs; // Given current pipeline and root shader object binding, generate and bind a specialized pipeline if necessary. + // The newly specialized pipeline is held alive by the pipeline cache so users of `outNewPipeline` do not + // need to maintain its lifespan. Result maybeSpecializePipeline( PipelineStateBase* currentPipeline, ShaderObjectBase* rootObject, -- cgit v1.2.3