GeometryShader::GeometryShader(const CompiledShaderByteCode& compiledShader, const StreamOutputInitializers& soInitializers) { if (compiledShader.GetStage() != ShaderStage::Null) { assert(compiledShader.GetStage() == ShaderStage::Geometry); auto byteCode = compiledShader.GetByteCode(); intrusive_ptr<ID3D::GeometryShader> underlying; if (soInitializers._outputBufferCount == 0) { underlying = ObjectFactory().CreateGeometryShader(byteCode.first, byteCode.second); } else { assert(soInitializers._outputBufferCount <= D3D11_SO_BUFFER_SLOT_COUNT); D3D11_SO_DECLARATION_ENTRY nativeDeclaration[D3D11_SO_STREAM_COUNT * D3D11_SO_OUTPUT_COMPONENT_COUNT]; auto delcCount = BuildNativeDeclaration(nativeDeclaration, dimof(nativeDeclaration), soInitializers); ObjectFactory objFactory; auto featureLevel = objFactory.GetUnderlying()->GetFeatureLevel(); underlying = objFactory.CreateGeometryShaderWithStreamOutput( byteCode.first, byteCode.second, nativeDeclaration, delcCount, soInitializers._outputBufferStrides, soInitializers._outputBufferCount, // Note -- "NO_RASTERIZED_STREAM" is only supported on feature level 11. For other feature levels // we must disable the rasterization step some other way (featureLevel>=D3D_FEATURE_LEVEL_11_0)?D3D11_SO_NO_RASTERIZED_STREAM:0); } _underlying = std::move(underlying); } }
GeometryShader::GeometryShader( const ResChar initializer[], const StreamOutputInitializers& soInitializers) { // // We have to append the shader model to the resource name // (if it's not already there) // ResChar temp[MaxPath]; if (!XlFindStringI(initializer, "gs_")) { StringMeldInPlace(temp) << initializer << ":" GS_DefShaderModel; initializer = temp; } intrusive_ptr<ID3D::GeometryShader> underlying; if (soInitializers._outputBufferCount == 0) { const auto& compiledShader = ::Assets::GetAssetComp<CompiledShaderByteCode>(initializer); assert(compiledShader.GetStage() == ShaderStage::Geometry); auto byteCode = compiledShader.GetByteCode(); underlying = ObjectFactory().CreateGeometryShader(byteCode.first, byteCode.second); } else { assert(soInitializers._outputBufferCount < D3D11_SO_BUFFER_SLOT_COUNT); D3D11_SO_DECLARATION_ENTRY nativeDeclaration[D3D11_SO_STREAM_COUNT * D3D11_SO_OUTPUT_COMPONENT_COUNT]; auto delcCount = BuildNativeDeclaration(nativeDeclaration, dimof(nativeDeclaration), soInitializers); ObjectFactory objFactory; auto featureLevel = objFactory.GetUnderlying()->GetFeatureLevel(); const auto& compiledShader = ::Assets::GetAssetComp<CompiledShaderByteCode>(initializer); assert(compiledShader.GetStage() == ShaderStage::Geometry); auto byteCode = compiledShader.GetByteCode(); underlying = objFactory.CreateGeometryShaderWithStreamOutput( byteCode.first, byteCode.second, nativeDeclaration, delcCount, soInitializers._outputBufferStrides, soInitializers._outputBufferCount, // Note -- "NO_RASTERIZED_STREAM" is only supported on feature level 11. For other feature levels // we must disable the rasterization step some other way (featureLevel>=D3D_FEATURE_LEVEL_11_0)?D3D11_SO_NO_RASTERIZED_STREAM:0); } // (creation successful; we can commit to member now) _underlying = std::move(underlying); }