diff options
| author | Yong He <yonghe@outlook.com> | 2021-04-05 13:31:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-05 13:31:05 -0700 |
| commit | 086ecf41fa21138899960bb9805bc8ced91690f0 (patch) | |
| tree | c98af81ffc28371a9334e71987a85f9e88bce678 /tools/gfx/immediate-renderer-base.h | |
| parent | dd662f5cda97e7a6720ef526509a772a06112d4a (diff) | |
Transient root shader object. (#1782)
Diffstat (limited to 'tools/gfx/immediate-renderer-base.h')
| -rw-r--r-- | tools/gfx/immediate-renderer-base.h | 165 |
1 files changed, 146 insertions, 19 deletions
diff --git a/tools/gfx/immediate-renderer-base.h b/tools/gfx/immediate-renderer-base.h index 296cd15cb..5f1770be0 100644 --- a/tools/gfx/immediate-renderer-base.h +++ b/tools/gfx/immediate-renderer-base.h @@ -24,37 +24,35 @@ private: public: // Immediate commands to be implemented by each target. - virtual SLANG_NO_THROW void SLANG_MCALL setPipelineState(IPipelineState* state) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL setFramebuffer(IFramebuffer* frameBuffer) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL clearFrame(uint32_t colorBufferMask, bool clearDepth, bool clearStencil) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL setViewports(UInt count, const Viewport* viewports) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL - setScissorRects(UInt count, const ScissorRect* scissors) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL setPrimitiveTopology(PrimitiveTopology topology) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL setVertexBuffers( + virtual Result createRootShaderObject(IShaderProgram* program, IShaderObject** outObject) = 0; + virtual void bindRootShaderObject(IShaderObject* rootObject) = 0; + virtual void setPipelineState(IPipelineState* state) = 0; + virtual void setFramebuffer(IFramebuffer* frameBuffer) = 0; + virtual void clearFrame(uint32_t colorBufferMask, bool clearDepth, bool clearStencil) = 0; + virtual void setViewports(UInt count, const Viewport* viewports) = 0; + virtual void setScissorRects(UInt count, const ScissorRect* scissors) = 0; + virtual void setPrimitiveTopology(PrimitiveTopology topology) = 0; + virtual void setVertexBuffers( UInt startSlot, UInt slotCount, IBufferResource* const* buffers, const UInt* strides, const UInt* offsets) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL - setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset = 0) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL draw(UInt vertexCount, UInt startVertex = 0) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL - drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL setStencilReference(uint32_t referenceValue) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL dispatchCompute(int x, int y, int z) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL copyBuffer( + virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset = 0) = 0; + virtual void draw(UInt vertexCount, UInt startVertex = 0) = 0; + virtual void drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) = 0; + virtual void setStencilReference(uint32_t referenceValue) = 0; + virtual void dispatchCompute(int x, int y, int z) = 0; + virtual void copyBuffer( IBufferResource* dst, size_t dstOffset, IBufferResource* src, size_t srcOffset, size_t size) = 0; - virtual SLANG_NO_THROW void SLANG_MCALL submitGpuWork() = 0; - virtual SLANG_NO_THROW void SLANG_MCALL waitForGpu() = 0; + virtual void submitGpuWork() = 0; + virtual void waitForGpu() = 0; virtual void* map(IBufferResource* buffer, MapFlavor flavor) = 0; virtual void unmap(IBufferResource* buffer) = 0; - virtual void bindRootShaderObject(PipelineType pipelineType, IShaderObject* shaderObject) = 0; public: Slang::ComPtr<ICommandQueue> m_queue; @@ -82,4 +80,133 @@ public: size_t size, ISlangBlob** outBlob) override; }; + +class ImmediateComputeDeviceBase : public ImmediateRendererBase +{ +public: + // Provide empty implementation for devices without graphics support. + virtual void setFramebuffer(IFramebuffer* frameBuffer) override { SLANG_UNUSED(frameBuffer); } + virtual void clearFrame(uint32_t colorBufferMask, bool clearDepth, bool clearStencil) override + { + SLANG_UNUSED(colorBufferMask); + SLANG_UNUSED(clearDepth); + SLANG_UNUSED(clearStencil); + } + virtual void setViewports(UInt count, const Viewport* viewports) override + { + SLANG_UNUSED(count); + SLANG_UNUSED(viewports); + } + virtual void setScissorRects(UInt count, const ScissorRect* scissors) override + { + SLANG_UNUSED(count); + SLANG_UNUSED(scissors); + } + virtual void setPrimitiveTopology(PrimitiveTopology topology) override + { + SLANG_UNUSED(topology); + } + virtual void setVertexBuffers( + UInt startSlot, + UInt slotCount, + IBufferResource* const* buffers, + const UInt* strides, + const UInt* offsets) override + { + SLANG_UNUSED(startSlot); + SLANG_UNUSED(slotCount); + SLANG_UNUSED(buffers); + SLANG_UNUSED(strides); + SLANG_UNUSED(offsets); + } + virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, UInt offset = 0) + override + { + SLANG_UNUSED(buffer); + SLANG_UNUSED(indexFormat); + SLANG_UNUSED(offset); + } + virtual void draw(UInt vertexCount, UInt startVertex = 0) override + { + SLANG_UNUSED(vertexCount); + SLANG_UNUSED(startVertex); + } + virtual void drawIndexed(UInt indexCount, UInt startIndex = 0, UInt baseVertex = 0) override + { + SLANG_UNUSED(indexCount); + SLANG_UNUSED(startIndex); + SLANG_UNUSED(baseVertex); + } + virtual void setStencilReference(uint32_t referenceValue) override + { + SLANG_UNUSED(referenceValue); + } + + virtual SLANG_NO_THROW Result SLANG_MCALL createSwapchain( + const ISwapchain::Desc& desc, + WindowHandle window, + ISwapchain** outSwapchain) override + { + SLANG_UNUSED(desc); + SLANG_UNUSED(window); + SLANG_UNUSED(outSwapchain); + return SLANG_FAIL; + } + virtual SLANG_NO_THROW Result SLANG_MCALL createFramebufferLayout( + const IFramebufferLayout::Desc& desc, + IFramebufferLayout** outLayout) override + { + SLANG_UNUSED(desc); + SLANG_UNUSED(outLayout); + return SLANG_FAIL; + } + virtual SLANG_NO_THROW Result SLANG_MCALL + createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) override + { + SLANG_UNUSED(desc); + SLANG_UNUSED(outFramebuffer); + return SLANG_FAIL; + } + virtual SLANG_NO_THROW Result SLANG_MCALL createRenderPassLayout( + const IRenderPassLayout::Desc& desc, + IRenderPassLayout** outRenderPassLayout) override + { + SLANG_UNUSED(desc); + SLANG_UNUSED(outRenderPassLayout); + return SLANG_FAIL; + } + + virtual SLANG_NO_THROW Result SLANG_MCALL createInputLayout( + const InputElementDesc* inputElements, + UInt inputElementCount, + IInputLayout** outLayout) override + { + SLANG_UNUSED(inputElements); + SLANG_UNUSED(inputElementCount); + SLANG_UNUSED(outLayout); + return SLANG_E_NOT_AVAILABLE; + } + virtual SLANG_NO_THROW Result SLANG_MCALL createGraphicsPipelineState( + const GraphicsPipelineStateDesc& desc, + IPipelineState** outState) override + { + SLANG_UNUSED(desc); + SLANG_UNUSED(outState); + return SLANG_E_NOT_AVAILABLE; + } + virtual SLANG_NO_THROW SlangResult SLANG_MCALL readTextureResource( + ITextureResource* texture, + ResourceState state, + ISlangBlob** outBlob, + size_t* outRowPitch, + size_t* outPixelSize) override + { + SLANG_UNUSED(texture); + SLANG_UNUSED(outBlob); + SLANG_UNUSED(outRowPitch); + SLANG_UNUSED(outPixelSize); + + return SLANG_E_NOT_AVAILABLE; + } +}; } |
