Repository navigation
Vulkan: occlusion queries, dynamic blend constants/stencil reference, root descriptors, render pass and framebuffer fixes - #136
Closed
itar3 wants to merge 6 commits into
Conversation
Adds R8, R8G8 and R8G8B8A8 USCALED/SSCALED, R16, R16G16 and R16G16B16A16 USCALED/SSCALED, and A2B10G10R10 UNORM/SNORM packed formats, with their Vulkan mappings and size tables. USCALED/SSCALED read unnormalized integers as floats, which vertex data from consoles often needs. Vulkan only: D3D12 has no scaled formats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Root descriptors (RenderPipelineLayoutDesc::rootDescriptorDescs) asserted on Vulkan. Each register space becomes a push descriptor set at the set index equal to the space, after the layout's descriptor sets (empty set layouts fill any gap); setGraphicsRootDescriptor pushes the buffer. Constant buffers map to uniform buffers, SRVs and UAVs to storage buffers. Needs VK_KHR_push_descriptor (now an optional extension). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds RenderCommandList::setBlendConstants and setStencilReference, and RenderGraphicsPipelineDesc::dynamicBlendConstantsEnabled and dynamicStencilReferenceEnabled (both off by default, so existing pipelines behave as before). Vulkan: the flags enable VK_DYNAMIC_STATE_BLEND_CONSTANTS and VK_DYNAMIC_STATE_STENCIL_REFERENCE. D3D12: OMSetBlendFactor and OMSetStencilRef; binding a pipeline with a dynamic stencil reference no longer overwrites it. Metal: setBlendColor and setStencilReferenceValue through the dirty state. Without them, a renderer whose stencil reference or blend constant changes per draw needs a pipeline per value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A framebuffer whose attachment is a view of mip level N took the base level's size as its size and render area, larger than the attachment: on MoltenVK draws then wrote outside it (GPU page faults). The size is now the view's mip level size, for colour and depth-only framebuffers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds RenderDevice::createOcclusionQueryPool, RenderCommandList::beginQuery and endQuery, and RenderQueryPool::getRawResults (results without waiting, false while any is unavailable). Other backends return no pool for now. Queries are precise (sample counts) when the device supports it; MoltenVK otherwise uses Metal's boolean visibility mode. A query begun inside a render pass instance stays in it instead of ending the pass (a store and reload of every attachment on tile GPUs) and ends with the pass at the latest, as Vulkan requires; queriesEndRenderPass restores begin/end outside passes. resetQueryPool now ends the active pass (vkCmdResetQueryPool is not allowed inside one). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setFramebuffer ended the active render pass every time, so rebinding the active framebuffer, or binding one that got no draws before switching back, ended and restarted the pass: a store and reload of every attachment on tile GPUs (MoltenVK, mobile). Now a draw or clear ends the pass only when it needs another framebuffer. setFramebuffer(nullptr) still ends it, and dispatch, traceRays and acceleration structure builds end it themselves (they relied on setFramebuffer ending it before; resolves already do). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Please read the contribution guide. AI-generated contributions are not accepted. https://github.com/renderbag/plume/blob/main/CONTRIBUTING.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Six self-contained changes from porting Fable II to macOS on plume's Vulkan backend (through MoltenVK, Apple Silicon). Each commit stands on its own and builds on its own, so they can be taken one at a time; I can split this into separate pull requests if you prefer.
RenderCommandList::setBlendConstants/setStencilReferencewithRenderGraphicsPipelineDesc::dynamicBlendConstantsEnabled/dynamicStencilReferenceEnabled, off by default, so existing pipelines behave as before. Implemented for Vulkan, D3D12 (OMSetBlendFactor/OMSetStencilRef; a pipeline with a dynamic reference no longer gets the static one from fix: apply the pipeline stencil reference on d3d12 #122 applied on draw) and Metal (through the dirty state;GraphicsStateFlags::setAllmask updated for the new bit). Without it, a stencil reference that changes per draw needs a pipeline per value.RenderDevice::createOcclusionQueryPool,RenderCommandList::beginQuery/endQuery,RenderQueryPool::getRawResults(no wait; false while any result is unavailable). Other backends return no pool for now. Queries are precise when the device supports it. A query begun inside a render pass stays in it instead of ending the pass, and ends with the pass at the latest, as Vulkan requires (queriesEndRenderPassrestores the old behaviour).resetQueryPoolnow ends the active pass, sincevkCmdResetQueryPoolis not allowed inside one.setFramebufferended the active pass every time, so rebinding the same framebuffer (or one that got no draws before switching back) cost a store and reload of every attachment on tile GPUs. Now a draw or clear ends the pass only when it needs another framebuffer.setFramebuffer(nullptr)still ends it, and dispatch, traceRays and acceleration structure builds now end it themselves (resolves already do since vulkan: End active render pass before resolve #133).Testing. Every commit builds with the Vulkan and Metal backends on macOS. I also ran the game on this branch (plus the two commits from zolaware/plume, a fork of this repository, that the game needs: the R11G11B10_FLOAT format and a Vulkan pipeline cache, and the renderer's own plume patch) on MoltenVK: three saves in automated runs, no errors in the logs, frame times the same as on the fork, where these changes are in daily use (also proposed there: zolaware#2). The Metal part of commit 3 is compiled but not run, and the D3D12 part is not compiled (no Windows machine here); it is a few lines, but please check it.
These are used by Fable2RecompMac.
🤖 Generated with Claude Code