[D3D12] Cleanup: remove inline

This commit is contained in:
Triang3l 2020-11-14 17:02:09 +03:00
parent 6b988d43c7
commit fe9b5b4a8f
8 changed files with 86 additions and 95 deletions

View File

@ -188,7 +188,7 @@ class D3D12CommandProcessor : public CommandProcessor {
// Returns a pipeline with deferred creation by its handle. May return nullptr // Returns a pipeline with deferred creation by its handle. May return nullptr
// if failed to create the pipeline. // if failed to create the pipeline.
inline ID3D12PipelineState* GetD3D12PipelineByHandle(void* handle) const { ID3D12PipelineState* GetD3D12PipelineByHandle(void* handle) const {
return pipeline_cache_->GetD3D12PipelineByHandle(handle); return pipeline_cache_->GetD3D12PipelineByHandle(handle);
} }
@ -501,7 +501,7 @@ class D3D12CommandProcessor : public CommandProcessor {
static constexpr uint32_t kSwapTextureWidth = 1280; static constexpr uint32_t kSwapTextureWidth = 1280;
static constexpr uint32_t kSwapTextureHeight = 720; static constexpr uint32_t kSwapTextureHeight = 720;
inline std::pair<uint32_t, uint32_t> GetSwapTextureSize() const { std::pair<uint32_t, uint32_t> GetSwapTextureSize() const {
if (texture_cache_->IsResolutionScale2X()) { if (texture_cache_->IsResolutionScale2X()) {
return std::make_pair(kSwapTextureWidth * 2, kSwapTextureHeight * 2); return std::make_pair(kSwapTextureWidth * 2, kSwapTextureHeight * 2);
} }

View File

@ -48,7 +48,7 @@ class D3D12SharedMemory : public SharedMemory {
// UseForReading or UseForWriting. // UseForReading or UseForWriting.
// Makes the buffer usable for vertices, indices and texture untiling. // Makes the buffer usable for vertices, indices and texture untiling.
inline void UseForReading() { void UseForReading() {
// Vertex fetch is also allowed in pixel shaders. // Vertex fetch is also allowed in pixel shaders.
CommitUAVWritesAndTransitionBuffer( CommitUAVWritesAndTransitionBuffer(
D3D12_RESOURCE_STATE_INDEX_BUFFER | D3D12_RESOURCE_STATE_INDEX_BUFFER |
@ -56,18 +56,18 @@ class D3D12SharedMemory : public SharedMemory {
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
} }
// Makes the buffer usable for texture tiling after a resolve. // Makes the buffer usable for texture tiling after a resolve.
inline void UseForWriting() { void UseForWriting() {
CommitUAVWritesAndTransitionBuffer(D3D12_RESOURCE_STATE_UNORDERED_ACCESS); CommitUAVWritesAndTransitionBuffer(D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
} }
// Makes the buffer usable as a source for copy commands. // Makes the buffer usable as a source for copy commands.
inline void UseAsCopySource() { void UseAsCopySource() {
CommitUAVWritesAndTransitionBuffer(D3D12_RESOURCE_STATE_COPY_SOURCE); CommitUAVWritesAndTransitionBuffer(D3D12_RESOURCE_STATE_COPY_SOURCE);
} }
// Must be called when doing draws/dispatches modifying data within the shared // Must be called when doing draws/dispatches modifying data within the shared
// memory buffer as a UAV, to make sure that when UseForWriting is called the // memory buffer as a UAV, to make sure that when UseForWriting is called the
// next time, a UAV barrier will be done, and subsequent overlapping UAV // next time, a UAV barrier will be done, and subsequent overlapping UAV
// writes and reads are ordered. // writes and reads are ordered.
inline void MarkUAVWritesCommitNeeded() { void MarkUAVWritesCommitNeeded() {
if (buffer_state_ == D3D12_RESOURCE_STATE_UNORDERED_ACCESS) { if (buffer_state_ == D3D12_RESOURCE_STATE_UNORDERED_ACCESS) {
buffer_uav_writes_commit_needed_ = true; buffer_uav_writes_commit_needed_ = true;
} }

View File

@ -33,7 +33,7 @@ class DeferredCommandList {
void Execute(ID3D12GraphicsCommandList* command_list, void Execute(ID3D12GraphicsCommandList* command_list,
ID3D12GraphicsCommandList1* command_list_1); ID3D12GraphicsCommandList1* command_list_1);
inline void D3DClearUnorderedAccessViewUint( void D3DClearUnorderedAccessViewUint(
D3D12_GPU_DESCRIPTOR_HANDLE view_gpu_handle_in_current_heap, D3D12_GPU_DESCRIPTOR_HANDLE view_gpu_handle_in_current_heap,
D3D12_CPU_DESCRIPTOR_HANDLE view_cpu_handle, ID3D12Resource* resource, D3D12_CPU_DESCRIPTOR_HANDLE view_cpu_handle, ID3D12Resource* resource,
const UINT values[4], UINT num_rects, const D3D12_RECT* rects) { const UINT values[4], UINT num_rects, const D3D12_RECT* rects) {
@ -51,7 +51,7 @@ class DeferredCommandList {
} }
} }
inline void D3DCopyBufferRegion(ID3D12Resource* dst_buffer, UINT64 dst_offset, void D3DCopyBufferRegion(ID3D12Resource* dst_buffer, UINT64 dst_offset,
ID3D12Resource* src_buffer, UINT64 src_offset, ID3D12Resource* src_buffer, UINT64 src_offset,
UINT64 num_bytes) { UINT64 num_bytes) {
auto& args = *reinterpret_cast<D3DCopyBufferRegionArguments*>(WriteCommand( auto& args = *reinterpret_cast<D3DCopyBufferRegionArguments*>(WriteCommand(
@ -63,7 +63,7 @@ class DeferredCommandList {
args.num_bytes = num_bytes; args.num_bytes = num_bytes;
} }
inline void D3DCopyResource(ID3D12Resource* dst_resource, void D3DCopyResource(ID3D12Resource* dst_resource,
ID3D12Resource* src_resource) { ID3D12Resource* src_resource) {
auto& args = *reinterpret_cast<D3DCopyResourceArguments*>(WriteCommand( auto& args = *reinterpret_cast<D3DCopyResourceArguments*>(WriteCommand(
Command::kD3DCopyResource, sizeof(D3DCopyResourceArguments))); Command::kD3DCopyResource, sizeof(D3DCopyResourceArguments)));
@ -71,7 +71,7 @@ class DeferredCommandList {
args.src_resource = src_resource; args.src_resource = src_resource;
} }
inline void CopyTexture(const D3D12_TEXTURE_COPY_LOCATION& dst, void CopyTexture(const D3D12_TEXTURE_COPY_LOCATION& dst,
const D3D12_TEXTURE_COPY_LOCATION& src) { const D3D12_TEXTURE_COPY_LOCATION& src) {
auto& args = *reinterpret_cast<CopyTextureArguments*>( auto& args = *reinterpret_cast<CopyTextureArguments*>(
WriteCommand(Command::kCopyTexture, sizeof(CopyTextureArguments))); WriteCommand(Command::kCopyTexture, sizeof(CopyTextureArguments)));
@ -79,8 +79,8 @@ class DeferredCommandList {
std::memcpy(&args.src, &src, sizeof(D3D12_TEXTURE_COPY_LOCATION)); std::memcpy(&args.src, &src, sizeof(D3D12_TEXTURE_COPY_LOCATION));
} }
inline void CopyTextureRegion(const D3D12_TEXTURE_COPY_LOCATION& dst, void CopyTextureRegion(const D3D12_TEXTURE_COPY_LOCATION& dst, UINT dst_x,
UINT dst_x, UINT dst_y, UINT dst_z, UINT dst_y, UINT dst_z,
const D3D12_TEXTURE_COPY_LOCATION& src, const D3D12_TEXTURE_COPY_LOCATION& src,
const D3D12_BOX& src_box) { const D3D12_BOX& src_box) {
auto& args = *reinterpret_cast<CopyTextureRegionArguments*>(WriteCommand( auto& args = *reinterpret_cast<CopyTextureRegionArguments*>(WriteCommand(
@ -93,7 +93,7 @@ class DeferredCommandList {
args.src_box = src_box; args.src_box = src_box;
} }
inline void D3DDispatch(UINT thread_group_count_x, UINT thread_group_count_y, void D3DDispatch(UINT thread_group_count_x, UINT thread_group_count_y,
UINT thread_group_count_z) { UINT thread_group_count_z) {
auto& args = *reinterpret_cast<D3DDispatchArguments*>( auto& args = *reinterpret_cast<D3DDispatchArguments*>(
WriteCommand(Command::kD3DDispatch, sizeof(D3DDispatchArguments))); WriteCommand(Command::kD3DDispatch, sizeof(D3DDispatchArguments)));
@ -102,9 +102,8 @@ class DeferredCommandList {
args.thread_group_count_z = thread_group_count_z; args.thread_group_count_z = thread_group_count_z;
} }
inline void D3DDrawIndexedInstanced(UINT index_count_per_instance, void D3DDrawIndexedInstanced(UINT index_count_per_instance,
UINT instance_count, UINT instance_count, UINT start_index_location,
UINT start_index_location,
INT base_vertex_location, INT base_vertex_location,
UINT start_instance_location) { UINT start_instance_location) {
auto& args = *reinterpret_cast<D3DDrawIndexedInstancedArguments*>( auto& args = *reinterpret_cast<D3DDrawIndexedInstancedArguments*>(
@ -117,8 +116,8 @@ class DeferredCommandList {
args.start_instance_location = start_instance_location; args.start_instance_location = start_instance_location;
} }
inline void D3DDrawInstanced(UINT vertex_count_per_instance, void D3DDrawInstanced(UINT vertex_count_per_instance, UINT instance_count,
UINT instance_count, UINT start_vertex_location, UINT start_vertex_location,
UINT start_instance_location) { UINT start_instance_location) {
auto& args = *reinterpret_cast<D3DDrawInstancedArguments*>(WriteCommand( auto& args = *reinterpret_cast<D3DDrawInstancedArguments*>(WriteCommand(
Command::kD3DDrawInstanced, sizeof(D3DDrawInstancedArguments))); Command::kD3DDrawInstanced, sizeof(D3DDrawInstancedArguments)));
@ -128,7 +127,7 @@ class DeferredCommandList {
args.start_instance_location = start_instance_location; args.start_instance_location = start_instance_location;
} }
inline void D3DIASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW* view) { void D3DIASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW* view) {
auto& args = *reinterpret_cast<D3D12_INDEX_BUFFER_VIEW*>(WriteCommand( auto& args = *reinterpret_cast<D3D12_INDEX_BUFFER_VIEW*>(WriteCommand(
Command::kD3DIASetIndexBuffer, sizeof(D3D12_INDEX_BUFFER_VIEW))); Command::kD3DIASetIndexBuffer, sizeof(D3D12_INDEX_BUFFER_VIEW)));
if (view != nullptr) { if (view != nullptr) {
@ -142,14 +141,13 @@ class DeferredCommandList {
} }
} }
inline void D3DIASetPrimitiveTopology( void D3DIASetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY primitive_topology) {
D3D12_PRIMITIVE_TOPOLOGY primitive_topology) {
auto& arg = *reinterpret_cast<D3D12_PRIMITIVE_TOPOLOGY*>(WriteCommand( auto& arg = *reinterpret_cast<D3D12_PRIMITIVE_TOPOLOGY*>(WriteCommand(
Command::kD3DIASetPrimitiveTopology, sizeof(D3D12_PRIMITIVE_TOPOLOGY))); Command::kD3DIASetPrimitiveTopology, sizeof(D3D12_PRIMITIVE_TOPOLOGY)));
arg = primitive_topology; arg = primitive_topology;
} }
inline void D3DOMSetBlendFactor(const FLOAT blend_factor[4]) { void D3DOMSetBlendFactor(const FLOAT blend_factor[4]) {
auto args = reinterpret_cast<FLOAT*>( auto args = reinterpret_cast<FLOAT*>(
WriteCommand(Command::kD3DOMSetBlendFactor, 4 * sizeof(FLOAT))); WriteCommand(Command::kD3DOMSetBlendFactor, 4 * sizeof(FLOAT)));
args[0] = blend_factor[0]; args[0] = blend_factor[0];
@ -158,7 +156,7 @@ class DeferredCommandList {
args[3] = blend_factor[3]; args[3] = blend_factor[3];
} }
inline void D3DOMSetRenderTargets( void D3DOMSetRenderTargets(
UINT num_render_target_descriptors, UINT num_render_target_descriptors,
const D3D12_CPU_DESCRIPTOR_HANDLE* render_target_descriptors, const D3D12_CPU_DESCRIPTOR_HANDLE* render_target_descriptors,
BOOL rts_single_handle_to_descriptor_range, BOOL rts_single_handle_to_descriptor_range,
@ -185,13 +183,13 @@ class DeferredCommandList {
} }
} }
inline void D3DOMSetStencilRef(UINT stencil_ref) { void D3DOMSetStencilRef(UINT stencil_ref) {
auto& arg = *reinterpret_cast<UINT*>( auto& arg = *reinterpret_cast<UINT*>(
WriteCommand(Command::kD3DOMSetStencilRef, sizeof(UINT))); WriteCommand(Command::kD3DOMSetStencilRef, sizeof(UINT)));
arg = stencil_ref; arg = stencil_ref;
} }
inline void D3DResourceBarrier(UINT num_barriers, void D3DResourceBarrier(UINT num_barriers,
const D3D12_RESOURCE_BARRIER* barriers) { const D3D12_RESOURCE_BARRIER* barriers) {
if (num_barriers == 0) { if (num_barriers == 0) {
return; return;
@ -207,21 +205,22 @@ class DeferredCommandList {
num_barriers * sizeof(D3D12_RESOURCE_BARRIER)); num_barriers * sizeof(D3D12_RESOURCE_BARRIER));
} }
inline void RSSetScissorRect(const D3D12_RECT& rect) { void RSSetScissorRect(const D3D12_RECT& rect) {
auto& arg = *reinterpret_cast<D3D12_RECT*>( auto& arg = *reinterpret_cast<D3D12_RECT*>(
WriteCommand(Command::kRSSetScissorRect, sizeof(D3D12_RECT))); WriteCommand(Command::kRSSetScissorRect, sizeof(D3D12_RECT)));
arg = rect; arg = rect;
} }
inline void RSSetViewport(const D3D12_VIEWPORT& viewport) { void RSSetViewport(const D3D12_VIEWPORT& viewport) {
auto& arg = *reinterpret_cast<D3D12_VIEWPORT*>( auto& arg = *reinterpret_cast<D3D12_VIEWPORT*>(
WriteCommand(Command::kRSSetViewport, sizeof(D3D12_VIEWPORT))); WriteCommand(Command::kRSSetViewport, sizeof(D3D12_VIEWPORT)));
arg = viewport; arg = viewport;
} }
inline void D3DSetComputeRoot32BitConstants( void D3DSetComputeRoot32BitConstants(UINT root_parameter_index,
UINT root_parameter_index, UINT num_32bit_values_to_set, UINT num_32bit_values_to_set,
const void* src_data, UINT dest_offset_in_32bit_values) { const void* src_data,
UINT dest_offset_in_32bit_values) {
if (num_32bit_values_to_set == 0) { if (num_32bit_values_to_set == 0) {
return; return;
} }
@ -235,9 +234,10 @@ class DeferredCommandList {
std::memcpy(args + 1, src_data, num_32bit_values_to_set * sizeof(uint32_t)); std::memcpy(args + 1, src_data, num_32bit_values_to_set * sizeof(uint32_t));
} }
inline void D3DSetGraphicsRoot32BitConstants( void D3DSetGraphicsRoot32BitConstants(UINT root_parameter_index,
UINT root_parameter_index, UINT num_32bit_values_to_set, UINT num_32bit_values_to_set,
const void* src_data, UINT dest_offset_in_32bit_values) { const void* src_data,
UINT dest_offset_in_32bit_values) {
if (num_32bit_values_to_set == 0) { if (num_32bit_values_to_set == 0) {
return; return;
} }
@ -251,7 +251,7 @@ class DeferredCommandList {
std::memcpy(args + 1, src_data, num_32bit_values_to_set * sizeof(uint32_t)); std::memcpy(args + 1, src_data, num_32bit_values_to_set * sizeof(uint32_t));
} }
inline void D3DSetComputeRootConstantBufferView( void D3DSetComputeRootConstantBufferView(
UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) { UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) {
auto& args = *reinterpret_cast<SetRootConstantBufferViewArguments*>( auto& args = *reinterpret_cast<SetRootConstantBufferViewArguments*>(
WriteCommand(Command::kD3DSetComputeRootConstantBufferView, WriteCommand(Command::kD3DSetComputeRootConstantBufferView,
@ -260,7 +260,7 @@ class DeferredCommandList {
args.buffer_location = buffer_location; args.buffer_location = buffer_location;
} }
inline void D3DSetGraphicsRootConstantBufferView( void D3DSetGraphicsRootConstantBufferView(
UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) { UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS buffer_location) {
auto& args = *reinterpret_cast<SetRootConstantBufferViewArguments*>( auto& args = *reinterpret_cast<SetRootConstantBufferViewArguments*>(
WriteCommand(Command::kD3DSetGraphicsRootConstantBufferView, WriteCommand(Command::kD3DSetGraphicsRootConstantBufferView,
@ -269,7 +269,7 @@ class DeferredCommandList {
args.buffer_location = buffer_location; args.buffer_location = buffer_location;
} }
inline void D3DSetComputeRootDescriptorTable( void D3DSetComputeRootDescriptorTable(
UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) { UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) {
auto& args = *reinterpret_cast<SetRootDescriptorTableArguments*>( auto& args = *reinterpret_cast<SetRootDescriptorTableArguments*>(
WriteCommand(Command::kD3DSetComputeRootDescriptorTable, WriteCommand(Command::kD3DSetComputeRootDescriptorTable,
@ -278,7 +278,7 @@ class DeferredCommandList {
args.base_descriptor.ptr = base_descriptor.ptr; args.base_descriptor.ptr = base_descriptor.ptr;
} }
inline void D3DSetGraphicsRootDescriptorTable( void D3DSetGraphicsRootDescriptorTable(
UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) { UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor) {
auto& args = *reinterpret_cast<SetRootDescriptorTableArguments*>( auto& args = *reinterpret_cast<SetRootDescriptorTableArguments*>(
WriteCommand(Command::kD3DSetGraphicsRootDescriptorTable, WriteCommand(Command::kD3DSetGraphicsRootDescriptorTable,
@ -287,20 +287,19 @@ class DeferredCommandList {
args.base_descriptor.ptr = base_descriptor.ptr; args.base_descriptor.ptr = base_descriptor.ptr;
} }
inline void D3DSetComputeRootSignature(ID3D12RootSignature* root_signature) { void D3DSetComputeRootSignature(ID3D12RootSignature* root_signature) {
auto& arg = *reinterpret_cast<ID3D12RootSignature**>(WriteCommand( auto& arg = *reinterpret_cast<ID3D12RootSignature**>(WriteCommand(
Command::kD3DSetComputeRootSignature, sizeof(ID3D12RootSignature*))); Command::kD3DSetComputeRootSignature, sizeof(ID3D12RootSignature*)));
arg = root_signature; arg = root_signature;
} }
inline void D3DSetGraphicsRootSignature(ID3D12RootSignature* root_signature) { void D3DSetGraphicsRootSignature(ID3D12RootSignature* root_signature) {
auto& arg = *reinterpret_cast<ID3D12RootSignature**>(WriteCommand( auto& arg = *reinterpret_cast<ID3D12RootSignature**>(WriteCommand(
Command::kD3DSetGraphicsRootSignature, sizeof(ID3D12RootSignature*))); Command::kD3DSetGraphicsRootSignature, sizeof(ID3D12RootSignature*)));
arg = root_signature; arg = root_signature;
} }
inline void SetDescriptorHeaps( void SetDescriptorHeaps(ID3D12DescriptorHeap* cbv_srv_uav_descriptor_heap,
ID3D12DescriptorHeap* cbv_srv_uav_descriptor_heap,
ID3D12DescriptorHeap* sampler_descriptor_heap) { ID3D12DescriptorHeap* sampler_descriptor_heap) {
auto& args = *reinterpret_cast<SetDescriptorHeapsArguments*>(WriteCommand( auto& args = *reinterpret_cast<SetDescriptorHeapsArguments*>(WriteCommand(
Command::kSetDescriptorHeaps, sizeof(SetDescriptorHeapsArguments))); Command::kSetDescriptorHeaps, sizeof(SetDescriptorHeapsArguments)));
@ -308,20 +307,19 @@ class DeferredCommandList {
args.sampler_descriptor_heap = sampler_descriptor_heap; args.sampler_descriptor_heap = sampler_descriptor_heap;
} }
inline void D3DSetPipelineState(ID3D12PipelineState* pipeline_state) { void D3DSetPipelineState(ID3D12PipelineState* pipeline_state) {
auto& arg = *reinterpret_cast<ID3D12PipelineState**>(WriteCommand( auto& arg = *reinterpret_cast<ID3D12PipelineState**>(WriteCommand(
Command::kD3DSetPipelineState, sizeof(ID3D12PipelineState*))); Command::kD3DSetPipelineState, sizeof(ID3D12PipelineState*)));
arg = pipeline_state; arg = pipeline_state;
} }
inline void SetPipelineStateHandle(void* pipeline_state_handle) { void SetPipelineStateHandle(void* pipeline_state_handle) {
auto& arg = *reinterpret_cast<void**>( auto& arg = *reinterpret_cast<void**>(
WriteCommand(Command::kSetPipelineStateHandle, sizeof(void*))); WriteCommand(Command::kSetPipelineStateHandle, sizeof(void*)));
arg = pipeline_state_handle; arg = pipeline_state_handle;
} }
inline void D3DSetSamplePositions( void D3DSetSamplePositions(UINT num_samples_per_pixel, UINT num_pixels,
UINT num_samples_per_pixel, UINT num_pixels,
const D3D12_SAMPLE_POSITION* sample_positions) { const D3D12_SAMPLE_POSITION* sample_positions) {
auto& args = *reinterpret_cast<D3DSetSamplePositionsArguments*>( auto& args = *reinterpret_cast<D3DSetSamplePositionsArguments*>(
WriteCommand(Command::kD3DSetSamplePositions, WriteCommand(Command::kD3DSetSamplePositions,

View File

@ -78,7 +78,7 @@ class PipelineCache {
// Returns a pipeline with deferred creation by its handle. May return nullptr // Returns a pipeline with deferred creation by its handle. May return nullptr
// if failed to create the pipeline. // if failed to create the pipeline.
inline ID3D12PipelineState* GetD3D12PipelineByHandle(void* handle) const { ID3D12PipelineState* GetD3D12PipelineByHandle(void* handle) const {
return reinterpret_cast<const Pipeline*>(handle)->state; return reinterpret_cast<const Pipeline*>(handle)->state;
} }

View File

@ -303,8 +303,7 @@ class RenderTargetCache {
// performance difference, but with EDRAM loads/stores less conversion should // performance difference, but with EDRAM loads/stores less conversion should
// be performed by the shaders if D24S8 is emulated as D24_UNORM_S8_UINT, and // be performed by the shaders if D24S8 is emulated as D24_UNORM_S8_UINT, and
// it's probably more accurate. // it's probably more accurate.
static inline DXGI_FORMAT GetDepthDXGIFormat( static DXGI_FORMAT GetDepthDXGIFormat(xenos::DepthRenderTargetFormat format) {
xenos::DepthRenderTargetFormat format) {
return format == xenos::DepthRenderTargetFormat::kD24FS8 return format == xenos::DepthRenderTargetFormat::kD24FS8
? DXGI_FORMAT_D32_FLOAT_S8X24_UINT ? DXGI_FORMAT_D32_FLOAT_S8X24_UINT
: DXGI_FORMAT_D24_UNORM_S8_UINT; : DXGI_FORMAT_D24_UNORM_S8_UINT;

View File

@ -106,18 +106,18 @@ class TextureCache {
bool operator!=(const TextureKey& key) const { bool operator!=(const TextureKey& key) const {
return GetMapKey() != key.GetMapKey() || bucket_key != key.bucket_key; return GetMapKey() != key.GetMapKey() || bucket_key != key.bucket_key;
} }
inline uint64_t GetMapKey() const { uint64_t GetMapKey() const {
return uint64_t(map_key[0]) | (uint64_t(map_key[1]) << 32); return uint64_t(map_key[0]) | (uint64_t(map_key[1]) << 32);
} }
inline void SetMapKey(uint64_t key) { void SetMapKey(uint64_t key) {
map_key[0] = uint32_t(key); map_key[0] = uint32_t(key);
map_key[1] = uint32_t(key >> 32); map_key[1] = uint32_t(key >> 32);
} }
inline bool IsInvalid() const { bool IsInvalid() const {
// Zero base and zero width is enough for a binding to be invalid. // Zero base and zero width is enough for a binding to be invalid.
return map_key[0] == 0; return map_key[0] == 0;
} }
inline void MakeInvalid() { void MakeInvalid() {
// Reset all for a stable hash. // Reset all for a stable hash.
SetMapKey(0); SetMapKey(0);
bucket_key = 0; bucket_key = 0;
@ -222,9 +222,7 @@ class TextureCache {
void MarkRangeAsResolved(uint32_t start_unscaled, uint32_t length_unscaled); void MarkRangeAsResolved(uint32_t start_unscaled, uint32_t length_unscaled);
inline bool IsResolutionScale2X() const { bool IsResolutionScale2X() const { return scaled_resolve_buffer_ != nullptr; }
return scaled_resolve_buffer_ != nullptr;
}
ID3D12Resource* GetScaledResolveBuffer() const { ID3D12Resource* GetScaledResolveBuffer() const {
return scaled_resolve_buffer_; return scaled_resolve_buffer_;
} }
@ -233,7 +231,7 @@ class TextureCache {
uint32_t length_unscaled); uint32_t length_unscaled);
void UseScaledResolveBufferForReading(); void UseScaledResolveBufferForReading();
void UseScaledResolveBufferForWriting(); void UseScaledResolveBufferForWriting();
inline void MarkScaledResolveBufferUAVWritesCommitNeeded() { void MarkScaledResolveBufferUAVWritesCommitNeeded() {
if (scaled_resolve_buffer_state_ == D3D12_RESOURCE_STATE_UNORDERED_ACCESS) { if (scaled_resolve_buffer_state_ == D3D12_RESOURCE_STATE_UNORDERED_ACCESS) {
scaled_resolve_buffer_uav_writes_commit_needed_ = true; scaled_resolve_buffer_uav_writes_commit_needed_ = true;
} }
@ -432,7 +430,7 @@ class TextureCache {
// Whether the signed version of the texture has a different representation on // Whether the signed version of the texture has a different representation on
// the host than its unsigned version (for example, if it's a fixed-point // the host than its unsigned version (for example, if it's a fixed-point
// texture emulated with a larger host pixel format). // texture emulated with a larger host pixel format).
static inline bool IsSignedVersionSeparate(xenos::TextureFormat format) { static bool IsSignedVersionSeparate(xenos::TextureFormat format) {
const HostFormat& host_format = host_formats_[uint32_t(format)]; const HostFormat& host_format = host_formats_[uint32_t(format)];
return host_format.load_mode_snorm != LoadMode::kUnknown && return host_format.load_mode_snorm != LoadMode::kUnknown &&
host_format.load_mode_snorm != host_format.load_mode; host_format.load_mode_snorm != host_format.load_mode;
@ -441,26 +439,24 @@ class TextureCache {
// of block-compressed textures with 4x4-aligned dimensions on PC). // of block-compressed textures with 4x4-aligned dimensions on PC).
static bool IsDecompressionNeeded(xenos::TextureFormat format, uint32_t width, static bool IsDecompressionNeeded(xenos::TextureFormat format, uint32_t width,
uint32_t height); uint32_t height);
static inline DXGI_FORMAT GetDXGIResourceFormat(xenos::TextureFormat format, static DXGI_FORMAT GetDXGIResourceFormat(xenos::TextureFormat format,
uint32_t width, uint32_t width, uint32_t height) {
uint32_t height) {
const HostFormat& host_format = host_formats_[uint32_t(format)]; const HostFormat& host_format = host_formats_[uint32_t(format)];
return IsDecompressionNeeded(format, width, height) return IsDecompressionNeeded(format, width, height)
? host_format.dxgi_format_uncompressed ? host_format.dxgi_format_uncompressed
: host_format.dxgi_format_resource; : host_format.dxgi_format_resource;
} }
static inline DXGI_FORMAT GetDXGIResourceFormat(TextureKey key) { static DXGI_FORMAT GetDXGIResourceFormat(TextureKey key) {
return GetDXGIResourceFormat(key.format, key.width, key.height); return GetDXGIResourceFormat(key.format, key.width, key.height);
} }
static inline DXGI_FORMAT GetDXGIUnormFormat(xenos::TextureFormat format, static DXGI_FORMAT GetDXGIUnormFormat(xenos::TextureFormat format,
uint32_t width, uint32_t width, uint32_t height) {
uint32_t height) {
const HostFormat& host_format = host_formats_[uint32_t(format)]; const HostFormat& host_format = host_formats_[uint32_t(format)];
return IsDecompressionNeeded(format, width, height) return IsDecompressionNeeded(format, width, height)
? host_format.dxgi_format_uncompressed ? host_format.dxgi_format_uncompressed
: host_format.dxgi_format_unorm; : host_format.dxgi_format_unorm;
} }
static inline DXGI_FORMAT GetDXGIUnormFormat(TextureKey key) { static DXGI_FORMAT GetDXGIUnormFormat(TextureKey key) {
return GetDXGIUnormFormat(key.format, key.width, key.height); return GetDXGIUnormFormat(key.format, key.width, key.height);
} }

View File

@ -46,22 +46,22 @@ class D3D12Provider : public GraphicsProvider {
uint32_t GetRTVDescriptorSize() const { return descriptor_size_rtv_; } uint32_t GetRTVDescriptorSize() const { return descriptor_size_rtv_; }
uint32_t GetDSVDescriptorSize() const { return descriptor_size_dsv_; } uint32_t GetDSVDescriptorSize() const { return descriptor_size_dsv_; }
template <typename T> template <typename T>
inline T OffsetViewDescriptor(T start, uint32_t index) const { T OffsetViewDescriptor(T start, uint32_t index) const {
start.ptr += index * descriptor_size_view_; start.ptr += index * descriptor_size_view_;
return start; return start;
} }
template <typename T> template <typename T>
inline T OffsetSamplerDescriptor(T start, uint32_t index) const { T OffsetSamplerDescriptor(T start, uint32_t index) const {
start.ptr += index * descriptor_size_sampler_; start.ptr += index * descriptor_size_sampler_;
return start; return start;
} }
template <typename T> template <typename T>
inline T OffsetRTVDescriptor(T start, uint32_t index) const { T OffsetRTVDescriptor(T start, uint32_t index) const {
start.ptr += index * descriptor_size_rtv_; start.ptr += index * descriptor_size_rtv_;
return start; return start;
} }
template <typename T> template <typename T>
inline T OffsetDSVDescriptor(T start, uint32_t index) const { T OffsetDSVDescriptor(T start, uint32_t index) const {
start.ptr += index * descriptor_size_dsv_; start.ptr += index * descriptor_size_dsv_;
return start; return start;
} }
@ -91,31 +91,29 @@ class D3D12Provider : public GraphicsProvider {
} }
// Proxies for Direct3D 12 functions since they are loaded dynamically. // Proxies for Direct3D 12 functions since they are loaded dynamically.
inline HRESULT SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC* desc, HRESULT SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC* desc,
D3D_ROOT_SIGNATURE_VERSION version, D3D_ROOT_SIGNATURE_VERSION version,
ID3DBlob** blob_out, ID3DBlob** blob_out,
ID3DBlob** error_blob_out) const { ID3DBlob** error_blob_out) const {
return pfn_d3d12_serialize_root_signature_(desc, version, blob_out, return pfn_d3d12_serialize_root_signature_(desc, version, blob_out,
error_blob_out); error_blob_out);
} }
inline HRESULT Disassemble(const void* src_data, size_t src_data_size, HRESULT Disassemble(const void* src_data, size_t src_data_size, UINT flags,
UINT flags, const char* comments, const char* comments, ID3DBlob** disassembly_out) const {
ID3DBlob** disassembly_out) const {
if (!pfn_d3d_disassemble_) { if (!pfn_d3d_disassemble_) {
return E_NOINTERFACE; return E_NOINTERFACE;
} }
return pfn_d3d_disassemble_(src_data, src_data_size, flags, comments, return pfn_d3d_disassemble_(src_data, src_data_size, flags, comments,
disassembly_out); disassembly_out);
} }
inline HRESULT DxbcConverterCreateInstance(const CLSID& rclsid, HRESULT DxbcConverterCreateInstance(const CLSID& rclsid, const IID& riid,
const IID& riid,
void** ppv) const { void** ppv) const {
if (!pfn_dxilconv_dxc_create_instance_) { if (!pfn_dxilconv_dxc_create_instance_) {
return E_NOINTERFACE; return E_NOINTERFACE;
} }
return pfn_dxilconv_dxc_create_instance_(rclsid, riid, ppv); return pfn_dxilconv_dxc_create_instance_(rclsid, riid, ppv);
} }
inline HRESULT DxcCreateInstance(const CLSID& rclsid, const IID& riid, HRESULT DxcCreateInstance(const CLSID& rclsid, const IID& riid,
void** ppv) const { void** ppv) const {
if (!pfn_dxcompiler_dxc_create_instance_) { if (!pfn_dxcompiler_dxc_create_instance_) {
return E_NOINTERFACE; return E_NOINTERFACE;

View File

@ -27,7 +27,7 @@ extern const D3D12_HEAP_PROPERTIES kHeapPropertiesUpload;
extern const D3D12_HEAP_PROPERTIES kHeapPropertiesReadback; extern const D3D12_HEAP_PROPERTIES kHeapPropertiesReadback;
template <typename T> template <typename T>
inline bool ReleaseAndNull(T& object) { bool ReleaseAndNull(T& object) {
if (object != nullptr) { if (object != nullptr) {
object->Release(); object->Release();
object = nullptr; object = nullptr;