// Generated by generate_d3d12_hooks.py from the public SDK. Do not edit. using Fn_Close = HRESULT(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self); static Fn_Close original_Close = nullptr; static HRESULT STDMETHODCALLTYPE hook_Close(ID3D12GraphicsCommandList* self); using Fn_Reset = HRESULT(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12CommandAllocator *allocator, ID3D12PipelineState *initial_state); static Fn_Reset original_Reset = nullptr; static HRESULT STDMETHODCALLTYPE hook_Reset(ID3D12GraphicsCommandList* self, ID3D12CommandAllocator *allocator, ID3D12PipelineState *initial_state); using Fn_ClearState = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12PipelineState *pipeline_state); static Fn_ClearState original_ClearState = nullptr; static void STDMETHODCALLTYPE hook_ClearState(ID3D12GraphicsCommandList* self, ID3D12PipelineState *pipeline_state); using Fn_DrawInstanced = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location, UINT start_instance_location); static Fn_DrawInstanced original_DrawInstanced = nullptr; static void STDMETHODCALLTYPE hook_DrawInstanced(ID3D12GraphicsCommandList* self, UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location, UINT start_instance_location) { Access access(self); return original_DrawInstanced(access.target(), vertex_count_per_instance, instance_count, start_vertex_location, start_instance_location); } using Fn_DrawIndexedInstanced = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT index_count_per_instance, UINT instance_count, UINT start_vertex_location, INT base_vertex_location, UINT start_instance_location); static Fn_DrawIndexedInstanced original_DrawIndexedInstanced = nullptr; static void STDMETHODCALLTYPE hook_DrawIndexedInstanced(ID3D12GraphicsCommandList* self, UINT index_count_per_instance, UINT instance_count, UINT start_vertex_location, INT base_vertex_location, UINT start_instance_location) { Access access(self); return original_DrawIndexedInstanced(access.target(), index_count_per_instance, instance_count, start_vertex_location, base_vertex_location, start_instance_location); } using Fn_Dispatch = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT x, UINT u, UINT z); static Fn_Dispatch original_Dispatch = nullptr; static void STDMETHODCALLTYPE hook_Dispatch(ID3D12GraphicsCommandList* self, UINT x, UINT u, UINT z) { Access access(self); return original_Dispatch(access.target(), x, u, z); } using Fn_CopyBufferRegion = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT64 byte_count); static Fn_CopyBufferRegion original_CopyBufferRegion = nullptr; static void STDMETHODCALLTYPE hook_CopyBufferRegion(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT64 byte_count) { Access access(self); return original_CopyBufferRegion(access.target(), dst_buffer, dst_offset, src_buffer, src_offset, byte_count); } using Fn_CopyTextureRegion = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z, const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box); static Fn_CopyTextureRegion original_CopyTextureRegion = nullptr; static void STDMETHODCALLTYPE hook_CopyTextureRegion(ID3D12GraphicsCommandList* self, const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z, const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box) { Access access(self); return original_CopyTextureRegion(access.target(), dst, dst_x, dst_y, dst_z, src, src_box); } using Fn_CopyResource = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_resource, ID3D12Resource *src_resource); static Fn_CopyResource original_CopyResource = nullptr; static void STDMETHODCALLTYPE hook_CopyResource(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_resource, ID3D12Resource *src_resource) { Access access(self); return original_CopyResource(access.target(), dst_resource, src_resource); } using Fn_CopyTiles = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *tiled_resource, const D3D12_TILED_RESOURCE_COORDINATE *tile_region_start_coordinate, const D3D12_TILE_REGION_SIZE *tile_region_size, ID3D12Resource *buffer, UINT64 buffer_offset, D3D12_TILE_COPY_FLAGS flags); static Fn_CopyTiles original_CopyTiles = nullptr; static void STDMETHODCALLTYPE hook_CopyTiles(ID3D12GraphicsCommandList* self, ID3D12Resource *tiled_resource, const D3D12_TILED_RESOURCE_COORDINATE *tile_region_start_coordinate, const D3D12_TILE_REGION_SIZE *tile_region_size, ID3D12Resource *buffer, UINT64 buffer_offset, D3D12_TILE_COPY_FLAGS flags) { Access access(self); return original_CopyTiles(access.target(), tiled_resource, tile_region_start_coordinate, tile_region_size, buffer, buffer_offset, flags); } using Fn_ResolveSubresource = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_resource, UINT dst_sub_resource, ID3D12Resource *src_resource, UINT src_sub_resource, DXGI_FORMAT format); static Fn_ResolveSubresource original_ResolveSubresource = nullptr; static void STDMETHODCALLTYPE hook_ResolveSubresource(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_resource, UINT dst_sub_resource, ID3D12Resource *src_resource, UINT src_sub_resource, DXGI_FORMAT format) { Access access(self); return original_ResolveSubresource(access.target(), dst_resource, dst_sub_resource, src_resource, src_sub_resource, format); } using Fn_IASetPrimitiveTopology = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_PRIMITIVE_TOPOLOGY primitive_topology); static Fn_IASetPrimitiveTopology original_IASetPrimitiveTopology = nullptr; static void STDMETHODCALLTYPE hook_IASetPrimitiveTopology(ID3D12GraphicsCommandList* self, D3D12_PRIMITIVE_TOPOLOGY primitive_topology) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_IASetPrimitiveTopology(target, primitive_topology); }); return original_IASetPrimitiveTopology(access.target(), primitive_topology); } using Fn_RSSetViewports = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT viewport_count, const D3D12_VIEWPORT *viewports); static Fn_RSSetViewports original_RSSetViewports = nullptr; static void STDMETHODCALLTYPE hook_RSSetViewports(ID3D12GraphicsCommandList* self, UINT viewport_count, const D3D12_VIEWPORT *viewports) { Access access(self); auto saved_viewports = copy_values(viewports, viewport_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_RSSetViewports(target, viewport_count, values_pointer(saved_viewports)); }); return original_RSSetViewports(access.target(), viewport_count, viewports); } using Fn_RSSetScissorRects = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT rect_count, const D3D12_RECT *rects); static Fn_RSSetScissorRects original_RSSetScissorRects = nullptr; static void STDMETHODCALLTYPE hook_RSSetScissorRects(ID3D12GraphicsCommandList* self, UINT rect_count, const D3D12_RECT *rects) { Access access(self); auto saved_rects = copy_values(rects, rect_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_RSSetScissorRects(target, rect_count, values_pointer(saved_rects)); }); return original_RSSetScissorRects(access.target(), rect_count, rects); } using Fn_OMSetBlendFactor = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, const FLOAT blend_factor[4]); static Fn_OMSetBlendFactor original_OMSetBlendFactor = nullptr; static void STDMETHODCALLTYPE hook_OMSetBlendFactor(ID3D12GraphicsCommandList* self, const FLOAT blend_factor[4]) { Access access(self); auto saved_blend_factor = copy_values(blend_factor, 4); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_OMSetBlendFactor(target, values_pointer(saved_blend_factor)); }); return original_OMSetBlendFactor(access.target(), blend_factor); } using Fn_OMSetStencilRef = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT stencil_ref); static Fn_OMSetStencilRef original_OMSetStencilRef = nullptr; static void STDMETHODCALLTYPE hook_OMSetStencilRef(ID3D12GraphicsCommandList* self, UINT stencil_ref) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_OMSetStencilRef(target, stencil_ref); }); return original_OMSetStencilRef(access.target(), stencil_ref); } using Fn_SetPipelineState = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12PipelineState *pipeline_state); static Fn_SetPipelineState original_SetPipelineState = nullptr; static void STDMETHODCALLTYPE hook_SetPipelineState(ID3D12GraphicsCommandList* self, ID3D12PipelineState *pipeline_state) { Access access(self); auto saved_pipeline_state = retain(pipeline_state); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetPipelineState(target, saved_pipeline_state.Get()); }); return original_SetPipelineState(access.target(), pipeline_state); } using Fn_ResourceBarrier = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT barrier_count, const D3D12_RESOURCE_BARRIER *barriers); static Fn_ResourceBarrier original_ResourceBarrier = nullptr; static void STDMETHODCALLTYPE hook_ResourceBarrier(ID3D12GraphicsCommandList* self, UINT barrier_count, const D3D12_RESOURCE_BARRIER *barriers); using Fn_ExecuteBundle = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12GraphicsCommandList *command_list); static Fn_ExecuteBundle original_ExecuteBundle = nullptr; static void STDMETHODCALLTYPE hook_ExecuteBundle(ID3D12GraphicsCommandList* self, ID3D12GraphicsCommandList *command_list); using Fn_SetDescriptorHeaps = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT heap_count, ID3D12DescriptorHeap *const *heaps); static Fn_SetDescriptorHeaps original_SetDescriptorHeaps = nullptr; static void STDMETHODCALLTYPE hook_SetDescriptorHeaps(ID3D12GraphicsCommandList* self, UINT heap_count, ID3D12DescriptorHeap *const *heaps) { Access access(self); auto saved_heaps = retain_values(heaps, heap_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetDescriptorHeaps(target, heap_count, saved_heaps.raw.data()); }); return original_SetDescriptorHeaps(access.target(), heap_count, heaps); } using Fn_SetComputeRootSignature = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12RootSignature *root_signature); static Fn_SetComputeRootSignature original_SetComputeRootSignature = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRootSignature(ID3D12GraphicsCommandList* self, ID3D12RootSignature *root_signature) { Access access(self); auto saved_root_signature = retain(root_signature); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRootSignature(target, saved_root_signature.Get()); }); return original_SetComputeRootSignature(access.target(), root_signature); } using Fn_SetGraphicsRootSignature = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12RootSignature *root_signature); static Fn_SetGraphicsRootSignature original_SetGraphicsRootSignature = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRootSignature(ID3D12GraphicsCommandList* self, ID3D12RootSignature *root_signature) { Access access(self); auto saved_root_signature = retain(root_signature); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRootSignature(target, saved_root_signature.Get()); }); return original_SetGraphicsRootSignature(access.target(), root_signature); } using Fn_SetComputeRootDescriptorTable = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor); static Fn_SetComputeRootDescriptorTable original_SetComputeRootDescriptorTable = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRootDescriptorTable(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRootDescriptorTable(target, root_parameter_index, base_descriptor); }); return original_SetComputeRootDescriptorTable(access.target(), root_parameter_index, base_descriptor); } using Fn_SetGraphicsRootDescriptorTable = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor); static Fn_SetGraphicsRootDescriptorTable original_SetGraphicsRootDescriptorTable = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRootDescriptorTable(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRootDescriptorTable(target, root_parameter_index, base_descriptor); }); return original_SetGraphicsRootDescriptorTable(access.target(), root_parameter_index, base_descriptor); } using Fn_SetComputeRoot32BitConstant = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT data, UINT dst_offset); static Fn_SetComputeRoot32BitConstant original_SetComputeRoot32BitConstant = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRoot32BitConstant(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT data, UINT dst_offset) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRoot32BitConstant(target, root_parameter_index, data, dst_offset); }); return original_SetComputeRoot32BitConstant(access.target(), root_parameter_index, data, dst_offset); } using Fn_SetGraphicsRoot32BitConstant = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT data, UINT dst_offset); static Fn_SetGraphicsRoot32BitConstant original_SetGraphicsRoot32BitConstant = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRoot32BitConstant(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT data, UINT dst_offset) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRoot32BitConstant(target, root_parameter_index, data, dst_offset); }); return original_SetGraphicsRoot32BitConstant(access.target(), root_parameter_index, data, dst_offset); } using Fn_SetComputeRoot32BitConstants = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset); static Fn_SetComputeRoot32BitConstants original_SetComputeRoot32BitConstants = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRoot32BitConstants(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset) { Access access(self); auto saved_data = copy_values(static_cast(data), constant_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRoot32BitConstants(target, root_parameter_index, constant_count, values_pointer(saved_data), dst_offset); }); return original_SetComputeRoot32BitConstants(access.target(), root_parameter_index, constant_count, data, dst_offset); } using Fn_SetGraphicsRoot32BitConstants = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset); static Fn_SetGraphicsRoot32BitConstants original_SetGraphicsRoot32BitConstants = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRoot32BitConstants(ID3D12GraphicsCommandList* self, UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset) { Access access(self); auto saved_data = copy_values(static_cast(data), constant_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRoot32BitConstants(target, root_parameter_index, constant_count, values_pointer(saved_data), dst_offset); }); return original_SetGraphicsRoot32BitConstants(access.target(), root_parameter_index, constant_count, data, dst_offset); } using Fn_SetComputeRootConstantBufferView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address); static Fn_SetComputeRootConstantBufferView original_SetComputeRootConstantBufferView = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRootConstantBufferView(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRootConstantBufferView(target, root_parameter_index, address); }); return original_SetComputeRootConstantBufferView(access.target(), root_parameter_index, address); } using Fn_SetGraphicsRootConstantBufferView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address); static Fn_SetGraphicsRootConstantBufferView original_SetGraphicsRootConstantBufferView = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRootConstantBufferView(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRootConstantBufferView(target, root_parameter_index, address); }); return original_SetGraphicsRootConstantBufferView(access.target(), root_parameter_index, address); } using Fn_SetComputeRootShaderResourceView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address); static Fn_SetComputeRootShaderResourceView original_SetComputeRootShaderResourceView = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRootShaderResourceView(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRootShaderResourceView(target, root_parameter_index, address); }); return original_SetComputeRootShaderResourceView(access.target(), root_parameter_index, address); } using Fn_SetGraphicsRootShaderResourceView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address); static Fn_SetGraphicsRootShaderResourceView original_SetGraphicsRootShaderResourceView = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRootShaderResourceView(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRootShaderResourceView(target, root_parameter_index, address); }); return original_SetGraphicsRootShaderResourceView(access.target(), root_parameter_index, address); } using Fn_SetComputeRootUnorderedAccessView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address); static Fn_SetComputeRootUnorderedAccessView original_SetComputeRootUnorderedAccessView = nullptr; static void STDMETHODCALLTYPE hook_SetComputeRootUnorderedAccessView(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetComputeRootUnorderedAccessView(target, root_parameter_index, address); }); return original_SetComputeRootUnorderedAccessView(access.target(), root_parameter_index, address); } using Fn_SetGraphicsRootUnorderedAccessView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address); static Fn_SetGraphicsRootUnorderedAccessView original_SetGraphicsRootUnorderedAccessView = nullptr; static void STDMETHODCALLTYPE hook_SetGraphicsRootUnorderedAccessView(ID3D12GraphicsCommandList* self, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetGraphicsRootUnorderedAccessView(target, root_parameter_index, address); }); return original_SetGraphicsRootUnorderedAccessView(access.target(), root_parameter_index, address); } using Fn_IASetIndexBuffer = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, const D3D12_INDEX_BUFFER_VIEW *view); static Fn_IASetIndexBuffer original_IASetIndexBuffer = nullptr; static void STDMETHODCALLTYPE hook_IASetIndexBuffer(ID3D12GraphicsCommandList* self, const D3D12_INDEX_BUFFER_VIEW *view) { Access access(self); auto saved_view = copy_values(view, 1); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_IASetIndexBuffer(target, values_pointer(saved_view)); }); return original_IASetIndexBuffer(access.target(), view); } using Fn_IASetVertexBuffers = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views); static Fn_IASetVertexBuffers original_IASetVertexBuffers = nullptr; static void STDMETHODCALLTYPE hook_IASetVertexBuffers(ID3D12GraphicsCommandList* self, UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views) { Access access(self); auto saved_views = copy_values(views, view_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_IASetVertexBuffers(target, start_slot, view_count, values_pointer(saved_views)); }); return original_IASetVertexBuffers(access.target(), start_slot, view_count, views); } using Fn_SOSetTargets = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views); static Fn_SOSetTargets original_SOSetTargets = nullptr; static void STDMETHODCALLTYPE hook_SOSetTargets(ID3D12GraphicsCommandList* self, UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views) { Access access(self); auto saved_views = copy_values(views, view_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SOSetTargets(target, start_slot, view_count, values_pointer(saved_views)); }); return original_SOSetTargets(access.target(), start_slot, view_count, views); } using Fn_OMSetRenderTargets = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT render_target_descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE *render_target_descriptors, WINBOOL single_descriptor_handle, const D3D12_CPU_DESCRIPTOR_HANDLE *depth_stencil_descriptor); static Fn_OMSetRenderTargets original_OMSetRenderTargets = nullptr; static void STDMETHODCALLTYPE hook_OMSetRenderTargets(ID3D12GraphicsCommandList* self, UINT render_target_descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE *render_target_descriptors, WINBOOL single_descriptor_handle, const D3D12_CPU_DESCRIPTOR_HANDLE *depth_stencil_descriptor) { Access access(self); auto saved_render_target_descriptors = copy_values(render_target_descriptors, (single_descriptor_handle ? 1 : render_target_descriptor_count)); auto saved_depth_stencil_descriptor = copy_values(depth_stencil_descriptor, 1); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_OMSetRenderTargets(target, render_target_descriptor_count, values_pointer(saved_render_target_descriptors), single_descriptor_handle, values_pointer(saved_depth_stencil_descriptor)); }); return original_OMSetRenderTargets(access.target(), render_target_descriptor_count, render_target_descriptors, single_descriptor_handle, depth_stencil_descriptor); } using Fn_ClearDepthStencilView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_CPU_DESCRIPTOR_HANDLE dsv, D3D12_CLEAR_FLAGS flags, FLOAT depth, UINT8 stencil, UINT rect_count, const D3D12_RECT *rects); static Fn_ClearDepthStencilView original_ClearDepthStencilView = nullptr; static void STDMETHODCALLTYPE hook_ClearDepthStencilView(ID3D12GraphicsCommandList* self, D3D12_CPU_DESCRIPTOR_HANDLE dsv, D3D12_CLEAR_FLAGS flags, FLOAT depth, UINT8 stencil, UINT rect_count, const D3D12_RECT *rects) { Access access(self); return original_ClearDepthStencilView(access.target(), dsv, flags, depth, stencil, rect_count, rects); } using Fn_ClearRenderTargetView = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects); static Fn_ClearRenderTargetView original_ClearRenderTargetView = nullptr; static void STDMETHODCALLTYPE hook_ClearRenderTargetView(ID3D12GraphicsCommandList* self, D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects) { Access access(self); return original_ClearRenderTargetView(access.target(), rtv, color, rect_count, rects); } using Fn_ClearUnorderedAccessViewUint = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource, const UINT values[4], UINT rect_count, const D3D12_RECT *rects); static Fn_ClearUnorderedAccessViewUint original_ClearUnorderedAccessViewUint = nullptr; static void STDMETHODCALLTYPE hook_ClearUnorderedAccessViewUint(ID3D12GraphicsCommandList* self, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource, const UINT values[4], UINT rect_count, const D3D12_RECT *rects) { Access access(self); return original_ClearUnorderedAccessViewUint(access.target(), gpu_handle, cpu_handle, resource, values, rect_count, rects); } using Fn_ClearUnorderedAccessViewFloat = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource, const float values[4], UINT rect_count, const D3D12_RECT *rects); static Fn_ClearUnorderedAccessViewFloat original_ClearUnorderedAccessViewFloat = nullptr; static void STDMETHODCALLTYPE hook_ClearUnorderedAccessViewFloat(ID3D12GraphicsCommandList* self, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource, const float values[4], UINT rect_count, const D3D12_RECT *rects) { Access access(self); return original_ClearUnorderedAccessViewFloat(access.target(), gpu_handle, cpu_handle, resource, values, rect_count, rects); } using Fn_DiscardResource = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *resource, const D3D12_DISCARD_REGION *region); static Fn_DiscardResource original_DiscardResource = nullptr; static void STDMETHODCALLTYPE hook_DiscardResource(ID3D12GraphicsCommandList* self, ID3D12Resource *resource, const D3D12_DISCARD_REGION *region) { Access access(self); return original_DiscardResource(access.target(), resource, region); } using Fn_BeginQuery = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index); static Fn_BeginQuery original_BeginQuery = nullptr; static void STDMETHODCALLTYPE hook_BeginQuery(ID3D12GraphicsCommandList* self, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index); using Fn_EndQuery = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index); static Fn_EndQuery original_EndQuery = nullptr; static void STDMETHODCALLTYPE hook_EndQuery(ID3D12GraphicsCommandList* self, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index); using Fn_ResolveQueryData = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count, ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset); static Fn_ResolveQueryData original_ResolveQueryData = nullptr; static void STDMETHODCALLTYPE hook_ResolveQueryData(ID3D12GraphicsCommandList* self, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count, ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset) { Access access(self); return original_ResolveQueryData(access.target(), heap, type, start_index, query_count, dst_buffer, aligned_dst_buffer_offset); } using Fn_SetPredication = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *buffer, UINT64 aligned_buffer_offset, D3D12_PREDICATION_OP operation); static Fn_SetPredication original_SetPredication = nullptr; static void STDMETHODCALLTYPE hook_SetPredication(ID3D12GraphicsCommandList* self, ID3D12Resource *buffer, UINT64 aligned_buffer_offset, D3D12_PREDICATION_OP operation); using Fn_SetMarker = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT metadata, const void *data, UINT size); static Fn_SetMarker original_SetMarker = nullptr; static void STDMETHODCALLTYPE hook_SetMarker(ID3D12GraphicsCommandList* self, UINT metadata, const void *data, UINT size) { Access access(self); return original_SetMarker(access.target(), metadata, data, size); } using Fn_BeginEvent = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT metadata, const void *data, UINT size); static Fn_BeginEvent original_BeginEvent = nullptr; static void STDMETHODCALLTYPE hook_BeginEvent(ID3D12GraphicsCommandList* self, UINT metadata, const void *data, UINT size); using Fn_EndEvent = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self); static Fn_EndEvent original_EndEvent = nullptr; static void STDMETHODCALLTYPE hook_EndEvent(ID3D12GraphicsCommandList* self); using Fn_ExecuteIndirect = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12CommandSignature *command_signature, UINT max_command_count, ID3D12Resource *arg_buffer, UINT64 arg_buffer_offset, ID3D12Resource *count_buffer, UINT64 count_buffer_offset); static Fn_ExecuteIndirect original_ExecuteIndirect = nullptr; static void STDMETHODCALLTYPE hook_ExecuteIndirect(ID3D12GraphicsCommandList* self, ID3D12CommandSignature *command_signature, UINT max_command_count, ID3D12Resource *arg_buffer, UINT64 arg_buffer_offset, ID3D12Resource *count_buffer, UINT64 count_buffer_offset); using Fn_AtomicCopyBufferUINT = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT dependent_resource_count, ID3D12Resource *const *dependent_resources, const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges); static Fn_AtomicCopyBufferUINT original_AtomicCopyBufferUINT = nullptr; static void STDMETHODCALLTYPE hook_AtomicCopyBufferUINT(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT dependent_resource_count, ID3D12Resource *const *dependent_resources, const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges) { Access access(self); return original_AtomicCopyBufferUINT(access.target(), dst_buffer, dst_offset, src_buffer, src_offset, dependent_resource_count, dependent_resources, dependent_sub_resource_ranges); } using Fn_AtomicCopyBufferUINT64 = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT dependent_resource_count, ID3D12Resource *const *dependent_resources, const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges); static Fn_AtomicCopyBufferUINT64 original_AtomicCopyBufferUINT64 = nullptr; static void STDMETHODCALLTYPE hook_AtomicCopyBufferUINT64(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT dependent_resource_count, ID3D12Resource *const *dependent_resources, const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges) { Access access(self); return original_AtomicCopyBufferUINT64(access.target(), dst_buffer, dst_offset, src_buffer, src_offset, dependent_resource_count, dependent_resources, dependent_sub_resource_ranges); } using Fn_OMSetDepthBounds = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, FLOAT min, FLOAT max); static Fn_OMSetDepthBounds original_OMSetDepthBounds = nullptr; static void STDMETHODCALLTYPE hook_OMSetDepthBounds(ID3D12GraphicsCommandList* self, FLOAT min, FLOAT max) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_OMSetDepthBounds(target, min, max); }); return original_OMSetDepthBounds(access.target(), min, max); } using Fn_SetSamplePositions = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT sample_count, UINT pixel_count, D3D12_SAMPLE_POSITION *sample_positions); static Fn_SetSamplePositions original_SetSamplePositions = nullptr; static void STDMETHODCALLTYPE hook_SetSamplePositions(ID3D12GraphicsCommandList* self, UINT sample_count, UINT pixel_count, D3D12_SAMPLE_POSITION *sample_positions) { Access access(self); auto saved_sample_positions = copy_values(sample_positions, sample_count * pixel_count); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetSamplePositions(target, sample_count, pixel_count, values_pointer(saved_sample_positions)); }); return original_SetSamplePositions(access.target(), sample_count, pixel_count, sample_positions); } using Fn_ResolveSubresourceRegion = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_resource, UINT dst_sub_resource_idx, UINT dst_x, UINT dst_y, ID3D12Resource *src_resource, UINT src_sub_resource_idx, D3D12_RECT *src_rect, DXGI_FORMAT format, D3D12_RESOLVE_MODE mode); static Fn_ResolveSubresourceRegion original_ResolveSubresourceRegion = nullptr; static void STDMETHODCALLTYPE hook_ResolveSubresourceRegion(ID3D12GraphicsCommandList* self, ID3D12Resource *dst_resource, UINT dst_sub_resource_idx, UINT dst_x, UINT dst_y, ID3D12Resource *src_resource, UINT src_sub_resource_idx, D3D12_RECT *src_rect, DXGI_FORMAT format, D3D12_RESOLVE_MODE mode) { Access access(self); return original_ResolveSubresourceRegion(access.target(), dst_resource, dst_sub_resource_idx, dst_x, dst_y, src_resource, src_sub_resource_idx, src_rect, format, mode); } using Fn_SetViewInstanceMask = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT mask); static Fn_SetViewInstanceMask original_SetViewInstanceMask = nullptr; static void STDMETHODCALLTYPE hook_SetViewInstanceMask(ID3D12GraphicsCommandList* self, UINT mask) { Access access(self); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetViewInstanceMask(target, mask); }); return original_SetViewInstanceMask(access.target(), mask); } using Fn_WriteBufferImmediate = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT count, const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *parameters, const D3D12_WRITEBUFFERIMMEDIATE_MODE *modes); static Fn_WriteBufferImmediate original_WriteBufferImmediate = nullptr; static void STDMETHODCALLTYPE hook_WriteBufferImmediate(ID3D12GraphicsCommandList* self, UINT count, const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *parameters, const D3D12_WRITEBUFFERIMMEDIATE_MODE *modes) { Access access(self); return original_WriteBufferImmediate(access.target(), count, parameters, modes); } using Fn_SetProtectedResourceSession = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12ProtectedResourceSession *protected_resource_session); static Fn_SetProtectedResourceSession original_SetProtectedResourceSession = nullptr; static void STDMETHODCALLTYPE hook_SetProtectedResourceSession(ID3D12GraphicsCommandList* self, ID3D12ProtectedResourceSession *protected_resource_session) { Access access(self); auto saved_protected_resource_session = retain(protected_resource_session); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetProtectedResourceSession(target, saved_protected_resource_session.Get()); }); return original_SetProtectedResourceSession(access.target(), protected_resource_session); } using Fn_BeginRenderPass = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT render_targets_count, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *render_targets, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *depth_stencil, D3D12_RENDER_PASS_FLAGS flags); static Fn_BeginRenderPass original_BeginRenderPass = nullptr; static void STDMETHODCALLTYPE hook_BeginRenderPass(ID3D12GraphicsCommandList* self, UINT render_targets_count, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *render_targets, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *depth_stencil, D3D12_RENDER_PASS_FLAGS flags); using Fn_EndRenderPass = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self); static Fn_EndRenderPass original_EndRenderPass = nullptr; static void STDMETHODCALLTYPE hook_EndRenderPass(ID3D12GraphicsCommandList* self); using Fn_InitializeMetaCommand = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12MetaCommand *meta_command, const void *initialization_parameters_data, SIZE_T initialization_parameters_data_size_in_bytes); static Fn_InitializeMetaCommand original_InitializeMetaCommand = nullptr; static void STDMETHODCALLTYPE hook_InitializeMetaCommand(ID3D12GraphicsCommandList* self, ID3D12MetaCommand *meta_command, const void *initialization_parameters_data, SIZE_T initialization_parameters_data_size_in_bytes) { Access access(self); return original_InitializeMetaCommand(access.target(), meta_command, initialization_parameters_data, initialization_parameters_data_size_in_bytes); } using Fn_ExecuteMetaCommand = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12MetaCommand *meta_command, const void *execution_parameters_data, SIZE_T execution_parameters_data_size_in_bytes); static Fn_ExecuteMetaCommand original_ExecuteMetaCommand = nullptr; static void STDMETHODCALLTYPE hook_ExecuteMetaCommand(ID3D12GraphicsCommandList* self, ID3D12MetaCommand *meta_command, const void *execution_parameters_data, SIZE_T execution_parameters_data_size_in_bytes) { Access access(self); return original_ExecuteMetaCommand(access.target(), meta_command, execution_parameters_data, execution_parameters_data_size_in_bytes); } using Fn_BuildRaytracingAccelerationStructure = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *desc, UINT postbuild_info_descs_count, const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *postbuild_info_descs); static Fn_BuildRaytracingAccelerationStructure original_BuildRaytracingAccelerationStructure = nullptr; static void STDMETHODCALLTYPE hook_BuildRaytracingAccelerationStructure(ID3D12GraphicsCommandList* self, const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *desc, UINT postbuild_info_descs_count, const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *postbuild_info_descs) { Access access(self); return original_BuildRaytracingAccelerationStructure(access.target(), desc, postbuild_info_descs_count, postbuild_info_descs); } using Fn_EmitRaytracingAccelerationStructurePostbuildInfo = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc, UINT src_acceleration_structures_count, const D3D12_GPU_VIRTUAL_ADDRESS *src_acceleration_structure_data); static Fn_EmitRaytracingAccelerationStructurePostbuildInfo original_EmitRaytracingAccelerationStructurePostbuildInfo = nullptr; static void STDMETHODCALLTYPE hook_EmitRaytracingAccelerationStructurePostbuildInfo(ID3D12GraphicsCommandList* self, const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc, UINT src_acceleration_structures_count, const D3D12_GPU_VIRTUAL_ADDRESS *src_acceleration_structure_data) { Access access(self); return original_EmitRaytracingAccelerationStructurePostbuildInfo(access.target(), desc, src_acceleration_structures_count, src_acceleration_structure_data); } using Fn_CopyRaytracingAccelerationStructure = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_GPU_VIRTUAL_ADDRESS dst_acceleration_structure_data, D3D12_GPU_VIRTUAL_ADDRESS src_acceleration_structure_data, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode); static Fn_CopyRaytracingAccelerationStructure original_CopyRaytracingAccelerationStructure = nullptr; static void STDMETHODCALLTYPE hook_CopyRaytracingAccelerationStructure(ID3D12GraphicsCommandList* self, D3D12_GPU_VIRTUAL_ADDRESS dst_acceleration_structure_data, D3D12_GPU_VIRTUAL_ADDRESS src_acceleration_structure_data, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode) { Access access(self); return original_CopyRaytracingAccelerationStructure(access.target(), dst_acceleration_structure_data, src_acceleration_structure_data, mode); } using Fn_SetPipelineState1 = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12StateObject *state_object); static Fn_SetPipelineState1 original_SetPipelineState1 = nullptr; static void STDMETHODCALLTYPE hook_SetPipelineState1(ID3D12GraphicsCommandList* self, ID3D12StateObject *state_object) { Access access(self); auto saved_state_object = retain(state_object); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_SetPipelineState1(target, saved_state_object.Get()); }); return original_SetPipelineState1(access.target(), state_object); } using Fn_DispatchRays = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, const D3D12_DISPATCH_RAYS_DESC *desc); static Fn_DispatchRays original_DispatchRays = nullptr; static void STDMETHODCALLTYPE hook_DispatchRays(ID3D12GraphicsCommandList* self, const D3D12_DISPATCH_RAYS_DESC *desc) { Access access(self); return original_DispatchRays(access.target(), desc); } using Fn_RSSetShadingRate = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, D3D12_SHADING_RATE base_shading_rate, const D3D12_SHADING_RATE_COMBINER *combiners); static Fn_RSSetShadingRate original_RSSetShadingRate = nullptr; static void STDMETHODCALLTYPE hook_RSSetShadingRate(ID3D12GraphicsCommandList* self, D3D12_SHADING_RATE base_shading_rate, const D3D12_SHADING_RATE_COMBINER *combiners) { Access access(self); auto saved_combiners = copy_values(combiners, 2); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_RSSetShadingRate(target, base_shading_rate, values_pointer(saved_combiners)); }); return original_RSSetShadingRate(access.target(), base_shading_rate, combiners); } using Fn_RSSetShadingRateImage = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, ID3D12Resource *shading_rate_image); static Fn_RSSetShadingRateImage original_RSSetShadingRateImage = nullptr; static void STDMETHODCALLTYPE hook_RSSetShadingRateImage(ID3D12GraphicsCommandList* self, ID3D12Resource *shading_rate_image) { Access access(self); auto saved_shading_rate_image = retain(shading_rate_image); if (access.recording) access.recording->state.emplace_back([=](ID3D12GraphicsCommandList* target) mutable { original_RSSetShadingRateImage(target, saved_shading_rate_image.Get()); }); return original_RSSetShadingRateImage(access.target(), shading_rate_image); } using Fn_DispatchMesh = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z); static Fn_DispatchMesh original_DispatchMesh = nullptr; static void STDMETHODCALLTYPE hook_DispatchMesh(ID3D12GraphicsCommandList* self, UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z) { Access access(self); return original_DispatchMesh(access.target(), thread_group_count_x, thread_group_count_y, thread_group_count_z); } using Fn_Barrier = void(STDMETHODCALLTYPE*)(ID3D12GraphicsCommandList* self, UINT32 barrier_groups_count, const D3D12_BARRIER_GROUP *barrier_groups); static Fn_Barrier original_Barrier = nullptr; static void STDMETHODCALLTYPE hook_Barrier(ID3D12GraphicsCommandList* self, UINT32 barrier_groups_count, const D3D12_BARRIER_GROUP *barrier_groups); static void attach_recording_methods(void** table, unsigned version) { if (version >= 0) attach_method(table[9], reinterpret_cast(hook_Close), reinterpret_cast(&original_Close), "Close"); if (version >= 0) attach_method(table[10], reinterpret_cast(hook_Reset), reinterpret_cast(&original_Reset), "Reset"); if (version >= 0) attach_method(table[11], reinterpret_cast(hook_ClearState), reinterpret_cast(&original_ClearState), "ClearState"); if (version >= 0) attach_method(table[12], reinterpret_cast(hook_DrawInstanced), reinterpret_cast(&original_DrawInstanced), "DrawInstanced"); if (version >= 0) attach_method(table[13], reinterpret_cast(hook_DrawIndexedInstanced), reinterpret_cast(&original_DrawIndexedInstanced), "DrawIndexedInstanced"); if (version >= 0) attach_method(table[14], reinterpret_cast(hook_Dispatch), reinterpret_cast(&original_Dispatch), "Dispatch"); if (version >= 0) attach_method(table[15], reinterpret_cast(hook_CopyBufferRegion), reinterpret_cast(&original_CopyBufferRegion), "CopyBufferRegion"); if (version >= 0) attach_method(table[16], reinterpret_cast(hook_CopyTextureRegion), reinterpret_cast(&original_CopyTextureRegion), "CopyTextureRegion"); if (version >= 0) attach_method(table[17], reinterpret_cast(hook_CopyResource), reinterpret_cast(&original_CopyResource), "CopyResource"); if (version >= 0) attach_method(table[18], reinterpret_cast(hook_CopyTiles), reinterpret_cast(&original_CopyTiles), "CopyTiles"); if (version >= 0) attach_method(table[19], reinterpret_cast(hook_ResolveSubresource), reinterpret_cast(&original_ResolveSubresource), "ResolveSubresource"); if (version >= 0) attach_method(table[20], reinterpret_cast(hook_IASetPrimitiveTopology), reinterpret_cast(&original_IASetPrimitiveTopology), "IASetPrimitiveTopology"); if (version >= 0) attach_method(table[21], reinterpret_cast(hook_RSSetViewports), reinterpret_cast(&original_RSSetViewports), "RSSetViewports"); if (version >= 0) attach_method(table[22], reinterpret_cast(hook_RSSetScissorRects), reinterpret_cast(&original_RSSetScissorRects), "RSSetScissorRects"); if (version >= 0) attach_method(table[23], reinterpret_cast(hook_OMSetBlendFactor), reinterpret_cast(&original_OMSetBlendFactor), "OMSetBlendFactor"); if (version >= 0) attach_method(table[24], reinterpret_cast(hook_OMSetStencilRef), reinterpret_cast(&original_OMSetStencilRef), "OMSetStencilRef"); if (version >= 0) attach_method(table[25], reinterpret_cast(hook_SetPipelineState), reinterpret_cast(&original_SetPipelineState), "SetPipelineState"); if (version >= 0) attach_method(table[26], reinterpret_cast(hook_ResourceBarrier), reinterpret_cast(&original_ResourceBarrier), "ResourceBarrier"); if (version >= 0) attach_method(table[27], reinterpret_cast(hook_ExecuteBundle), reinterpret_cast(&original_ExecuteBundle), "ExecuteBundle"); if (version >= 0) attach_method(table[28], reinterpret_cast(hook_SetDescriptorHeaps), reinterpret_cast(&original_SetDescriptorHeaps), "SetDescriptorHeaps"); if (version >= 0) attach_method(table[29], reinterpret_cast(hook_SetComputeRootSignature), reinterpret_cast(&original_SetComputeRootSignature), "SetComputeRootSignature"); if (version >= 0) attach_method(table[30], reinterpret_cast(hook_SetGraphicsRootSignature), reinterpret_cast(&original_SetGraphicsRootSignature), "SetGraphicsRootSignature"); if (version >= 0) attach_method(table[31], reinterpret_cast(hook_SetComputeRootDescriptorTable), reinterpret_cast(&original_SetComputeRootDescriptorTable), "SetComputeRootDescriptorTable"); if (version >= 0) attach_method(table[32], reinterpret_cast(hook_SetGraphicsRootDescriptorTable), reinterpret_cast(&original_SetGraphicsRootDescriptorTable), "SetGraphicsRootDescriptorTable"); if (version >= 0) attach_method(table[33], reinterpret_cast(hook_SetComputeRoot32BitConstant), reinterpret_cast(&original_SetComputeRoot32BitConstant), "SetComputeRoot32BitConstant"); if (version >= 0) attach_method(table[34], reinterpret_cast(hook_SetGraphicsRoot32BitConstant), reinterpret_cast(&original_SetGraphicsRoot32BitConstant), "SetGraphicsRoot32BitConstant"); if (version >= 0) attach_method(table[35], reinterpret_cast(hook_SetComputeRoot32BitConstants), reinterpret_cast(&original_SetComputeRoot32BitConstants), "SetComputeRoot32BitConstants"); if (version >= 0) attach_method(table[36], reinterpret_cast(hook_SetGraphicsRoot32BitConstants), reinterpret_cast(&original_SetGraphicsRoot32BitConstants), "SetGraphicsRoot32BitConstants"); if (version >= 0) attach_method(table[37], reinterpret_cast(hook_SetComputeRootConstantBufferView), reinterpret_cast(&original_SetComputeRootConstantBufferView), "SetComputeRootConstantBufferView"); if (version >= 0) attach_method(table[38], reinterpret_cast(hook_SetGraphicsRootConstantBufferView), reinterpret_cast(&original_SetGraphicsRootConstantBufferView), "SetGraphicsRootConstantBufferView"); if (version >= 0) attach_method(table[39], reinterpret_cast(hook_SetComputeRootShaderResourceView), reinterpret_cast(&original_SetComputeRootShaderResourceView), "SetComputeRootShaderResourceView"); if (version >= 0) attach_method(table[40], reinterpret_cast(hook_SetGraphicsRootShaderResourceView), reinterpret_cast(&original_SetGraphicsRootShaderResourceView), "SetGraphicsRootShaderResourceView"); if (version >= 0) attach_method(table[41], reinterpret_cast(hook_SetComputeRootUnorderedAccessView), reinterpret_cast(&original_SetComputeRootUnorderedAccessView), "SetComputeRootUnorderedAccessView"); if (version >= 0) attach_method(table[42], reinterpret_cast(hook_SetGraphicsRootUnorderedAccessView), reinterpret_cast(&original_SetGraphicsRootUnorderedAccessView), "SetGraphicsRootUnorderedAccessView"); if (version >= 0) attach_method(table[43], reinterpret_cast(hook_IASetIndexBuffer), reinterpret_cast(&original_IASetIndexBuffer), "IASetIndexBuffer"); if (version >= 0) attach_method(table[44], reinterpret_cast(hook_IASetVertexBuffers), reinterpret_cast(&original_IASetVertexBuffers), "IASetVertexBuffers"); if (version >= 0) attach_method(table[45], reinterpret_cast(hook_SOSetTargets), reinterpret_cast(&original_SOSetTargets), "SOSetTargets"); if (version >= 0) attach_method(table[46], reinterpret_cast(hook_OMSetRenderTargets), reinterpret_cast(&original_OMSetRenderTargets), "OMSetRenderTargets"); if (version >= 0) attach_method(table[47], reinterpret_cast(hook_ClearDepthStencilView), reinterpret_cast(&original_ClearDepthStencilView), "ClearDepthStencilView"); if (version >= 0) attach_method(table[48], reinterpret_cast(hook_ClearRenderTargetView), reinterpret_cast(&original_ClearRenderTargetView), "ClearRenderTargetView"); if (version >= 0) attach_method(table[49], reinterpret_cast(hook_ClearUnorderedAccessViewUint), reinterpret_cast(&original_ClearUnorderedAccessViewUint), "ClearUnorderedAccessViewUint"); if (version >= 0) attach_method(table[50], reinterpret_cast(hook_ClearUnorderedAccessViewFloat), reinterpret_cast(&original_ClearUnorderedAccessViewFloat), "ClearUnorderedAccessViewFloat"); if (version >= 0) attach_method(table[51], reinterpret_cast(hook_DiscardResource), reinterpret_cast(&original_DiscardResource), "DiscardResource"); if (version >= 0) attach_method(table[52], reinterpret_cast(hook_BeginQuery), reinterpret_cast(&original_BeginQuery), "BeginQuery"); if (version >= 0) attach_method(table[53], reinterpret_cast(hook_EndQuery), reinterpret_cast(&original_EndQuery), "EndQuery"); if (version >= 0) attach_method(table[54], reinterpret_cast(hook_ResolveQueryData), reinterpret_cast(&original_ResolveQueryData), "ResolveQueryData"); if (version >= 0) attach_method(table[55], reinterpret_cast(hook_SetPredication), reinterpret_cast(&original_SetPredication), "SetPredication"); if (version >= 0) attach_method(table[56], reinterpret_cast(hook_SetMarker), reinterpret_cast(&original_SetMarker), "SetMarker"); if (version >= 0) attach_method(table[57], reinterpret_cast(hook_BeginEvent), reinterpret_cast(&original_BeginEvent), "BeginEvent"); if (version >= 0) attach_method(table[58], reinterpret_cast(hook_EndEvent), reinterpret_cast(&original_EndEvent), "EndEvent"); if (version >= 0) attach_method(table[59], reinterpret_cast(hook_ExecuteIndirect), reinterpret_cast(&original_ExecuteIndirect), "ExecuteIndirect"); if (version >= 1) attach_method(table[60], reinterpret_cast(hook_AtomicCopyBufferUINT), reinterpret_cast(&original_AtomicCopyBufferUINT), "AtomicCopyBufferUINT"); if (version >= 1) attach_method(table[61], reinterpret_cast(hook_AtomicCopyBufferUINT64), reinterpret_cast(&original_AtomicCopyBufferUINT64), "AtomicCopyBufferUINT64"); if (version >= 1) attach_method(table[62], reinterpret_cast(hook_OMSetDepthBounds), reinterpret_cast(&original_OMSetDepthBounds), "OMSetDepthBounds"); if (version >= 1) attach_method(table[63], reinterpret_cast(hook_SetSamplePositions), reinterpret_cast(&original_SetSamplePositions), "SetSamplePositions"); if (version >= 1) attach_method(table[64], reinterpret_cast(hook_ResolveSubresourceRegion), reinterpret_cast(&original_ResolveSubresourceRegion), "ResolveSubresourceRegion"); if (version >= 1) attach_method(table[65], reinterpret_cast(hook_SetViewInstanceMask), reinterpret_cast(&original_SetViewInstanceMask), "SetViewInstanceMask"); if (version >= 2) attach_method(table[66], reinterpret_cast(hook_WriteBufferImmediate), reinterpret_cast(&original_WriteBufferImmediate), "WriteBufferImmediate"); if (version >= 3) attach_method(table[67], reinterpret_cast(hook_SetProtectedResourceSession), reinterpret_cast(&original_SetProtectedResourceSession), "SetProtectedResourceSession"); if (version >= 4) attach_method(table[68], reinterpret_cast(hook_BeginRenderPass), reinterpret_cast(&original_BeginRenderPass), "BeginRenderPass"); if (version >= 4) attach_method(table[69], reinterpret_cast(hook_EndRenderPass), reinterpret_cast(&original_EndRenderPass), "EndRenderPass"); if (version >= 4) attach_method(table[70], reinterpret_cast(hook_InitializeMetaCommand), reinterpret_cast(&original_InitializeMetaCommand), "InitializeMetaCommand"); if (version >= 4) attach_method(table[71], reinterpret_cast(hook_ExecuteMetaCommand), reinterpret_cast(&original_ExecuteMetaCommand), "ExecuteMetaCommand"); if (version >= 4) attach_method(table[72], reinterpret_cast(hook_BuildRaytracingAccelerationStructure), reinterpret_cast(&original_BuildRaytracingAccelerationStructure), "BuildRaytracingAccelerationStructure"); if (version >= 4) attach_method(table[73], reinterpret_cast(hook_EmitRaytracingAccelerationStructurePostbuildInfo), reinterpret_cast(&original_EmitRaytracingAccelerationStructurePostbuildInfo), "EmitRaytracingAccelerationStructurePostbuildInfo"); if (version >= 4) attach_method(table[74], reinterpret_cast(hook_CopyRaytracingAccelerationStructure), reinterpret_cast(&original_CopyRaytracingAccelerationStructure), "CopyRaytracingAccelerationStructure"); if (version >= 4) attach_method(table[75], reinterpret_cast(hook_SetPipelineState1), reinterpret_cast(&original_SetPipelineState1), "SetPipelineState1"); if (version >= 4) attach_method(table[76], reinterpret_cast(hook_DispatchRays), reinterpret_cast(&original_DispatchRays), "DispatchRays"); if (version >= 5) attach_method(table[77], reinterpret_cast(hook_RSSetShadingRate), reinterpret_cast(&original_RSSetShadingRate), "RSSetShadingRate"); if (version >= 5) attach_method(table[78], reinterpret_cast(hook_RSSetShadingRateImage), reinterpret_cast(&original_RSSetShadingRateImage), "RSSetShadingRateImage"); if (version >= 6) attach_method(table[79], reinterpret_cast(hook_DispatchMesh), reinterpret_cast(&original_DispatchMesh), "DispatchMesh"); if (version >= 7) attach_method(table[80], reinterpret_cast(hook_Barrier), reinterpret_cast(&original_Barrier), "Barrier"); }