diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index a167a4a27f..b0d6c44e0e 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -154,28 +154,28 @@ class RenderTestApp struct AssignValsFromLayoutContext { IDevice* device; - slang::ISession* slangSession; + slang::IComponentType* slangComponent; ShaderOutputPlan& outputPlan; TestResourceContext& resourceContext; - slang::ProgramLayout* slangReflection; IAccelerationStructure* accelerationStructure; AssignValsFromLayoutContext( IDevice* device, - slang::ISession* slangSession, + slang::IComponentType* slangComponent, ShaderOutputPlan& outputPlan, TestResourceContext& resourceContext, - slang::ProgramLayout* slangReflection, IAccelerationStructure* accelerationStructure) : device(device) - , slangSession(slangSession) + , slangComponent(slangComponent) , outputPlan(outputPlan) , resourceContext(resourceContext) - , slangReflection(slangReflection) , accelerationStructure(accelerationStructure) { } + slang::ProgramLayout* slangReflection() { return slangComponent->getLayout(); } + slang::ISession* slangSession() { return slangComponent->getSession(); } + void maybeAddOutput( ShaderCursor const& dstCursor, ShaderInputLayout::Val* srcVal, @@ -389,7 +389,7 @@ struct AssignValsFromLayoutContext // If the input line specified the name of the type // to allocate, then we use it directly. // - slangType = slangReflection->findTypeByName(typeName.getBuffer()); + slangType = slangReflection()->findTypeByName(typeName.getBuffer()); } else { @@ -418,7 +418,7 @@ struct AssignValsFromLayoutContext ComPtr shaderObject; device->createShaderObject( - slangSession, + slangSession(), slangType, ShaderObjectContainerType::None, shaderObject.writeRef()); @@ -437,7 +437,7 @@ struct AssignValsFromLayoutContext List args; for (auto& typeName : srcVal->typeArgs) { - auto slangType = slangReflection->findTypeByName(typeName.getBuffer()); + auto slangType = slangReflection()->findTypeByName(typeName.getBuffer()); if (!slangType) { StdWriters::getError().print( @@ -516,42 +516,30 @@ struct AssignValsFromLayoutContext } }; -SlangResult _assignVarsFromLayout( +static SlangResult _assignVarsFromLayout( IDevice* device, - slang::ISession* slangSession, + slang::IComponentType* slangComponent, IShaderObject* shaderObject, ShaderInputLayout const& layout, ShaderOutputPlan& ioOutputPlan, TestResourceContext& ioResourceContext, - slang::ProgramLayout* slangReflection, IAccelerationStructure* accelerationStructure) { - AssignValsFromLayoutContext context( - device, - slangSession, - ioOutputPlan, - ioResourceContext, - slangReflection, - accelerationStructure); + AssignValsFromLayoutContext + context(device, slangComponent, ioOutputPlan, ioResourceContext, accelerationStructure); ShaderCursor rootCursor = ShaderCursor(shaderObject); return context.assign(rootCursor, layout.rootVal); } Result RenderTestApp::applyBinding(IShaderObject* rootObject) { - auto slangReflection = (slang::ProgramLayout*)spGetReflection( - m_compilationOutput.output.getRequestForReflection()); - ComPtr slangSession; - m_compilationOutput.output.m_requestForKernels->getSession(slangSession.writeRef()); - return _assignVarsFromLayout( m_device, - slangSession, + m_compilationOutput.output.slangProgram, rootObject, m_compilationOutput.layout, m_outputPlan, m_resourceContext, - slangReflection, m_topLevelAccelerationStructure); } @@ -1086,9 +1074,6 @@ Result RenderTestApp::update() m_options.shaderType == Options::ShaderProgramType::GraphicsMeshCompute || m_options.shaderType == Options::ShaderProgramType::GraphicsTaskMeshCompute) { - auto request = m_compilationOutput.output.getRequestForReflection(); - auto slangReflection = (slang::ShaderReflection*)spGetReflection(request); - SLANG_RETURN_ON_FAIL(writeBindingOutput(m_options.outputPath)); } else diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index 368ee03900..22a745d1f7 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -36,16 +36,15 @@ void ShaderCompilerUtil::Output::reset() } session = nullptr; - m_requestForKernels = nullptr; - m_extraRequestForReflection = nullptr; + m_requestDEPRECATED = nullptr; } -/* static */ SlangResult ShaderCompilerUtil::_compileProgramImpl( +static SlangResult _compileProgramImpl( slang::IGlobalSession* globalSession, const Options& options, - const Input& input, + const ShaderCompilerUtil::Input& input, const ShaderCompileRequest& request, - Output& out) + ShaderCompilerUtil::Output& out) { out.reset(); @@ -58,7 +57,7 @@ void ShaderCompilerUtil::Output::reset() SLANG_ALLOW_DEPRECATED_BEGIN globalSession->createCompileRequest(slangRequest.writeRef()); SLANG_ALLOW_DEPRECATED_END - out.m_requestForKernels = slangRequest; + out.m_requestDEPRECATED = slangRequest; out.session = globalSession; bool hasRepro = false; @@ -303,12 +302,12 @@ void ShaderCompilerUtil::Output::reset() return SLANG_OK; } -/* static */ SlangResult ShaderCompilerUtil::compileProgram( +static SlangResult compileProgram( slang::IGlobalSession* globalSession, const Options& options, - const Input& input, + const ShaderCompilerUtil::Input& input, const ShaderCompileRequest& request, - Output& out) + ShaderCompilerUtil::Output& out) { if (input.passThrough == SLANG_PASS_THROUGH_NONE) { @@ -333,7 +332,7 @@ void ShaderCompilerUtil::Output::reset() // compile in another pass using the desired downstream compiler // so that we can get the refleciton information we need. // - Output slangOutput; + ShaderCompilerUtil::Output slangOutput; if (canUseSlangForPrecompile) { ShaderCompilerUtil::Input slangInput = input; @@ -354,17 +353,16 @@ void ShaderCompilerUtil::Output::reset() // SLANG_RETURN_ON_FAIL(_compileProgramImpl(globalSession, options, input, request, out)); - out.m_extraRequestForReflection = slangOutput.getRequestForReflection(); + out.m_requestDEPRECATED = slangOutput.m_requestDEPRECATED; out.desc.slangGlobalScope = slangOutput.desc.slangGlobalScope; - slangOutput.m_requestForKernels = nullptr; + slangOutput.m_requestDEPRECATED = nullptr; return SLANG_OK; } } -/* static */ SlangResult ShaderCompilerUtil::readSource( - const String& inSourcePath, - List& outSourceText) +// Helper for compileWithLayout +/* static */ SlangResult readSource(const String& inSourcePath, List& outSourceText) { // Read in the source code FILE* sourceFile = fopen(inSourcePath.getBuffer(), "rb"); @@ -392,8 +390,8 @@ void ShaderCompilerUtil::Output::reset() /* static */ SlangResult ShaderCompilerUtil::compileWithLayout( slang::IGlobalSession* globalSession, const Options& options, - const ShaderCompilerUtil::Input& input, - OutputAndLayout& output) + const Input& input, + ShaderCompilerUtil::OutputAndLayout& output) { String sourcePath = options.sourcePath; auto shaderType = options.shaderType; @@ -531,12 +529,7 @@ void ShaderCompilerUtil::Output::reset() c.idOverride = conformance.idOverride; compileRequest.typeConformances.add(c); } - return ShaderCompilerUtil::compileProgram( - globalSession, - options, - input, - compileRequest, - output.output); + return compileProgram(globalSession, options, input, compileRequest, output.output); } } // namespace renderer_test diff --git a/tools/render-test/slang-support.h b/tools/render-test/slang-support.h index d5574e9032..e105b6b86c 100644 --- a/tools/render-test/slang-support.h +++ b/tools/render-test/slang-support.h @@ -67,17 +67,7 @@ struct ShaderCompilerUtil ComPtr slangProgram; ShaderProgramDesc desc = {}; - /// Compile request that owns the lifetime of compiled kernel code. - ComPtr m_requestForKernels = nullptr; - - /// Compile request that owns the lifetime of reflection information. - ComPtr m_extraRequestForReflection = nullptr; - - SlangCompileRequest* getRequestForKernels() const { return m_requestForKernels; } - SlangCompileRequest* getRequestForReflection() const - { - return m_extraRequestForReflection ? m_extraRequestForReflection : m_requestForKernels; - } + ComPtr m_requestDEPRECATED = nullptr; SlangSession* session = nullptr; }; @@ -89,28 +79,12 @@ struct ShaderCompilerUtil Slang::String sourcePath; }; + // Wrapper for compileProgram static SlangResult compileWithLayout( slang::IGlobalSession* globalSession, const Options& options, const ShaderCompilerUtil::Input& input, OutputAndLayout& output); - - static SlangResult readSource( - const Slang::String& inSourcePath, - Slang::List& outSourceText); - - static SlangResult _compileProgramImpl( - slang::IGlobalSession* globalSession, - const Options& options, - const Input& input, - const ShaderCompileRequest& request, - Output& out); - static SlangResult compileProgram( - slang::IGlobalSession* globalSession, - const Options& options, - const Input& input, - const ShaderCompileRequest& request, - Output& out); };