use Sleep(0) instead of SwitchToThread, should waste less power and help the os with scheduling.
PM4 buffer handling made a virtual member of commandprocessor, place the implementation/declaration into reusable macro files. this is probably the biggest boost here. Optimized SET_CONSTANT/ LOAD_CONSTANT pm4 ops based on the register range they start writing at, this was also a nice boost Expose X64 extension flags to code outside of x64 backend, so we can detect and use things like avx512, xop, avx2, etc in normal code Add freelists for HIR structures to try to reduce the number of last level cache misses during optimization (currently disabled... fixme later) Analyzed PGO feedback and reordered branches, uninlined functions, moved code out into different functions based on info from it in the PM4 functions, this gave like a 2% boost at best. Added support for the db16cyc opcode, which is used often in xb360 spinlocks. before it was just being translated to nop, now on x64 we translate it to _mm_pause but may change that in the future to reduce cpu time wasted texture util - all our divisors were powers of 2, instead we look up a shift. this made texture scaling slightly faster, more so on intel processors which seem to be worse at int divs. GetGuestTextureLayout is now a little faster, although it is still one of the heaviest functions in the emulator when scaling is on. xe_unlikely_mutex was not a good choice for the guest clock lock, (running theory) on intel processors another thread may take a significant time to update the clock? maybe because of the uint64 division? really not sure, but switched it to xe_mutex. This fixed audio stutter that i had introduced to 1 or 2 games, fixed performance on that n64 rare game with the monkeys. Took another crack at DMA implementation, another failure. Instead of passing as a parameter, keep the ringbuffer reader as the first member of commandprocessor so it can be accessed through this Added macro for noalias Applied noalias to Memory::LookupHeap. This reduced the size of the executable by 7 kb. Reworked kernel shim template, this shaved like 100kb off the exe and eliminated the indirect calls from the shim to the actual implementation. We still unconditionally generate string representations of kernel calls though :(, unless it is kHighFrequency Add nvapi extensions support, currently unused. Will use CPUVISIBLE memory at some point Inserted prefetches in a few places based on feedback from vtune. Add native implementation of SHA int8 if all elements are the same Vectorized comparisons for SetViewport, SetScissorRect Vectorized ranged comparisons for WriteRegister Add XE_MSVC_ASSUME Move FormatInfo::name out of the structure, instead look up the name in a different table. Debug related data and critical runtime data are best kept apart Templated UpdateSystemConstantValues based on ROV/RTV and primitive_polygonal Add ArchFloatMask functions, these are for storing the results of floating point comparisons without doing costly float->int pipeline transfers (vucomiss/setb) Use floatmasks in UpdateSystemConstantValues for checking if dirty, only transfer to int at end of function. Instead of dirty |= (x == y) in UpdateSystemConstantValues, now we do dirty_u32 |= (x^y). if any of them are not equal, dirty_u32 will be nz, else if theyre all equal it will be zero. This is more friendly to register renaming and the lack of dependencies on EFLAGS lets the compiler reorder better Add PrefetchSamplerParameters to D3D12TextureCache use PrefetchSamplerParameters in UpdateBindings to eliminate cache misses that vtune detected Add PrefetchTextureBinding to D3D12TextureCache Prefetch texture bindings to get rid of more misses vtune detected (more accesses out of order with random strides) Rewrote DMAC, still terrible though and have disabled it for now. Replace tiny memcmp of 6 U64 in render_target_cache with inline loop, msvc fails to make it a loop and instead does a thunk to their memcmp function, which is optimized for larger sizes PrefetchTextureBinding in AreActiveTextureSRVKeysUpToDate Replace memcmp calls for pipelinedescription with handwritten cmp Directly write some registers that dont have special handling in PM4 functions Changed EstimateMaxY to try to eliminate mispredictions that vtune was reporting, msvc ended up turning the changed code into a series of blends in ExecutePacketType3_EVENT_WRITE_EXT, instead of writing extents to an array on the stack and then doing xe_copy_and_swap_16 of the data to its dest, pre-swap each constant and then store those. msvc manages to unroll that into wider stores stop logging XE_SWAP every time we receive XE_SWAP, stop logging the start and end of each viz query Prefetch watch nodes in FireWatches based on feedback from vtune Removed dead code from texture_info.cc NOINLINE on GpuSwap, PGO builds did it so we should too.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
/**
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
@@ -35,6 +36,7 @@
|
||||
#include "xenia/gpu/registers.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
#include "xenia/kernel/kernel_state.h"
|
||||
#include "xenia/kernel/user_module.h"
|
||||
#include "xenia/ui/d3d12/d3d12_descriptor_heap_pool.h"
|
||||
#include "xenia/ui/d3d12/d3d12_provider.h"
|
||||
#include "xenia/ui/d3d12/d3d12_upload_buffer_pool.h"
|
||||
@@ -46,6 +48,7 @@ namespace d3d12 {
|
||||
|
||||
class D3D12CommandProcessor final : public CommandProcessor {
|
||||
public:
|
||||
#include "../pm4_command_processor_declare.h"
|
||||
explicit D3D12CommandProcessor(D3D12GraphicsSystem* graphics_system,
|
||||
kernel::KernelState* kernel_state);
|
||||
~D3D12CommandProcessor();
|
||||
@@ -205,22 +208,70 @@ class D3D12CommandProcessor final : public CommandProcessor {
|
||||
protected:
|
||||
bool SetupContext() override;
|
||||
void ShutdownContext() override;
|
||||
XE_FORCEINLINE
|
||||
|
||||
void WriteRegister(uint32_t index, uint32_t value) override;
|
||||
XE_FORCEINLINE
|
||||
virtual void WriteRegistersFromMem(uint32_t start_index, uint32_t* base,
|
||||
uint32_t num_registers) override;
|
||||
|
||||
template <uint32_t register_lower_bound, uint32_t register_upper_bound>
|
||||
XE_FORCEINLINE void WriteRegisterRangeFromMem_WithKnownBound(
|
||||
uint32_t start_index, uint32_t* base, uint32_t num_registers);
|
||||
XE_FORCEINLINE
|
||||
virtual void WriteRegisterRangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_registers) override;
|
||||
template <uint32_t register_lower_bound, uint32_t register_upper_bound>
|
||||
XE_FORCEINLINE void WriteRegisterRangeFromRing_WithKnownBound(
|
||||
xe::RingBuffer* ring, uint32_t base, uint32_t num_registers);
|
||||
|
||||
XE_NOINLINE
|
||||
void WriteRegisterRangeFromRing_WraparoundCase(xe::RingBuffer* ring,
|
||||
uint32_t base,
|
||||
uint32_t num_registers);
|
||||
XE_FORCEINLINE
|
||||
virtual void WriteOneRegisterFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_registers);
|
||||
XE_NOINLINE
|
||||
virtual void WriteOneRegisterFromRing(uint32_t base,
|
||||
uint32_t num_times) override;
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteALURangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_times);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteFetchRangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_times);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteBoolRangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_times);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteLoopRangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_times);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteREGISTERSRangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_times);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteALURangeFromMem(uint32_t start_index, uint32_t* base,
|
||||
uint32_t num_registers);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteFetchRangeFromMem(uint32_t start_index, uint32_t* base,
|
||||
uint32_t num_registers);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteBoolRangeFromMem(uint32_t start_index, uint32_t* base,
|
||||
uint32_t num_registers);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteLoopRangeFromMem(uint32_t start_index, uint32_t* base,
|
||||
uint32_t num_registers);
|
||||
|
||||
XE_FORCEINLINE
|
||||
void WriteREGISTERSRangeFromMem(uint32_t start_index, uint32_t* base,
|
||||
uint32_t num_registers);
|
||||
|
||||
void OnGammaRamp256EntryTableValueWritten() override;
|
||||
void OnGammaRampPWLValueWritten() override;
|
||||
|
||||
@@ -367,6 +418,14 @@ class D3D12CommandProcessor final : public CommandProcessor {
|
||||
const draw_util::Scissor& scissor,
|
||||
bool primitive_polygonal,
|
||||
reg::RB_DEPTHCONTROL normalized_depth_control);
|
||||
|
||||
template <bool primitive_polygonal, bool edram_rov_used>
|
||||
XE_NOINLINE void UpdateSystemConstantValues_Impl(
|
||||
bool shared_memory_is_uav, uint32_t line_loop_closing_index,
|
||||
xenos::Endian index_endian, const draw_util::ViewportInfo& viewport_info,
|
||||
uint32_t used_texture_mask, reg::RB_DEPTHCONTROL normalized_depth_control,
|
||||
uint32_t normalized_color_mask);
|
||||
|
||||
void UpdateSystemConstantValues(bool shared_memory_is_uav,
|
||||
bool primitive_polygonal,
|
||||
uint32_t line_loop_closing_index,
|
||||
@@ -619,8 +678,8 @@ class D3D12CommandProcessor final : public CommandProcessor {
|
||||
uint32_t current_graphics_root_up_to_date_;
|
||||
|
||||
// System shader constants.
|
||||
alignas(XE_HOST_CACHE_LINE_SIZE)
|
||||
DxbcShaderTranslator::SystemConstants system_constants_;
|
||||
alignas(XE_HOST_CACHE_LINE_SIZE)
|
||||
DxbcShaderTranslator::SystemConstants system_constants_;
|
||||
|
||||
// Float constant usage masks of the last draw call.
|
||||
// chrispy: make sure accesses to these cant cross cacheline boundaries
|
||||
|
||||
122
src/xenia/gpu/d3d12/d3d12_nvapi.hpp
Normal file
122
src/xenia/gpu/d3d12/d3d12_nvapi.hpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
// requires windows.h
|
||||
#include <stdint.h>
|
||||
|
||||
namespace lightweight_nvapi {
|
||||
|
||||
using nvstatus_t = int;
|
||||
|
||||
using nvintfid_t = unsigned int;
|
||||
|
||||
#ifndef LIGHTWEIGHT_NVAPI_EXCLUDE_D3D12
|
||||
constexpr nvintfid_t id_NvAPI_D3D12_QueryCpuVisibleVidmem = 0x26322BC3;
|
||||
|
||||
using cb_NvAPI_D3D12_QueryCpuVisibleVidmem = nvstatus_t (*)(
|
||||
ID3D12Device* pDevice, uint64_t* pTotalBytes, uint64_t* pFreeBytes);
|
||||
|
||||
constexpr nvintfid_t id_NvAPI_D3D12_UseDriverHeapPriorities = 0xF0D978A8;
|
||||
using cb_NvAPI_D3D12_UseDriverHeapPriorities =
|
||||
nvstatus_t (*)(ID3D12Device* pDevice);
|
||||
enum NV_D3D12_RESOURCE_FLAGS {
|
||||
NV_D3D12_RESOURCE_FLAG_NONE = 0,
|
||||
NV_D3D12_RESOURCE_FLAG_HTEX = 1, //!< Create HTEX texture
|
||||
NV_D3D12_RESOURCE_FLAG_CPUVISIBLE_VIDMEM =
|
||||
2, //!< Hint to create resource in cpuvisible vidmem
|
||||
};
|
||||
|
||||
struct NV_RESOURCE_PARAMS {
|
||||
uint32_t version; //!< Version of structure. Must always be first member
|
||||
NV_D3D12_RESOURCE_FLAGS
|
||||
NVResourceFlags; //!< Additional NV specific flags (set the
|
||||
//!< NV_D3D12_RESOURCE_FLAG_HTEX bit to create HTEX
|
||||
//!< texture)
|
||||
};
|
||||
|
||||
using cb_NvAPI_D3D12_CreateCommittedResource = nvstatus_t (*)(
|
||||
ID3D12Device* pDevice, const D3D12_HEAP_PROPERTIES* pHeapProperties,
|
||||
D3D12_HEAP_FLAGS HeapFlags, const D3D12_RESOURCE_DESC* pDesc,
|
||||
D3D12_RESOURCE_STATES InitialState,
|
||||
const D3D12_CLEAR_VALUE* pOptimizedClearValue,
|
||||
const NV_RESOURCE_PARAMS* pNVResourceParams, REFIID riid,
|
||||
void** ppvResource, bool* pSupported);
|
||||
constexpr nvintfid_t id_NvAPI_D3D12_CreateCommittedResource = 0x27E98AEu;
|
||||
#endif
|
||||
class nvapi_state_t {
|
||||
HMODULE nvapi64_;
|
||||
void* (*queryinterface_)(unsigned int intfid);
|
||||
bool available_;
|
||||
bool init_ptrs();
|
||||
|
||||
bool call_init_interface();
|
||||
void call_deinit_interface();
|
||||
|
||||
public:
|
||||
nvapi_state_t() : nvapi64_(LoadLibraryA("nvapi64.dll")), available_(false) {
|
||||
available_ = init_ptrs();
|
||||
}
|
||||
~nvapi_state_t();
|
||||
template <typename T>
|
||||
T* query_interface(unsigned int intfid) {
|
||||
if (queryinterface_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<T*>(queryinterface_(intfid));
|
||||
}
|
||||
|
||||
bool is_available() const { return available_; }
|
||||
};
|
||||
inline bool nvapi_state_t::call_init_interface() {
|
||||
int result = -1;
|
||||
auto initInterfaceEx = query_interface<int(int)>(0xAD298D3F);
|
||||
if (!initInterfaceEx) {
|
||||
auto initInterface = query_interface<int()>(0x150E828u);
|
||||
if (initInterface) {
|
||||
result = initInterface();
|
||||
}
|
||||
} else {
|
||||
result = initInterfaceEx(0);
|
||||
}
|
||||
return result == 0;
|
||||
}
|
||||
inline void nvapi_state_t::call_deinit_interface() {
|
||||
auto deinitinterfaceex = query_interface<void(int)>(0xD7C61344);
|
||||
if (deinitinterfaceex) {
|
||||
deinitinterfaceex(1); // or 0? im not sure what the proper value is
|
||||
} else {
|
||||
auto deinitinterface = query_interface<void()>(0xD22BDD7E);
|
||||
if (deinitinterface) {
|
||||
deinitinterface();
|
||||
}
|
||||
}
|
||||
}
|
||||
inline bool nvapi_state_t::init_ptrs() {
|
||||
if (!nvapi64_) return false;
|
||||
queryinterface_ = reinterpret_cast<void* (*)(unsigned)>(
|
||||
GetProcAddress(nvapi64_, "nvapi_QueryInterface"));
|
||||
|
||||
if (!queryinterface_) {
|
||||
return false;
|
||||
}
|
||||
if (!call_init_interface()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
inline nvapi_state_t::~nvapi_state_t() {
|
||||
if (available_) {
|
||||
call_deinit_interface();
|
||||
}
|
||||
}
|
||||
inline void init_nvapi() {
|
||||
/// HMODULE moddy = LoadLibraryA("nvapi64.dll");
|
||||
|
||||
// FARPROC quif = GetProcAddress(moddy, "nvapi_QueryInterface");
|
||||
|
||||
nvapi_state_t nvapi{};
|
||||
|
||||
auto queryvisible = nvapi.query_interface<void>(0x26322BC3);
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace lightweight_nvapi
|
||||
@@ -108,12 +108,11 @@ bool D3D12PrimitiveProcessor::InitializeBuiltinIndexBuffer(
|
||||
size_bytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> upload_resource;
|
||||
if (FAILED(device->CreateCommittedResource(
|
||||
&ui::d3d12::util::kHeapPropertiesUpload,
|
||||
if (!provider.CreateUploadResource(
|
||||
provider.GetHeapFlagCreateNotZeroed(), &resource_desc,
|
||||
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
|
||||
IID_PPV_ARGS(&upload_resource)))) {
|
||||
D3D12_RESOURCE_STATE_GENERIC_READ, IID_PPV_ARGS(&upload_resource))) {
|
||||
XELOGE(
|
||||
"D3D12 primitive processor: Failed to create the built-in index "
|
||||
"buffer upload resource with {} bytes",
|
||||
|
||||
@@ -5492,11 +5492,19 @@ void D3D12RenderTargetCache::SetCommandListRenderTargets(
|
||||
}
|
||||
|
||||
// Bind the render targets.
|
||||
if (are_current_command_list_render_targets_valid_ &&
|
||||
std::memcmp(current_command_list_render_targets_,
|
||||
depth_and_color_render_targets,
|
||||
sizeof(current_command_list_render_targets_))) {
|
||||
are_current_command_list_render_targets_valid_ = false;
|
||||
if (are_current_command_list_render_targets_valid_) {
|
||||
// chrispy: the small memcmp doesnt get optimized by msvc
|
||||
|
||||
for (unsigned i = 0;
|
||||
i < sizeof(current_command_list_render_targets_) /
|
||||
sizeof(current_command_list_render_targets_[0]);
|
||||
++i) {
|
||||
if ((const void*)current_command_list_render_targets_[i] !=
|
||||
(const void*)depth_and_color_render_targets[i]) {
|
||||
are_current_command_list_render_targets_valid_ = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint32_t render_targets_are_srgb;
|
||||
if (gamma_render_target_as_srgb_) {
|
||||
|
||||
@@ -467,7 +467,7 @@ void D3D12TextureCache::EndFrame() {
|
||||
XELOGE("Unsupported texture formats used in the frame:");
|
||||
unsupported_header_written = true;
|
||||
}
|
||||
XELOGE("* {}{}{}{}", FormatInfo::Get(xenos::TextureFormat(i))->name,
|
||||
XELOGE("* {}{}{}{}", FormatInfo::GetName(xenos::TextureFormat(i)),
|
||||
unsupported_features & kUnsupportedResourceBit ? " resource" : "",
|
||||
unsupported_features & kUnsupportedUnormBit ? " unsigned" : "",
|
||||
unsupported_features & kUnsupportedSnormBit ? " signed" : "");
|
||||
@@ -523,12 +523,16 @@ void D3D12TextureCache::RequestTextures(uint32_t used_texture_mask) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// chrispy: optimize this further
|
||||
bool D3D12TextureCache::AreActiveTextureSRVKeysUpToDate(
|
||||
const TextureSRVKey* keys,
|
||||
const D3D12Shader::TextureBinding* host_shader_bindings,
|
||||
size_t host_shader_binding_count) const {
|
||||
for (size_t i = 0; i < host_shader_binding_count; ++i) {
|
||||
if (i + 8 < host_shader_binding_count) {
|
||||
PrefetchTextureBinding<swcache::PrefetchTag::Nontemporal>(
|
||||
host_shader_bindings[i + 8].fetch_constant);
|
||||
}
|
||||
const TextureSRVKey& key = keys[i];
|
||||
const TextureBinding* binding =
|
||||
GetValidTextureBinding(host_shader_bindings[i].fetch_constant);
|
||||
@@ -538,8 +542,9 @@ bool D3D12TextureCache::AreActiveTextureSRVKeysUpToDate(
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (key.key != binding->key || key.host_swizzle != binding->host_swizzle ||
|
||||
key.swizzled_signs != binding->swizzled_signs) {
|
||||
if ((key.key != binding->key) |
|
||||
(key.host_swizzle != binding->host_swizzle) |
|
||||
(key.swizzled_signs != binding->swizzled_signs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -666,8 +671,12 @@ uint32_t D3D12TextureCache::GetActiveTextureBindlessSRVIndex(
|
||||
}
|
||||
return descriptor_index;
|
||||
}
|
||||
|
||||
D3D12TextureCache::SamplerParameters D3D12TextureCache::GetSamplerParameters(
|
||||
void D3D12TextureCache::PrefetchSamplerParameters(
|
||||
const D3D12Shader::SamplerBinding& binding) const {
|
||||
swcache::PrefetchL1(®ister_file()[XE_GPU_REG_SHADER_CONSTANT_FETCH_00_0 +
|
||||
binding.fetch_constant * 6]);
|
||||
}
|
||||
D3D12TextureCache::SamplerParameters D3D12TextureCache::GetSamplerParameters(
|
||||
const D3D12Shader::SamplerBinding& binding) const {
|
||||
const auto& regs = register_file();
|
||||
const auto& fetch = regs.Get<xenos::xe_gpu_texture_fetch_t>(
|
||||
@@ -694,7 +703,7 @@ D3D12TextureCache::SamplerParameters D3D12TextureCache::GetSamplerParameters(
|
||||
nullptr, nullptr, nullptr,
|
||||
&mip_min_level, nullptr);
|
||||
parameters.mip_min_level = mip_min_level;
|
||||
|
||||
//high cache miss count here, prefetch fetch earlier
|
||||
// TODO(Triang3l): Disable filtering for texture formats not supporting it.
|
||||
xenos::AnisoFilter aniso_filter =
|
||||
binding.aniso_filter == xenos::AnisoFilter::kUseFetchConst
|
||||
|
||||
@@ -119,7 +119,8 @@ class D3D12TextureCache final : public TextureCache {
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE handle);
|
||||
uint32_t GetActiveTextureBindlessSRVIndex(
|
||||
const D3D12Shader::TextureBinding& host_shader_binding);
|
||||
|
||||
void PrefetchSamplerParameters(
|
||||
const D3D12Shader::SamplerBinding& binding) const;
|
||||
SamplerParameters GetSamplerParameters(
|
||||
const D3D12Shader::SamplerBinding& binding) const;
|
||||
void WriteSampler(SamplerParameters parameters,
|
||||
@@ -712,7 +713,7 @@ class D3D12TextureCache final : public TextureCache {
|
||||
}
|
||||
|
||||
LoadShaderIndex GetLoadShaderIndex(TextureKey key) const;
|
||||
|
||||
// chrispy: todo, can use simple branchless tests here
|
||||
static constexpr bool AreDimensionsCompatible(
|
||||
xenos::FetchOpDimension binding_dimension,
|
||||
xenos::DataDimension resource_dimension) {
|
||||
|
||||
@@ -1047,8 +1047,7 @@ bool PipelineCache::ConfigurePipeline(
|
||||
PipelineDescription& description = runtime_description.description;
|
||||
|
||||
if (current_pipeline_ != nullptr &&
|
||||
!std::memcmp(¤t_pipeline_->description.description, &description,
|
||||
sizeof(description))) {
|
||||
current_pipeline_->description.description == description) {
|
||||
*pipeline_handle_out = current_pipeline_;
|
||||
*root_signature_out = runtime_description.root_signature;
|
||||
return true;
|
||||
@@ -1059,8 +1058,7 @@ bool PipelineCache::ConfigurePipeline(
|
||||
auto found_range = pipelines_.equal_range(hash);
|
||||
for (auto it = found_range.first; it != found_range.second; ++it) {
|
||||
Pipeline* found_pipeline = it->second;
|
||||
if (!std::memcmp(&found_pipeline->description.description, &description,
|
||||
sizeof(description))) {
|
||||
if (found_pipeline->description.description == description) {
|
||||
current_pipeline_ = found_pipeline;
|
||||
*pipeline_handle_out = found_pipeline;
|
||||
*root_signature_out = found_pipeline->description.root_signature;
|
||||
|
||||
@@ -226,6 +226,7 @@ class PipelineCache {
|
||||
|
||||
PipelineRenderTarget render_targets[xenos::kMaxColorRenderTargets];
|
||||
|
||||
inline bool operator==(const PipelineDescription& other) const;
|
||||
static constexpr uint32_t kVersion = 0x20210425;
|
||||
});
|
||||
|
||||
@@ -424,7 +425,34 @@ class PipelineCache {
|
||||
size_t creation_threads_shutdown_from_ = SIZE_MAX;
|
||||
std::vector<std::unique_ptr<xe::threading::Thread>> creation_threads_;
|
||||
};
|
||||
inline bool PipelineCache::PipelineDescription::operator==(
|
||||
const PipelineDescription& other) const {
|
||||
constexpr size_t cmp_size = sizeof(PipelineDescription);
|
||||
#if XE_ARCH_AMD64 == 1
|
||||
if constexpr (cmp_size == 64) {
|
||||
if (vertex_shader_hash != other.vertex_shader_hash ||
|
||||
vertex_shader_modification != other.vertex_shader_modification) {
|
||||
return false;
|
||||
}
|
||||
const __m128i* thiz = (const __m128i*)this;
|
||||
const __m128i* thoze = (const __m128i*)&other;
|
||||
__m128i cmp32 =
|
||||
_mm_cmpeq_epi8(_mm_loadu_si128(thiz + 1), _mm_loadu_si128(thoze + 1));
|
||||
|
||||
cmp32 = _mm_and_si128(cmp32, _mm_cmpeq_epi8(_mm_loadu_si128(thiz + 2),
|
||||
_mm_loadu_si128(thoze + 2)));
|
||||
|
||||
cmp32 = _mm_and_si128(cmp32, _mm_cmpeq_epi8(_mm_loadu_si128(thiz + 3),
|
||||
_mm_loadu_si128(thoze + 3)));
|
||||
|
||||
return _mm_movemask_epi8(cmp32) == 0xFFFF;
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
return !memcmp(this, &other, cmp_size);
|
||||
}
|
||||
}
|
||||
} // namespace d3d12
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
Reference in New Issue
Block a user