Repository navigation
fix the shaders, the initial matrix, the column-major draw uniforms and the runtime issues - #2
Open
igagis-bot wants to merge 7 commits into
Open
igagis-bot wants to merge 7 commits into
igagis-bot wants to merge 7 commits into
Conversation
shaders - declare the per-draw uniforms as a cbuffer (float4x4 draw_matrix + float4 draw_color) and use mul() for the matrix multiply (the old RootConstants style no longer compiles with the current SDK) - declare SV_POSITION as the first (unused) fragment-shader input so its hardware register matches the vertex shader's, which outputs SV_POSITION at register 0 and any arbitrary semantic at register 1 (otherwise pipeline creation fails with mismatched hardware registers) - compile to vs_5_1/ps_5_1 and use a shared compile_hlsl_blob() helper so the pipeline can keep the blob alive for its lifetime - fix the vertex input layout: a1 attribute semantic is shader-specific (COLOR for pos_clr, TEXCOORD otherwise) and the a1 buffer is read from offset 0 of the second vertex buffer (the buffers are bound per-slot, so the stride is not a byte offset into a single buffer) - bind every vertex buffer of the vertex array (not just the first one), which rendered only the right half of textured geometry - use D3D12_CULL_MODE_BACK (never NONE) - create the pipeline with the real RTV/DSV formats and pass them in the pipeline key so the cache does not confuse pipelines for different formats initial matrix - scale(1, -1, 1) -> translate(-1, -1) -> scale(2, 2): the framework's normalized viewport (x right, y down, (0, 0) top-left) now maps to the DirectX NDC instead of coming out flipped vertically column-major draw uniforms - the renderer's per-draw matrix is stored row-major (r4), so transpose it before writing it into the HLSL cbuffer (float4x4 is column-major by default); everything currently drawn was mirrored
igagis
reviewed
Nov 28, 2026
| // compile the shaders to DXIL (the blobs are kept alive in shader_blobs) | ||
| auto* vs_blob = this->compile_shader(vertex_hlsl, "main", "vs_6_0"); | ||
| auto* fs_blob = this->compile_shader(fragment_hlsl, "main", "ps_6_0"); | ||
| auto* vs_blob = this->compile_shader(vertex_hlsl, "main", "vs_5_1"); |
Member
There was a problem hiding this comment.
make a comment here that vs_5_1 is chosen because not all drivers support 6_0?
- use D3D12_MEMORY_POOL_UNKNOWN for non-custom heaps (the D3D12 debug layer reports D3D12_MEMORY_POOL_L0 as invalid for them) - use D3D_ROOT_SIGNATURE_VERSION_1_0: the SDK 10.0.26100.0 serializer rejects version 1_1; include the shader compiler error blob in the root signature serialization error message - skip the Reset() call on a freshly created command allocator and command list: some runtimes reject Reset() on them until the first work has completed - do not create GPU resources for empty vertex/index buffers and skip the index buffer draw path for them - format the HRESULT in check_hresult() as a hex number - use a local D3D12_MAX_LOD constant (removed from the new SDK) - use GENERIC_READ for the buffer upload resources and INDEX_BUFFER for the index buffer resource - use a READBACK heap for the GPU-visible readback buffer - use the D3D12 queue to signal the frame and upload fences - use the swapchain's current back buffer index and pass the swapchain queue (not the device) to CreateSwapChainForHwnd - use a BORDER sampler address mode, MaxAnisotropy 0 and MaxLOD D3D12_FLOAT32_MAX - use PIXEL_SHADER_RESOURCE for the texture barrier (no combined RENDER_TARGET | PIXEL_SHADER_RESOURCE state)
The DirectX renderer is Windows-only and ships no Debian package; debian/ holds only a placeholder changelog (and a README explaining why) so that the ci's myci-deb-version scripts can extract the version from debian/changelog and apply it to the packages.
…ard + runtime check)
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes for the DirectX 12 renderer that make the test app (
ruisapp-directx-test) build, launch and render:Shaders, vertex input, initial matrix, per-draw matrix upload
cbuffer(float4x4 draw_matrix+float4 draw_color) and multiplied withmul()(the oldRootConstantsstyle no longer compiles with the current SDK). Fragment shaders declareSV_POSITIONas their first (unused) input so it matches the vertex shader's hardware-register layout (otherwiseCreateGraphicsPipelineStatefails with mismatched hardware registers). Compilation targetsvs_5_1/ps_5_1via a sharedcompile_hlsl_blob()helper that the pipeline keeps alive.a1attribute's semantic is shader-specific (COLORforpos_clr,TEXCOORDotherwise) and its buffer is read from offset 0 of the second vertex buffer; every buffer of the vertex array is bound (not just the first), which rendered only the right half of textured geometry otherwise. Culling isBACK(neverNONE), and the pipeline is created with the real RTV/DSV formats (tracked in the pipeline key) instead ofUNKNOWN.scale(1, -1, 1) -> translate(-1, -1) -> scale(2, 2), so the framework's normalized viewport (y down, origin top-left) maps to the DirectX NDC (was flipped vertically).float4x4cbuffer (r4 stores row-major).Runtime fixes (needed to actually launch the app)
D3D12_MEMORY_POOL_UNKNOWNfor non-custom heaps (the D3D12 debug layer reportsD3D12_MEMORY_POOL_L0as invalid).D3D_ROOT_SIGNATURE_VERSION_1_0: the SDK 10.0.26100.0 serializer rejects version 1_1; the error blob is now included in the serialization error message.Reset()on a freshly created command allocator/list is skipped (some runtimes reject it until the first work has completed) —frame_first_begin/upload_first_shotguards.check_hresult()prints the HRESULT as hex;D3D12_MAX_LOD(removed from the new SDK) is defined locally (2048.0f).GENERIC_READ; the index buffer usesINDEX_BUFFER; the GPU readback buffer uses a READBACK heap.GetCurrentBackBufferIndex()instead of a manual increment.BORDERaddress mode,MaxAnisotropy = 0,MaxLOD = D3D12_FLOAT32_MAX.PIXEL_SHADER_RESOURCE(no combinedRENDER_TARGET | PIXEL_SHADER_RESOURCEstate).Notes
gui::renderlogs) fromout/dbg.