Merge pull request #61 from chrisps/canary_experimental
performance improvements, kernel fixes, cpu accuracy improvements
This commit is contained in:
@@ -1710,7 +1710,60 @@ void D3D12CommandProcessor::WriteRegister(uint32_t index, uint32_t value) {
|
||||
}
|
||||
}
|
||||
}
|
||||
void D3D12CommandProcessor::WriteRegistersFromMem(uint32_t start_index,
|
||||
uint32_t* base,
|
||||
uint32_t num_registers) {
|
||||
for (uint32_t i = 0; i < num_registers; ++i) {
|
||||
uint32_t data = xe::load_and_swap<uint32_t>(base + i);
|
||||
D3D12CommandProcessor::WriteRegister(start_index + i, data);
|
||||
}
|
||||
}
|
||||
void D3D12CommandProcessor::WriteRegisterRangeFromRing(xe::RingBuffer* ring,
|
||||
uint32_t base,
|
||||
uint32_t num_registers) {
|
||||
// we already brought it into L2 earlier
|
||||
RingBuffer::ReadRange range =
|
||||
ring->BeginPrefetchedRead<swcache::PrefetchTag::Level1>(num_registers *
|
||||
sizeof(uint32_t));
|
||||
|
||||
uint32_t num_regs_firstrange =
|
||||
static_cast<uint32_t>(range.first_length / sizeof(uint32_t));
|
||||
|
||||
D3D12CommandProcessor::WriteRegistersFromMem(
|
||||
base, reinterpret_cast<uint32_t*>(const_cast<uint8_t*>(range.first)),
|
||||
num_regs_firstrange);
|
||||
if (range.second) {
|
||||
D3D12CommandProcessor::WriteRegistersFromMem(
|
||||
base + num_regs_firstrange,
|
||||
reinterpret_cast<uint32_t*>(const_cast<uint8_t*>(range.second)),
|
||||
num_registers - num_regs_firstrange);
|
||||
}
|
||||
ring->EndRead(range);
|
||||
}
|
||||
void D3D12CommandProcessor::WriteOneRegisterFromRing(xe::RingBuffer* ring,
|
||||
uint32_t base,
|
||||
uint32_t num_times) {
|
||||
auto read = ring->BeginPrefetchedRead<swcache::PrefetchTag::Level1>(
|
||||
num_times * sizeof(uint32_t));
|
||||
|
||||
uint32_t first_length = read.first_length / sizeof(uint32_t);
|
||||
|
||||
for (uint32_t i = 0; i < first_length; ++i) {
|
||||
D3D12CommandProcessor::WriteRegister(
|
||||
base, xe::load_and_swap<uint32_t>(read.first + (sizeof(uint32_t) * i)));
|
||||
}
|
||||
|
||||
if (read.second) {
|
||||
uint32_t second_length = read.second_length / sizeof(uint32_t);
|
||||
|
||||
for (uint32_t i = 0; i < second_length; ++i) {
|
||||
D3D12CommandProcessor::WriteRegister(
|
||||
base,
|
||||
xe::load_and_swap<uint32_t>(read.second + (sizeof(uint32_t) * i)));
|
||||
}
|
||||
}
|
||||
ring->EndRead(read);
|
||||
}
|
||||
void D3D12CommandProcessor::OnGammaRamp256EntryTableValueWritten() {
|
||||
gamma_ramp_256_entry_table_up_to_date_ = false;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace xe {
|
||||
namespace gpu {
|
||||
namespace d3d12 {
|
||||
|
||||
class D3D12CommandProcessor : public CommandProcessor {
|
||||
class D3D12CommandProcessor final : public CommandProcessor {
|
||||
public:
|
||||
explicit D3D12CommandProcessor(D3D12GraphicsSystem* graphics_system,
|
||||
kernel::KernelState* kernel_state);
|
||||
@@ -203,9 +203,17 @@ class D3D12CommandProcessor : 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;
|
||||
XE_FORCEINLINE
|
||||
virtual void WriteRegisterRangeFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_registers) override;
|
||||
XE_FORCEINLINE
|
||||
virtual void WriteOneRegisterFromRing(xe::RingBuffer* ring, uint32_t base,
|
||||
uint32_t num_times) override;
|
||||
void OnGammaRamp256EntryTableValueWritten() override;
|
||||
void OnGammaRampPWLValueWritten() override;
|
||||
|
||||
|
||||
@@ -406,14 +406,16 @@ bool D3D12SharedMemory::AllocateSparseHostGpuMemoryRange(
|
||||
}
|
||||
|
||||
bool D3D12SharedMemory::UploadRanges(
|
||||
const std::vector<std::pair<uint32_t, uint32_t>>& upload_page_ranges) {
|
||||
if (upload_page_ranges.empty()) {
|
||||
const std::pair<uint32_t, uint32_t>* upload_page_ranges, unsigned num_upload_page_ranges) {
|
||||
if (!num_upload_page_ranges) {
|
||||
return true;
|
||||
}
|
||||
CommitUAVWritesAndTransitionBuffer(D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
command_processor_.SubmitBarriers();
|
||||
auto& command_list = command_processor_.GetDeferredCommandList();
|
||||
for (auto upload_range : upload_page_ranges) {
|
||||
//for (auto upload_range : upload_page_ranges) {
|
||||
for (unsigned int i = 0; i < num_upload_page_ranges; ++i) {
|
||||
auto& upload_range = upload_page_ranges[i];
|
||||
uint32_t upload_range_start = upload_range.first;
|
||||
uint32_t upload_range_length = upload_range.second;
|
||||
trace_writer_.WriteMemoryRead(upload_range_start << page_size_log2(),
|
||||
|
||||
@@ -91,8 +91,8 @@ class D3D12SharedMemory : public SharedMemory {
|
||||
bool AllocateSparseHostGpuMemoryRange(uint32_t offset_allocations,
|
||||
uint32_t length_allocations) override;
|
||||
|
||||
bool UploadRanges(const std::vector<std::pair<uint32_t, uint32_t>>&
|
||||
upload_page_ranges) override;
|
||||
bool UploadRanges(const std::pair<uint32_t, uint32_t>*
|
||||
upload_page_ranges, unsigned num_ranges) override;
|
||||
|
||||
private:
|
||||
D3D12CommandProcessor& command_processor_;
|
||||
|
||||
@@ -31,8 +31,8 @@ void DeferredCommandList::Execute(ID3D12GraphicsCommandList* command_list,
|
||||
#if XE_UI_D3D12_FINE_GRAINED_DRAW_SCOPES
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
#endif // XE_UI_D3D12_FINE_GRAINED_DRAW_SCOPES
|
||||
const uintmax_t* stream = command_stream_.data();
|
||||
size_t stream_remaining = command_stream_.size();
|
||||
const uintmax_t* stream = (const uintmax_t*)command_stream_.data();
|
||||
size_t stream_remaining = command_stream_.size() / sizeof(uintmax_t);
|
||||
ID3D12PipelineState* current_pipeline_state = nullptr;
|
||||
while (stream_remaining != 0) {
|
||||
const CommandHeader& header =
|
||||
@@ -266,8 +266,12 @@ void DeferredCommandList::Execute(ID3D12GraphicsCommandList* command_list,
|
||||
|
||||
void* DeferredCommandList::WriteCommand(Command command,
|
||||
size_t arguments_size_bytes) {
|
||||
|
||||
size_t arguments_size_elements =
|
||||
(arguments_size_bytes + sizeof(uintmax_t) - 1) / sizeof(uintmax_t);
|
||||
round_up(arguments_size_bytes, sizeof(uintmax_t), false);
|
||||
|
||||
//(arguments_size_bytes + sizeof(uintmax_t) - 1) / sizeof(uintmax_t);
|
||||
#if 0
|
||||
size_t offset = command_stream_.size();
|
||||
command_stream_.resize(offset + kCommandHeaderSizeElements +
|
||||
arguments_size_elements);
|
||||
@@ -276,6 +280,19 @@ void* DeferredCommandList::WriteCommand(Command command,
|
||||
header.command = command;
|
||||
header.arguments_size_elements = uint32_t(arguments_size_elements);
|
||||
return command_stream_.data() + (offset + kCommandHeaderSizeElements);
|
||||
#else
|
||||
|
||||
size_t offset = command_stream_.size();
|
||||
constexpr size_t kCommandHeaderSizeBytes =
|
||||
kCommandHeaderSizeElements * sizeof(uintmax_t);
|
||||
command_stream_.resize(offset + kCommandHeaderSizeBytes +
|
||||
arguments_size_elements);
|
||||
CommandHeader& header =
|
||||
*reinterpret_cast<CommandHeader*>(command_stream_.data() + offset);
|
||||
header.command = command;
|
||||
header.arguments_size_elements = uint32_t(arguments_size_elements) / sizeof(uintmax_t);
|
||||
return command_stream_.data() + (offset + kCommandHeaderSizeBytes);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace d3d12
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "xenia/base/literals.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/ui/d3d12/d3d12_api.h"
|
||||
|
||||
#include "xenia/base/memory.h"
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
namespace d3d12 {
|
||||
@@ -30,8 +30,12 @@ class D3D12CommandProcessor;
|
||||
|
||||
class DeferredCommandList {
|
||||
public:
|
||||
static constexpr size_t MAX_SIZEOF_COMMANDLIST = 65536 * 128; //around 8 mb
|
||||
/*
|
||||
chrispy: upped from 1_MiB to 4_MiB, m:durandal hits frequent resizes in large open maps
|
||||
*/
|
||||
DeferredCommandList(const D3D12CommandProcessor& command_processor,
|
||||
size_t initial_size_bytes = 1_MiB);
|
||||
size_t initial_size_bytes = MAX_SIZEOF_COMMANDLIST);
|
||||
|
||||
void Reset();
|
||||
void Execute(ID3D12GraphicsCommandList* command_list,
|
||||
@@ -562,7 +566,8 @@ class DeferredCommandList {
|
||||
const D3D12CommandProcessor& command_processor_;
|
||||
|
||||
// uintmax_t to ensure uint64_t and pointer alignment of all structures.
|
||||
std::vector<uintmax_t> command_stream_;
|
||||
//std::vector<uintmax_t> command_stream_;
|
||||
FixedVMemVector<MAX_SIZEOF_COMMANDLIST> command_stream_;
|
||||
};
|
||||
|
||||
} // namespace d3d12
|
||||
|
||||
Reference in New Issue
Block a user