Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zd3d12] more helper functions #594

Merged
merged 4 commits into from
May 14, 2024

Conversation

Pyrolistical
Copy link
Contributor

@Pyrolistical Pyrolistical commented May 12, 2024

Added helpers:

  1. fn checkFeatureSupport(gctx: *GraphicsContext, comptime feature: d3d12.FEATURE, data: anytype) HResultError!void
    Purpose: Compile time check to ensure correct data is passed in for feature.
    HResultError instead of HRESULT.
  2. fn allocRenderTargetView(gctx: *GraphicsContext, handle: ResourceHandle, desc: ?*const d3d12.RENDER_TARGET_VIEW_DESC) d3d12.CPU_DESCRIPTOR_HANDLE
    Purpose: Use zd3d12.ResourceHandle instead of d3d12.IResource. Allocate required .RTV cpu descriptor and returns it.
  3. fn allocDepthStencilView(gctx: *GraphicsContext, handle: ResourceHandle, desc: ?*const d3d12.DEPTH_STENCIL_VIEW_DESC) d3d12.CPU_DESCRIPTOR_HANDLE
    Purpose: Use zd3d12.ResourceHandle instead of d3d12.IResource. Allocate required .DSV cpu descriptor and returns it.
  4. fn createRootSignature(gctx: *GraphicsContext, node_mask: w32.UINT, signature: *d3d.IBlob) HResultError!*d3d12.IRootSignature
    Purpose: Take in signature IBlob instead of pointer and size. Return *IRootSignature instead of out pointer. HResultError instead of HRESULT.
  5. fn writeResource(gctx: *GraphicsContext, comptime T: type, destination: ResourceHandle, source: []const T) HResultError!void
    Purpose: Simplify writing a slice to a resource instead of manually mapping and unmapping a byte array.
  6. fn clearRenderTargetView(gctx: *GraphicsContext, rt_view: d3d12.CPU_DESCRIPTOR_HANDLE, rgba: *const [4]w32.FLOAT, rects: []const w32.RECT) void
    Purpose: RECT slice instead of a length and pointer.
  7. fn clearDepthStencilView(gctx: *GraphicsContext, ds_view: d3d12.CPU_DESCRIPTOR_HANDLE, clear_flags: d3d12.CLEAR_FLAGS, depth: w32.FLOAT, stencil: w32.UINT8, rects: []const w32.RECT) void
    Purpose: RECT slice instead of a length and pointer.
  8. fn omSetRenderTargets(gctx: *GraphicsContext, render_target_descriptors: []const d3d12.CPU_DESCRIPTOR_HANDLE, single_handle: bool, ds_descriptors: ?*const d3d12.CPU_DESCRIPTOR_HANDLE) void
    Purpose: CPU_DESCRIPTOR_HANDLE slice instead of a length and pointer. bool instead of BOOL.
  9. fn rsSetViewports(gctx: *GraphicsContext, viewports: []const d3d12.VIEWPORT)
    Purpose: VIEWPORT slice instead of a length and pointer.
  10. fn rsSetScissorRects(gctx: *GraphicsContext, rects: []const d3d12.RECT)
    Purpose: RECT slice instead of a length and pointer.
  11. fn iaSetPrimitiveTopology(gctx: *GraphicsContext, topology: d3d12.PRIMITIVE_TOPOLOGY) void
    Purpose: Passthrough to get rid of last usage of gctx.cmdlist in simple_openvr sample
  12. fn iaSetVertexBuffers(gctx: *GraphicsContext, start_slot: w32.UINT, views: []const d3d12.VERTEX_BUFFER_VIEW)
    Purpose: VERTEX_BUFFER_VIEW slice instead of a length and pointer.
  13. fn iaSetIndexBuffer(gctx: *GraphicsContext, view: ?*const d3d12.INDEX_BUFFER_VIEW) void
    Purpose: Passthrough to get rid of last usage of gctx.cmdlist in simple_openvr sample
  14. fn setGraphicsRootConstantBufferView(gctx: *GraphicsContext, index: w32.UINT, handle: ResourceHandle) void
    Purpose: zd3d12.ResourceHandle instead of d3d12.IResource.
  15. fn drawInstanced(gctx: *GraphicsContext, vertex_count_per_instance: w32.UINT, instance_count: w32.UINT, start_vertex_location: w32.UINT, start_instance_location: w32.UINT) void
    Purpose: Passthrough to get rid of last usage of gctx.cmdlist in simple_openvr sample
  16. fn drawIndexedInstanced(gctx: *GraphicsContext, index_count_per_instance: w32.UINT, instance_count: w32.UINT, start_index_location: w32.UINT, base_vertex_location: w32.INT, start_instance_location: w32.UINT) void
    Purpose: Passthrough to get rid of last usage of gctx.cmdlist in simple_openvr sample
  17. fn serializeVersionedRootSignature(root_signature_desc: *const d3d12.VERSIONED_ROOT_SIGNATURE_DESC) HResultError!*d3d.IBlob
    Purpose: Returns IBlob instead of out pointer. HResultError instead of HRESULT.

[zd3d12] added allocRenderTargetView
[zd3d12] added allocDepthStencilView
[zd3d12] added createRootSignature
[zd3d12] added writeResource
[zd3d12] added omSetRenderTargets
[zd3d12] added rsSetViewports
[zd3d12] added rsSetScissorRects
[zd3d12] added iaSetVertexBuffers
[zd3d12] added setGraphicsRootConstantBufferView
[zd3d12] added serializeVersionedRootSignature
[d3d12] fixed ROOT_SIGNATURE_DESC.NumParamenters typo
[d3d12] fixed ROOT_SIGNATURE_DESC1.NumParamenters typo
[d3d12] added ROOT_SIGNATURE_DESC1.init
[d3d12] added VERSIONED_ROOT_SIGNATURE_DESC.initVersion1_0
[d3d12] added VERSIONED_ROOT_SIGNATURE_DESC.initVersion1_1

refactored simple_openvr to use new helper methods
…iaSetPrimitiveTopology, iaSetIndexBuffer, drawInstanced, drawIndexedInstanced
@hazeycode hazeycode merged commit ab1f888 into zig-gamedev:main May 14, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants