diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-08-06 15:52:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-06 15:52:38 -0700 |
| commit | 73ff6907d723003d30e400f661876e7960de574f (patch) | |
| tree | 76fb87e0d7cdf6310c4a62753556dbf061842d7b /tools/gfx/render.h | |
| parent | 68d705f6c805c9b4d31b386e065762e6db13ad18 (diff) | |
Add basic support for "Dear IMGUI" (#625)
This isn't being made visible just yet, but it will allow us to have a simple UI for loading models into the model-viewer example.
In order to support rendering with IMGUI I had to add the following to the `Renderer` layer:
* viewports
* scissor rects
* blend support
These are really only fully implemented for D3D11, but adding them to the other back-ends should be a reasonably small task.
Diffstat (limited to 'tools/gfx/render.h')
| -rw-r--r-- | tools/gfx/render.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/tools/gfx/render.h b/tools/gfx/render.h index b43152b68..f59a5ef9f 100644 --- a/tools/gfx/render.h +++ b/tools/gfx/render.h @@ -155,6 +155,7 @@ enum class Format RGBA_Unorm_UInt8, + R_UInt16, R_UInt32, D_Float32, @@ -647,6 +648,80 @@ struct RasterizerDesc bool antialiasedLineEnable = false; }; +enum class LogicOp +{ + NoOp, +}; + +enum class BlendOp +{ + Add, + Subtract, + ReverseSubtract, + Min, + Max, +}; + +enum class BlendFactor +{ + Zero, + One, + SrcColor, + InvSrcColor, + SrcAlpha, + InvSrcAlpha, + DestAlpha, + InvDestAlpha, + DestColor, + InvDestColor, + SrcAlphaSaturate, + BlendColor, + InvBlendColor, + SecondarySrcColor, + InvSecondarySrcColor, + SecondarySrcAlpha, + InvSecondarySrcAlpha, +}; + +namespace RenderTargetWriteMask +{ + typedef uint8_t Type; + enum + { + EnableNone = 0, + EnableRed = 0x01, + EnableGreen = 0x02, + EnableBlue = 0x04, + EnableAlpha = 0x08, + EnableAll = 0x0F, + }; +}; +typedef RenderTargetWriteMask::Type RenderTargetWriteMaskT; + +struct AspectBlendDesc +{ + BlendFactor srcFactor = BlendFactor::One; + BlendFactor dstFactor = BlendFactor::Zero; + BlendOp op = BlendOp::Add; +}; + +struct TargetBlendDesc +{ + AspectBlendDesc color; + AspectBlendDesc alpha; + + LogicOp logicOp = LogicOp::NoOp; + RenderTargetWriteMaskT writeMask = RenderTargetWriteMask::EnableAll; +}; + +struct BlendDesc +{ + TargetBlendDesc const* targets = nullptr; + UInt targetCount = 0; + + bool alphaToCoverateEnable = false; +}; + struct GraphicsPipelineStateDesc { ShaderProgram* program; @@ -657,6 +732,7 @@ struct GraphicsPipelineStateDesc UInt renderTargetCount; DepthStencilDesc depthStencil; RasterizerDesc rasterizer; + BlendDesc blend; }; struct ComputePipelineStateDesc @@ -670,6 +746,24 @@ class PipelineState : public Slang::RefObject public: }; +struct ScissorRect +{ + Int minX; + Int minY; + Int maxX; + Int maxY; +}; + +struct Viewport +{ + float originX = 0.0f; + float originY = 0.0f; + float extentX = 0.0f; + float extentY = 0.0f; + float minZ = 0.0f; + float maxZ = 1.0f; +}; + class Renderer: public Slang::RefObject { public: @@ -823,6 +917,18 @@ public: virtual void setDepthStencilTarget(ResourceView* depthStencilView) = 0; + virtual void setViewports(UInt count, Viewport const* viewports) = 0; + inline void setViewport(Viewport const& viewport) + { + setViewports(1, &viewport); + } + + virtual void setScissorRects(UInt count, ScissorRect const* rects) = 0; + inline void setScissorRect(ScissorRect const& rect) + { + setScissorRects(1, &rect); + } + virtual void setPipelineState(PipelineType pipelineType, PipelineState* state) = 0; virtual void draw(UInt vertexCount, UInt startVertex = 0) = 0; |
