71 constexpr uint16_t H0 = 0x0000;
72 constexpr uint16_t H1 = 0x3C00;
74 QuadVertex verts[6] = {
75 { -1.0f, -1.0f, 255, 255, 255, 255, H0, H0 },
76 { 1.0f, -1.0f, 255, 255, 255, 255, H1, H0 },
77 { 1.0f, 1.0f, 255, 255, 255, 255, H1, H1 },
78 { -1.0f, -1.0f, 255, 255, 255, 255, H0, H0 },
79 { 1.0f, 1.0f, 255, 255, 255, 255, H1, H1 },
80 { -1.0f, 1.0f, 255, 255, 255, 255, H0, H1 },
106 singleTexLayoutDesc.
entries.push_back(
147 uint32_t aHeight,
const std::vector<COMPOSITOR_LAYER>& aLayers,
148 const float* aBackgroundColor,
149 const std::function<
void()>& aDrawOnTop )
161 if( aBackgroundColor )
170 bool rpOk =
m_device.BeginRenderPass( beginDesc );
176 viewport.
width =
static_cast<float>( aWidth );
177 viewport.
height =
static_cast<float>( aHeight );
181 scissor.
width = aWidth;
191 for(
const auto& layer : aLayers )
202 return aAccumulationFBO;
208 uint32_t aGroupIndex )
214 wxLogTrace(
traceRhi, wxS(
"Compositor: missing FBO color texture fbo=%u layout=%u" ),
215 static_cast<unsigned>( aFBO.
value ),
216 static_cast<unsigned>( aLayout.
value ) );
220 uint64_t key = (
static_cast<uint64_t
>( tex.
value ) << 32 ) | aLayout.
value;
225 m_device.BindGroup( aGroupIndex, it->second );
231 bgDesc.
entries.push_back( { 0, {}, tex } );
237 wxLogTrace(
traceRhi, wxS(
"Compositor: CreateBindGroup FAILED fbo=%u tex=%u layout=%u" ),
238 static_cast<unsigned>( aFBO.
value ),
239 static_cast<unsigned>( tex.
value ),
240 static_cast<unsigned>( aLayout.
value ) );
245 m_device.BindGroup( aGroupIndex, bg );
265 m_device.SetPushConstants( &pc,
sizeof( pc ) );
RHI_BindGroupHandle bindFBOTexture(RHI_FramebufferHandle aFBO, RHI_BindGroupLayoutHandle aLayout, uint32_t aGroupIndex)
RHI_PipelineHandle m_compositorPipeline
RHI_BindGroupLayoutHandle m_singleTexLayout
void destroyFBOBindGroups()
RHI_COMPOSITOR(RHI_DEVICE &aDevice)
bool m_ownsSingleTexLayout
void SetCompositorPipeline(RHI_PipelineHandle aPipeline)
Set the pipeline that draws each layer as an alpha-blended fullscreen quad.
std::unordered_map< uint64_t, RHI_BindGroupHandle > m_fboBindGroups
Bind groups over FBO color textures, keyed by texture and layout handles.
RHI_BufferHandle m_quadVB
bool Initialize(RHI_BindGroupLayoutHandle aSingleTexLayout={})
Create the clear pass and fullscreen quad.
void Destroy()
Release all GPU resources.
RHI_FramebufferHandle Composite(RHI_FramebufferHandle aAccumulationFBO, uint32_t aWidth, uint32_t aHeight, const std::vector< COMPOSITOR_LAYER > &aLayers, const float *aBackgroundColor=nullptr, const std::function< void()> &aDrawOnTop={})
Blend aLayers back-to-front into aAccumulationFBO, which is cleared to aBackgroundColor first.
void compositeLayer(const COMPOSITOR_LAYER &aLayer)
RHI_RenderPassHandle m_clearRenderPass
Creates, uses and destroys GPU resources through one graphics API backend.
const wxChar *const traceRhi
Flag to enable debug output of the RHI rendering backend.
@ COMBINED_TEXTURE_SAMPLER
RHI_HANDLE< RHI_TAG_FRAMEBUFFER > RHI_FramebufferHandle
RHI_HANDLE< RHI_TAG_TEXTURE > RHI_TextureHandle
RHI_HANDLE< RHI_TAG_PIPELINE > RHI_PipelineHandle
RHI_HANDLE< RHI_TAG_BIND_GROUP > RHI_BindGroupHandle
RHI_HANDLE< RHI_TAG_BIND_GROUP_LAYOUT > RHI_BindGroupLayoutHandle
RHI_FramebufferHandle fbo
Matches the PushConstants block of the compositor shader.
std::vector< RHI_BIND_GROUP_RESOURCE > entries
RHI_BindGroupLayoutHandle layout
std::vector< RHI_BINDING_ENTRY > entries
RHI_BIND_FREQUENCY frequency
RHI_TEXTURE_FORMAT format
RHI_FramebufferHandle framebuffer
bool hasClearColorOverride
Replaces the render pass clear color of every CLEAR color attachment, so the background can change pe...
RHI_RenderPassHandle renderPass
float clearColorOverride[4]
std::vector< RHI_COLOR_ATTACHMENT_DESC > colorAttachments
Same pixel space as RHI_VIEWPORT.
Top-left origin, in device pixels.
wxLogTrace helper definitions.