Code cleanup: moving poly/ into xenia/base/
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "xenia/gpu/gl4/circular_buffer.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
|
||||
@@ -67,13 +67,13 @@ void CircularBuffer::Shutdown() {
|
||||
}
|
||||
|
||||
bool CircularBuffer::CanAcquire(size_t length) {
|
||||
size_t aligned_length = poly::round_up(length, alignment_);
|
||||
size_t aligned_length = xe::round_up(length, alignment_);
|
||||
return write_head_ + aligned_length <= capacity_;
|
||||
}
|
||||
|
||||
CircularBuffer::Allocation CircularBuffer::Acquire(size_t length) {
|
||||
// Addresses must always be % 256.
|
||||
size_t aligned_length = poly::round_up(length, alignment_);
|
||||
size_t aligned_length = xe::round_up(length, alignment_);
|
||||
assert_true(aligned_length <= capacity_, "Request too large");
|
||||
if (write_head_ + aligned_length > capacity_) {
|
||||
// Flush and wait.
|
||||
@@ -97,7 +97,7 @@ bool CircularBuffer::AcquireCached(uint32_t key, size_t length,
|
||||
auto& it = allocation_cache_.find(full_key);
|
||||
if (it != allocation_cache_.end()) {
|
||||
uintptr_t write_head = it->second;
|
||||
size_t aligned_length = poly::round_up(length, alignment_);
|
||||
size_t aligned_length = xe::round_up(length, alignment_);
|
||||
out_allocation->host_ptr = host_base_ + write_head;
|
||||
out_allocation->gpu_ptr = gpu_base_ + write_head;
|
||||
out_allocation->offset = write_head;
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/gpu/sampler_info.h"
|
||||
#include "xenia/gpu/texture_info.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
#include "third_party/xxhash/xxhash.h"
|
||||
@@ -100,7 +100,7 @@ bool CommandProcessor::Initialize(std::unique_ptr<GLContext> context) {
|
||||
|
||||
worker_running_ = true;
|
||||
worker_thread_ = std::thread([this]() {
|
||||
poly::threading::set_name("GL4 Worker");
|
||||
xe::threading::set_name("GL4 Worker");
|
||||
xe::Profiler::ThreadEnter("GL4 Worker");
|
||||
WorkerMain();
|
||||
xe::Profiler::ThreadExit();
|
||||
@@ -212,7 +212,7 @@ void CommandProcessor::WorkerMain() {
|
||||
// TODO(benvanik): use reader->Read_update_freq_ and only issue after moving
|
||||
// that many indices.
|
||||
if (read_ptr_writeback_ptr_) {
|
||||
poly::store_and_swap<uint32_t>(
|
||||
xe::store_and_swap<uint32_t>(
|
||||
memory_->TranslatePhysical(read_ptr_writeback_ptr_), read_ptr_index_);
|
||||
}
|
||||
}
|
||||
@@ -488,8 +488,7 @@ void CommandProcessor::WriteRegister(uint32_t index, uint32_t value) {
|
||||
// Enabled - write to address.
|
||||
uint32_t scratch_addr = regs->values[XE_GPU_REG_SCRATCH_ADDR].u32;
|
||||
uint32_t mem_addr = scratch_addr + (scratch_reg * 4);
|
||||
poly::store_and_swap<uint32_t>(memory_->TranslatePhysical(mem_addr),
|
||||
value);
|
||||
xe::store_and_swap<uint32_t>(memory_->TranslatePhysical(mem_addr), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -602,14 +601,14 @@ class CommandProcessor::RingbufferReader {
|
||||
uint32_t offset() const { return offset_; }
|
||||
bool can_read() const { return ptr_ != end_ptr_; }
|
||||
|
||||
uint32_t Peek() { return poly::load_and_swap<uint32_t>(membase_ + ptr_); }
|
||||
uint32_t Peek() { return xe::load_and_swap<uint32_t>(membase_ + ptr_); }
|
||||
|
||||
void CheckRead(uint32_t words) {
|
||||
assert_true(ptr_ + words * sizeof(uint32_t) <= end_ptr_);
|
||||
}
|
||||
|
||||
uint32_t Read() {
|
||||
uint32_t value = poly::load_and_swap<uint32_t>(membase_ + ptr_);
|
||||
uint32_t value = xe::load_and_swap<uint32_t>(membase_ + ptr_);
|
||||
Advance(1);
|
||||
return value;
|
||||
}
|
||||
@@ -992,7 +991,7 @@ bool CommandProcessor::ExecutePacketType3_WAIT_REG_MEM(RingbufferReader* reader,
|
||||
// Memory.
|
||||
auto endianness = static_cast<Endian>(poll_reg_addr & 0x3);
|
||||
poll_reg_addr &= ~0x3;
|
||||
value = poly::load<uint32_t>(memory_->TranslatePhysical(poll_reg_addr));
|
||||
value = xe::load<uint32_t>(memory_->TranslatePhysical(poll_reg_addr));
|
||||
value = GpuSwap(value, endianness);
|
||||
trace_writer_.WriteMemoryRead(poll_reg_addr, 4);
|
||||
} else {
|
||||
@@ -1095,7 +1094,7 @@ bool CommandProcessor::ExecutePacketType3_COND_WRITE(RingbufferReader* reader,
|
||||
auto endianness = static_cast<Endian>(poll_reg_addr & 0x3);
|
||||
poll_reg_addr &= ~0x3;
|
||||
trace_writer_.WriteMemoryRead(poll_reg_addr, 4);
|
||||
value = poly::load<uint32_t>(memory_->TranslatePhysical(poll_reg_addr));
|
||||
value = xe::load<uint32_t>(memory_->TranslatePhysical(poll_reg_addr));
|
||||
value = GpuSwap(value, endianness);
|
||||
} else {
|
||||
// Register.
|
||||
@@ -1136,7 +1135,7 @@ bool CommandProcessor::ExecutePacketType3_COND_WRITE(RingbufferReader* reader,
|
||||
auto endianness = static_cast<Endian>(write_reg_addr & 0x3);
|
||||
write_reg_addr &= ~0x3;
|
||||
write_data = GpuSwap(write_data, endianness);
|
||||
poly::store(memory_->TranslatePhysical(write_reg_addr), write_data);
|
||||
xe::store(memory_->TranslatePhysical(write_reg_addr), write_data);
|
||||
trace_writer_.WriteMemoryWrite(write_reg_addr, 4);
|
||||
} else {
|
||||
// Register.
|
||||
@@ -1182,7 +1181,7 @@ bool CommandProcessor::ExecutePacketType3_EVENT_WRITE_SHD(
|
||||
auto endianness = static_cast<Endian>(address & 0x3);
|
||||
address &= ~0x3;
|
||||
data_value = GpuSwap(data_value, endianness);
|
||||
poly::store(memory_->TranslatePhysical(address), data_value);
|
||||
xe::store(memory_->TranslatePhysical(address), data_value);
|
||||
trace_writer_.WriteMemoryWrite(address, 4);
|
||||
return true;
|
||||
}
|
||||
@@ -1206,9 +1205,9 @@ bool CommandProcessor::ExecutePacketType3_EVENT_WRITE_EXT(
|
||||
1, // max z
|
||||
};
|
||||
assert_true(endianness == xenos::Endian::k8in16);
|
||||
poly::copy_and_swap_16_aligned(
|
||||
xe::copy_and_swap_16_aligned(
|
||||
reinterpret_cast<uint16_t*>(memory_->TranslatePhysical(address)), extents,
|
||||
poly::countof(extents));
|
||||
xe::countof(extents));
|
||||
trace_writer_.WriteMemoryWrite(address, sizeof(extents));
|
||||
return true;
|
||||
}
|
||||
@@ -1367,7 +1366,7 @@ bool CommandProcessor::ExecutePacketType3_LOAD_ALU_CONSTANT(
|
||||
}
|
||||
trace_writer_.WriteMemoryRead(address, size_dwords * 4);
|
||||
for (uint32_t n = 0; n < size_dwords; n++, index++) {
|
||||
uint32_t data = poly::load_and_swap<uint32_t>(
|
||||
uint32_t data = xe::load_and_swap<uint32_t>(
|
||||
memory_->TranslatePhysical(address + n * 4));
|
||||
WriteRegister(index, data);
|
||||
}
|
||||
@@ -1626,7 +1625,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateShaders(
|
||||
if (!cached_pipeline->handles.default_pipeline) {
|
||||
// Perhaps it's a bit wasteful to do all of these, but oh well.
|
||||
GLuint pipelines[5];
|
||||
glCreateProgramPipelines(GLsizei(poly::countof(pipelines)), pipelines);
|
||||
glCreateProgramPipelines(GLsizei(xe::countof(pipelines)), pipelines);
|
||||
|
||||
glUseProgramStages(pipelines[0], GL_VERTEX_SHADER_BIT, vertex_program);
|
||||
glUseProgramStages(pipelines[0], GL_FRAGMENT_SHADER_BIT, fragment_program);
|
||||
@@ -1748,7 +1747,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRenderTargets() {
|
||||
regs.rb_color3_info,
|
||||
};
|
||||
// A2XX_RB_COLOR_MASK_WRITE_* == D3DRS_COLORWRITEENABLE
|
||||
for (int n = 0; n < poly::countof(color_info); n++) {
|
||||
for (int n = 0; n < xe::countof(color_info); n++) {
|
||||
uint32_t write_mask = (regs.rb_color_mask >> (n * 4)) & 0xF;
|
||||
if (!write_mask || !shader_targets[n]) {
|
||||
// Unused, so keep disabled and set to wildcard so we'll take any
|
||||
@@ -2133,7 +2132,7 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateBlendState() {
|
||||
/* 3 */ GL_MAX,
|
||||
/* 4 */ GL_FUNC_REVERSE_SUBTRACT,
|
||||
};
|
||||
for (int i = 0; i < poly::countof(regs.rb_blendcontrol); ++i) {
|
||||
for (int i = 0; i < xe::countof(regs.rb_blendcontrol); ++i) {
|
||||
uint32_t blend_control = regs.rb_blendcontrol[i];
|
||||
// A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND
|
||||
auto src_blend = blend_map[(blend_control & 0x0000001F) >> 0];
|
||||
@@ -2299,11 +2298,11 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateIndexBuffer() {
|
||||
if (info.format == IndexFormat::kInt32) {
|
||||
auto dest = reinterpret_cast<uint32_t*>(allocation.host_ptr);
|
||||
auto src = memory_->TranslatePhysical<const uint32_t*>(info.guest_base);
|
||||
poly::copy_and_swap_32_aligned(dest, src, info.count);
|
||||
xe::copy_and_swap_32_aligned(dest, src, info.count);
|
||||
} else {
|
||||
auto dest = reinterpret_cast<uint16_t*>(allocation.host_ptr);
|
||||
auto src = memory_->TranslatePhysical<const uint16_t*>(info.guest_base);
|
||||
poly::copy_and_swap_16_aligned(dest, src, info.count);
|
||||
xe::copy_and_swap_16_aligned(dest, src, info.count);
|
||||
}
|
||||
draw_batcher_.set_index_buffer(allocation);
|
||||
scratch_buffer_.Commit(std::move(allocation));
|
||||
@@ -2354,7 +2353,7 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateVertexBuffers() {
|
||||
// We could be smart about this to save GPU bandwidth by building a CRC
|
||||
// as we copy and only if it differs from the previous value committing
|
||||
// it (and if it matches just discard and reuse).
|
||||
poly::copy_and_swap_32_aligned(
|
||||
xe::copy_and_swap_32_aligned(
|
||||
reinterpret_cast<uint32_t*>(allocation.host_ptr),
|
||||
memory_->TranslatePhysical<const uint32_t*>(fetch->address << 2),
|
||||
valid_range / 4);
|
||||
@@ -2663,8 +2662,8 @@ bool CommandProcessor::IssueCopy() {
|
||||
// but I can't seem to find something similar.
|
||||
uint32_t dest_logical_width = copy_dest_pitch;
|
||||
uint32_t dest_logical_height = copy_dest_height;
|
||||
uint32_t dest_block_width = poly::round_up(dest_logical_width, 32);
|
||||
uint32_t dest_block_height = poly::round_up(dest_logical_height, 32);
|
||||
uint32_t dest_block_width = xe::round_up(dest_logical_width, 32);
|
||||
uint32_t dest_block_height = xe::round_up(dest_logical_height, 32);
|
||||
|
||||
uint32_t window_offset = regs[XE_GPU_REG_PA_SC_WINDOW_OFFSET].u32;
|
||||
int16_t window_offset_x = window_offset & 0x7FFF;
|
||||
@@ -2700,24 +2699,24 @@ bool CommandProcessor::IssueCopy() {
|
||||
trace_writer_.WriteMemoryRead(fetch->address << 2, fetch->size * 4);
|
||||
int32_t dest_min_x = int32_t((std::min(
|
||||
std::min(
|
||||
GpuSwap(poly::load<float>(vertex_addr + 0), Endian(fetch->endian)),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 8), Endian(fetch->endian))),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 16), Endian(fetch->endian)))));
|
||||
GpuSwap(xe::load<float>(vertex_addr + 0), Endian(fetch->endian)),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 8), Endian(fetch->endian))),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 16), Endian(fetch->endian)))));
|
||||
int32_t dest_max_x = int32_t((std::max(
|
||||
std::max(
|
||||
GpuSwap(poly::load<float>(vertex_addr + 0), Endian(fetch->endian)),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 8), Endian(fetch->endian))),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 16), Endian(fetch->endian)))));
|
||||
GpuSwap(xe::load<float>(vertex_addr + 0), Endian(fetch->endian)),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 8), Endian(fetch->endian))),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 16), Endian(fetch->endian)))));
|
||||
int32_t dest_min_y = int32_t((std::min(
|
||||
std::min(
|
||||
GpuSwap(poly::load<float>(vertex_addr + 4), Endian(fetch->endian)),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 12), Endian(fetch->endian))),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 20), Endian(fetch->endian)))));
|
||||
GpuSwap(xe::load<float>(vertex_addr + 4), Endian(fetch->endian)),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 12), Endian(fetch->endian))),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 20), Endian(fetch->endian)))));
|
||||
int32_t dest_max_y = int32_t((std::max(
|
||||
std::max(
|
||||
GpuSwap(poly::load<float>(vertex_addr + 4), Endian(fetch->endian)),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 12), Endian(fetch->endian))),
|
||||
GpuSwap(poly::load<float>(vertex_addr + 20), Endian(fetch->endian)))));
|
||||
GpuSwap(xe::load<float>(vertex_addr + 4), Endian(fetch->endian)),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 12), Endian(fetch->endian))),
|
||||
GpuSwap(xe::load<float>(vertex_addr + 20), Endian(fetch->endian)))));
|
||||
Rect2D dest_rect(dest_min_x, dest_min_y, dest_max_x - dest_min_x,
|
||||
dest_max_y - dest_min_y);
|
||||
Rect2D src_rect(0, 0, dest_rect.width, dest_rect.height);
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "xenia/gpu/gl4/draw_batcher.h"
|
||||
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/cxx_compat.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -168,7 +168,7 @@ bool DrawBatcher::BeginDraw() {
|
||||
}
|
||||
}
|
||||
batch_state_.command_stride =
|
||||
poly::round_up(command_size, GLsizei(kCommandBufferAlignment));
|
||||
xe::round_up(command_size, GLsizei(kCommandBufferAlignment));
|
||||
|
||||
GLsizei header_size = sizeof(CommonHeader);
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/gpu/gl4/gl4_profiler_display.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/gpu/tracing.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -38,7 +38,7 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
|
||||
// Create rendering control.
|
||||
// This must happen on the UI thread.
|
||||
poly::threading::Fence control_ready_fence;
|
||||
xe::threading::Fence control_ready_fence;
|
||||
std::unique_ptr<GLContext> processor_context;
|
||||
target_loop_->Post([&]() {
|
||||
// Setup the GL control that actually does the drawing.
|
||||
@@ -128,12 +128,11 @@ void GL4GraphicsSystem::RequestSwap() {
|
||||
}
|
||||
|
||||
void GL4GraphicsSystem::RequestFrameTrace() {
|
||||
command_processor_->RequestFrameTrace(
|
||||
poly::to_wstring(FLAGS_trace_gpu_prefix));
|
||||
command_processor_->RequestFrameTrace(xe::to_wstring(FLAGS_trace_gpu_prefix));
|
||||
}
|
||||
|
||||
void GL4GraphicsSystem::BeginTracing() {
|
||||
command_processor_->BeginTracing(poly::to_wstring(FLAGS_trace_gpu_prefix));
|
||||
command_processor_->BeginTracing(xe::to_wstring(FLAGS_trace_gpu_prefix));
|
||||
}
|
||||
|
||||
void GL4GraphicsSystem::EndTracing() { command_processor_->EndTracing(); }
|
||||
@@ -149,7 +148,7 @@ void GL4GraphicsSystem::PlayTrace(const uint8_t* trace_data, size_t trace_size,
|
||||
const PacketStartCommand* pending_packet = nullptr;
|
||||
while (trace_ptr < trace_data + trace_size) {
|
||||
auto type =
|
||||
static_cast<TraceCommandType>(poly::load<uint32_t>(trace_ptr));
|
||||
static_cast<TraceCommandType>(xe::load<uint32_t>(trace_ptr));
|
||||
switch (type) {
|
||||
case TraceCommandType::kPrimaryBufferStart: {
|
||||
auto cmd =
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include "third_party/microprofile/microprofileui.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/cxx_compat.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -182,7 +182,7 @@ GL4ProfilerDisplay::GL4ProfilerDisplay(WGLControl* control)
|
||||
|
||||
bool GL4ProfilerDisplay::SetupFont() {
|
||||
// Setup font lookup table.
|
||||
for (uint32_t i = 0; i < poly::countof(font_description_.char_offsets); ++i) {
|
||||
for (uint32_t i = 0; i < xe::countof(font_description_.char_offsets); ++i) {
|
||||
font_description_.char_offsets[i] = 206;
|
||||
}
|
||||
for (uint32_t i = 'A'; i <= 'Z'; ++i) {
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
#include "xenia/gpu/gl4/gl4_shader.h"
|
||||
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/cxx_compat.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/gpu/gl4/gl4_shader_translator.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -355,8 +355,8 @@ bool GL4Shader::CompileProgram(std::string source) {
|
||||
|
||||
// Save to disk, if we asked for it.
|
||||
auto base_path = FLAGS_dump_shaders.c_str();
|
||||
char file_name[poly::max_path];
|
||||
snprintf(file_name, poly::countof(file_name), "%s/gl4_gen_%.16llX.%s",
|
||||
char file_name[xe::max_path];
|
||||
snprintf(file_name, xe::countof(file_name), "%s/gl4_gen_%.16llX.%s",
|
||||
base_path, data_hash_,
|
||||
shader_type_ == ShaderType::kVertex ? "vert" : "frag");
|
||||
if (FLAGS_dump_shaders.size()) {
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "xenia/gpu/gl4/gl4_shader_translator.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "poly/string_buffer.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/gpu/gl4/gl_context.h"
|
||||
#include "xenia/gpu/gl4/gl4_shader.h"
|
||||
#include "xenia/gpu/ucode.h"
|
||||
@@ -41,7 +41,7 @@ class GL4ShaderTranslator {
|
||||
const uint32_t* dwords_;
|
||||
|
||||
static const int kOutputCapacity = 64 * 1024;
|
||||
poly::StringBuffer output_;
|
||||
StringBuffer output_;
|
||||
|
||||
bool is_vertex_shader() const { return shader_type_ == ShaderType::kVertex; }
|
||||
bool is_pixel_shader() const { return shader_type_ == ShaderType::kPixel; }
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/cxx_compat.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -306,7 +306,7 @@ void GLContext::SetupDebugging() {
|
||||
// intended to be used as an offset into a buffer object?
|
||||
};
|
||||
glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_OTHER, GL_DONT_CARE,
|
||||
GLsizei(poly::countof(disable_message_ids)),
|
||||
GLsizei(xe::countof(disable_message_ids)),
|
||||
disable_message_ids, GL_FALSE);
|
||||
|
||||
// Callback will be made from driver threads.
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "xenia/gpu/gl4/texture_cache.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -652,14 +652,14 @@ void TextureSwap(Endian endianness, void* dest, const void* src,
|
||||
size_t length) {
|
||||
switch (endianness) {
|
||||
case Endian::k8in16:
|
||||
poly::copy_and_swap_16_aligned(reinterpret_cast<uint16_t*>(dest),
|
||||
reinterpret_cast<const uint16_t*>(src),
|
||||
length / 2);
|
||||
xe::copy_and_swap_16_aligned(reinterpret_cast<uint16_t*>(dest),
|
||||
reinterpret_cast<const uint16_t*>(src),
|
||||
length / 2);
|
||||
break;
|
||||
case Endian::k8in32:
|
||||
poly::copy_and_swap_32_aligned(reinterpret_cast<uint32_t*>(dest),
|
||||
reinterpret_cast<const uint32_t*>(src),
|
||||
length / 4);
|
||||
xe::copy_and_swap_32_aligned(reinterpret_cast<uint32_t*>(dest),
|
||||
reinterpret_cast<const uint32_t*>(src),
|
||||
length / 4);
|
||||
break;
|
||||
case Endian::k16in32:
|
||||
// TODO(benvanik): make more efficient.
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "xenia/gpu/gl4/wgl_control.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/gpu/gl4/gl_context.h"
|
||||
#include "xenia/ui/loop.h"
|
||||
#include "xenia/ui/win32/win32_control.h"
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "xenia/gpu/graphics_system.h"
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/gpu/gpu-private.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -63,7 +63,7 @@ void GraphicsSystem::DispatchInterruptCallback(uint32_t source, uint32_t cpu) {
|
||||
// NOTE: we may be executing in some random thread.
|
||||
uint64_t args[] = {source, interrupt_callback_data_};
|
||||
processor_->ExecuteInterrupt(cpu, interrupt_callback_, args,
|
||||
poly::countof(args));
|
||||
xe::countof(args));
|
||||
}
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "xenia/gpu/register_file.h"
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "xenia/gpu/shader.h"
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/gpu/ucode_disassembler.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -26,7 +26,7 @@ Shader::Shader(ShaderType shader_type, uint64_t data_hash,
|
||||
has_prepared_(false),
|
||||
is_valid_(false) {
|
||||
data_.resize(dword_count);
|
||||
poly::copy_and_swap(data_.data(), dword_ptr, dword_count);
|
||||
xe::copy_and_swap(data_.data(), dword_ptr, dword_count);
|
||||
std::memset(&alloc_counts_, 0, sizeof(alloc_counts_));
|
||||
std::memset(&buffer_inputs_, 0, sizeof(buffer_inputs_));
|
||||
std::memset(&sampler_inputs_, 0, sizeof(sampler_inputs_));
|
||||
@@ -198,7 +198,7 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) {
|
||||
for (size_t n = 0; n < inputs.count; n++) {
|
||||
auto& desc = inputs.descs[n];
|
||||
if (desc.fetch_slot == fetch_slot) {
|
||||
assert_true(desc.element_count <= poly::countof(desc.elements));
|
||||
assert_true(desc.element_count <= xe::countof(desc.elements));
|
||||
// It may not hold that all strides are equal, but I hope it does.
|
||||
assert_true(!vtx->stride || desc.stride_words == vtx->stride);
|
||||
el = &desc.elements[desc.element_count++];
|
||||
@@ -207,7 +207,7 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) {
|
||||
}
|
||||
if (!el) {
|
||||
assert_not_zero(vtx->stride);
|
||||
assert_true(inputs.count + 1 < poly::countof(inputs.descs));
|
||||
assert_true(inputs.count + 1 < xe::countof(inputs.descs));
|
||||
auto& desc = inputs.descs[inputs.count++];
|
||||
desc.input_index = inputs.count - 1;
|
||||
desc.fetch_slot = fetch_slot;
|
||||
@@ -263,7 +263,7 @@ void Shader::GatherTextureFetch(const instr_fetch_tex_t* tex) {
|
||||
|
||||
assert_true(tex->const_idx < 0x1F);
|
||||
|
||||
assert_true(sampler_inputs_.count + 1 <= poly::countof(sampler_inputs_.descs));
|
||||
assert_true(sampler_inputs_.count + 1 <= xe::countof(sampler_inputs_.descs));
|
||||
auto& input = sampler_inputs_.descs[sampler_inputs_.count++];
|
||||
input.input_index = sampler_inputs_.count - 1;
|
||||
input.fetch_slot = tex->const_idx & 0xF; // ??????????????????????????????
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "third_party/xxhash/xxhash.h"
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -178,10 +178,10 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) {
|
||||
|
||||
// w/h in blocks must be a multiple of block size.
|
||||
uint32_t block_width =
|
||||
poly::round_up(size_2d.logical_width, format_info->block_width) /
|
||||
xe::round_up(size_2d.logical_width, format_info->block_width) /
|
||||
format_info->block_width;
|
||||
uint32_t block_height =
|
||||
poly::round_up(size_2d.logical_height, format_info->block_height) /
|
||||
xe::round_up(size_2d.logical_height, format_info->block_height) /
|
||||
format_info->block_height;
|
||||
|
||||
// Tiles are 32x32 blocks. All textures must be multiples of tile dimensions.
|
||||
@@ -196,7 +196,7 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) {
|
||||
uint32_t byte_pitch = tile_width * 32 * bytes_per_block;
|
||||
if (!is_tiled) {
|
||||
// Each row must be a multiple of 256 in linear textures.
|
||||
byte_pitch = poly::round_up(byte_pitch, 256);
|
||||
byte_pitch = xe::round_up(byte_pitch, 256);
|
||||
}
|
||||
|
||||
size_2d.input_width = tile_width * 32 * format_info->block_width;
|
||||
@@ -219,11 +219,11 @@ void TextureInfo::CalculateTextureSizesCube(const xe_gpu_texture_fetch_t& fetch)
|
||||
|
||||
// w/h in blocks must be a multiple of block size.
|
||||
uint32_t block_width =
|
||||
poly::round_up(size_cube.logical_width, format_info->block_width) /
|
||||
format_info->block_width;
|
||||
xe::round_up(size_cube.logical_width, format_info->block_width) /
|
||||
format_info->block_width;
|
||||
uint32_t block_height =
|
||||
poly::round_up(size_cube.logical_height, format_info->block_height) /
|
||||
format_info->block_height;
|
||||
xe::round_up(size_cube.logical_height, format_info->block_height) /
|
||||
format_info->block_height;
|
||||
|
||||
// Tiles are 32x32 blocks. All textures must be multiples of tile dimensions.
|
||||
uint32_t tile_width = uint32_t(std::ceilf(block_width / 32.0f));
|
||||
@@ -237,7 +237,7 @@ void TextureInfo::CalculateTextureSizesCube(const xe_gpu_texture_fetch_t& fetch)
|
||||
uint32_t byte_pitch = tile_width * 32 * bytes_per_block;
|
||||
if (!is_tiled) {
|
||||
// Each row must be a multiple of 256 in linear textures.
|
||||
byte_pitch = poly::round_up(byte_pitch, 256);
|
||||
byte_pitch = xe::round_up(byte_pitch, 256);
|
||||
}
|
||||
|
||||
size_cube.input_width = tile_width * 32 * format_info->block_width;
|
||||
@@ -297,8 +297,8 @@ void TextureInfo::GetPackedTileOffset(const TextureInfo& texture_info,
|
||||
return;
|
||||
}
|
||||
|
||||
if (poly::log2_ceil(texture_info.size_2d.logical_width) >
|
||||
poly::log2_ceil(texture_info.size_2d.logical_height)) {
|
||||
if (xe::log2_ceil(texture_info.size_2d.logical_width) >
|
||||
xe::log2_ceil(texture_info.size_2d.logical_height)) {
|
||||
// Wider than tall. Laid out vertically.
|
||||
*out_offset_x = 0;
|
||||
*out_offset_y = 16;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/gpu/ucode.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
|
||||
|
||||
@@ -9,17 +9,18 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "poly/main.h"
|
||||
#include "poly/mapped_memory.h"
|
||||
#include "poly/math.h"
|
||||
#include "third_party/imgui/imgui.h"
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/main.h"
|
||||
#include "xenia/base/mapped_memory.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/gpu/gl4/gl_context.h"
|
||||
#include "xenia/gpu/graphics_system.h"
|
||||
#include "xenia/gpu/register_file.h"
|
||||
#include "xenia/gpu/tracing.h"
|
||||
#include "xenia/gpu/xenos.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
#include "xenia/ui/main_window.h"
|
||||
|
||||
@@ -100,7 +101,7 @@ bool DisasmPacketType0(const uint8_t* base_ptr, uint32_t packet,
|
||||
uint32_t base_index = (packet & 0x7FFF);
|
||||
uint32_t write_one_reg = (packet >> 15) & 0x1;
|
||||
for (uint32_t m = 0; m < count; m++) {
|
||||
uint32_t reg_data = poly::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t reg_data = xe::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t target_index = write_one_reg ? base_index : base_index + m;
|
||||
out_info->actions.emplace_back(
|
||||
PacketAction::RegisterWrite(target_index, reg_data));
|
||||
@@ -120,8 +121,8 @@ bool DisasmPacketType1(const uint8_t* base_ptr, uint32_t packet,
|
||||
|
||||
uint32_t reg_index_1 = packet & 0x7FF;
|
||||
uint32_t reg_index_2 = (packet >> 11) & 0x7FF;
|
||||
uint32_t reg_data_1 = poly::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t reg_data_2 = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t reg_data_1 = xe::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t reg_data_2 = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
out_info->actions.emplace_back(
|
||||
PacketAction::RegisterWrite(reg_index_1, reg_data_1));
|
||||
out_info->actions.emplace_back(
|
||||
@@ -177,7 +178,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_INTERRUPT"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t cpu_mask = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t cpu_mask = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
for (int n = 0; n < 6; n++) {
|
||||
if (cpu_mask & (1 << n)) {
|
||||
// graphics_system_->DispatchInterruptCallback(1, n);
|
||||
@@ -193,7 +194,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kSwap,
|
||||
"PM4_XE_SWAP"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t frontbuffer_ptr = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t frontbuffer_ptr = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
break;
|
||||
}
|
||||
case PM4_INDIRECT_BUFFER: {
|
||||
@@ -201,8 +202,8 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_INDIRECT_BUFFER"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t list_ptr = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t list_length = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t list_ptr = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t list_length = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
break;
|
||||
}
|
||||
case PM4_WAIT_REG_MEM: {
|
||||
@@ -210,11 +211,11 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_WAIT_REG_MEM"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t wait_info = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t poll_reg_addr = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t ref = poly::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t mask = poly::load_and_swap<uint32_t>(ptr + 12);
|
||||
uint32_t wait = poly::load_and_swap<uint32_t>(ptr + 16);
|
||||
uint32_t wait_info = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t poll_reg_addr = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t ref = xe::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t mask = xe::load_and_swap<uint32_t>(ptr + 12);
|
||||
uint32_t wait = xe::load_and_swap<uint32_t>(ptr + 16);
|
||||
break;
|
||||
}
|
||||
case PM4_REG_RMW: {
|
||||
@@ -223,9 +224,9 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_REG_RMW"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t rmw_info = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t and_mask = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t or_mask = poly::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t rmw_info = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t and_mask = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t or_mask = xe::load_and_swap<uint32_t>(ptr + 8);
|
||||
break;
|
||||
}
|
||||
case PM4_COND_WRITE: {
|
||||
@@ -233,12 +234,12 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_COND_WRITE"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t wait_info = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t poll_reg_addr = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t ref = poly::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t mask = poly::load_and_swap<uint32_t>(ptr + 12);
|
||||
uint32_t write_reg_addr = poly::load_and_swap<uint32_t>(ptr + 16);
|
||||
uint32_t write_data = poly::load_and_swap<uint32_t>(ptr + 20);
|
||||
uint32_t wait_info = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t poll_reg_addr = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t ref = xe::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t mask = xe::load_and_swap<uint32_t>(ptr + 12);
|
||||
uint32_t write_reg_addr = xe::load_and_swap<uint32_t>(ptr + 16);
|
||||
uint32_t write_data = xe::load_and_swap<uint32_t>(ptr + 20);
|
||||
break;
|
||||
}
|
||||
case PM4_EVENT_WRITE: {
|
||||
@@ -246,7 +247,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_EVENT_WRITE"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t initiator = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t initiator = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
break;
|
||||
}
|
||||
case PM4_EVENT_WRITE_SHD: {
|
||||
@@ -254,9 +255,9 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_EVENT_WRITE_SHD"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t initiator = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t address = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t value = poly::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t initiator = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t address = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t value = xe::load_and_swap<uint32_t>(ptr + 8);
|
||||
break;
|
||||
}
|
||||
case PM4_EVENT_WRITE_EXT: {
|
||||
@@ -264,8 +265,8 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_EVENT_WRITE_EXT"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t unk0 = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t unk1 = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t unk0 = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t unk1 = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
break;
|
||||
}
|
||||
case PM4_DRAW_INDX: {
|
||||
@@ -274,15 +275,15 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kDraw,
|
||||
"PM4_DRAW_INDX"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t dword0 = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t dword1 = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t dword0 = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t dword1 = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t index_count = dword1 >> 16;
|
||||
auto prim_type = static_cast<PrimitiveType>(dword1 & 0x3F);
|
||||
uint32_t src_sel = (dword1 >> 6) & 0x3;
|
||||
if (src_sel == 0x0) {
|
||||
// Indexed draw.
|
||||
uint32_t guest_base = poly::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t index_size = poly::load_and_swap<uint32_t>(ptr + 12);
|
||||
uint32_t guest_base = xe::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t index_size = xe::load_and_swap<uint32_t>(ptr + 12);
|
||||
auto endianness = static_cast<Endian>(index_size >> 30);
|
||||
index_size &= 0x00FFFFFF;
|
||||
bool index_32bit = (dword1 >> 11) & 0x1;
|
||||
@@ -300,7 +301,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kDraw,
|
||||
"PM4_DRAW_INDX_2"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t dword0 = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t dword0 = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t index_count = dword0 >> 16;
|
||||
auto prim_type = static_cast<PrimitiveType>(dword0 & 0x3F);
|
||||
uint32_t src_sel = (dword0 >> 6) & 0x3;
|
||||
@@ -317,7 +318,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_CONSTANT"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t offset_type = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t offset_type = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t index = offset_type & 0x7FF;
|
||||
uint32_t type = (offset_type >> 16) & 0xFF;
|
||||
switch (type) {
|
||||
@@ -342,7 +343,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
break;
|
||||
}
|
||||
for (uint32_t n = 0; n < count - 1; n++, index++) {
|
||||
uint32_t data = poly::load_and_swap<uint32_t>(ptr + 4 + n * 4);
|
||||
uint32_t data = xe::load_and_swap<uint32_t>(ptr + 4 + n * 4);
|
||||
out_info->actions.emplace_back(
|
||||
PacketAction::RegisterWrite(index, data));
|
||||
}
|
||||
@@ -352,10 +353,10 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_CONSTANT2"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t offset_type = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t offset_type = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t index = offset_type & 0xFFFF;
|
||||
for (uint32_t n = 0; n < count - 1; n++, index++) {
|
||||
uint32_t data = poly::load_and_swap<uint32_t>(ptr + 4 + n * 4);
|
||||
uint32_t data = xe::load_and_swap<uint32_t>(ptr + 4 + n * 4);
|
||||
out_info->actions.emplace_back(
|
||||
PacketAction::RegisterWrite(index, data));
|
||||
}
|
||||
@@ -367,11 +368,11 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_LOAD_ALU_CONSTANT"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t address = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t address = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
address &= 0x3FFFFFFF;
|
||||
uint32_t offset_type = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t offset_type = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t index = offset_type & 0x7FF;
|
||||
uint32_t size_dwords = poly::load_and_swap<uint32_t>(ptr + 8);
|
||||
uint32_t size_dwords = xe::load_and_swap<uint32_t>(ptr + 8);
|
||||
size_dwords &= 0xFFF;
|
||||
uint32_t type = (offset_type >> 16) & 0xFF;
|
||||
switch (type) {
|
||||
@@ -396,7 +397,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
}
|
||||
for (uint32_t n = 0; n < size_dwords; n++, index++) {
|
||||
// Hrm, ?
|
||||
// poly::load_and_swap<uint32_t>(membase_ + GpuToCpu(address + n * 4));
|
||||
// xe::load_and_swap<uint32_t>(membase_ + GpuToCpu(address + n * 4));
|
||||
uint32_t data = 0xDEADBEEF;
|
||||
out_info->actions.emplace_back(
|
||||
PacketAction::RegisterWrite(index, data));
|
||||
@@ -407,10 +408,10 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_SHADER_CONSTANTS"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t offset_type = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t offset_type = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t index = offset_type & 0xFFFF;
|
||||
for (uint32_t n = 0; n < count - 1; n++, index++) {
|
||||
uint32_t data = poly::load_and_swap<uint32_t>(ptr + 4 + n * 4);
|
||||
uint32_t data = xe::load_and_swap<uint32_t>(ptr + 4 + n * 4);
|
||||
out_info->actions.emplace_back(
|
||||
PacketAction::RegisterWrite(index, data));
|
||||
}
|
||||
@@ -421,10 +422,10 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_IM_LOAD"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t addr_type = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t addr_type = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
auto shader_type = static_cast<ShaderType>(addr_type & 0x3);
|
||||
uint32_t addr = addr_type & ~0x3;
|
||||
uint32_t start_size = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t start_size = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t start = start_size >> 16;
|
||||
uint32_t size_dwords = start_size & 0xFFFF; // dwords
|
||||
assert_true(start == 0);
|
||||
@@ -435,8 +436,8 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_IM_LOAD_IMMEDIATE"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t dword0 = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t dword1 = poly::load_and_swap<uint32_t>(ptr + 4);
|
||||
uint32_t dword0 = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t dword1 = xe::load_and_swap<uint32_t>(ptr + 4);
|
||||
auto shader_type = static_cast<ShaderType>(dword0);
|
||||
uint32_t start_size = dword1;
|
||||
uint32_t start = start_size >> 16;
|
||||
@@ -449,14 +450,14 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_INVALIDATE_STATE"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t mask = poly::load_and_swap<uint32_t>(ptr + 0);
|
||||
uint32_t mask = xe::load_and_swap<uint32_t>(ptr + 0);
|
||||
break;
|
||||
}
|
||||
case PM4_SET_BIN_MASK_LO: {
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_BIN_MASK_LO"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t value = poly::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t value = xe::load_and_swap<uint32_t>(ptr);
|
||||
// bin_mask_ = (bin_mask_ & 0xFFFFFFFF00000000ull) | value;
|
||||
out_info->actions.emplace_back(PacketAction::SetBinMask(value));
|
||||
break;
|
||||
@@ -465,7 +466,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_BIN_MASK_HI"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t value = poly::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t value = xe::load_and_swap<uint32_t>(ptr);
|
||||
// bin_mask_ =
|
||||
// (bin_mask_ & 0xFFFFFFFFull) | (static_cast<uint64_t>(value) << 32);
|
||||
break;
|
||||
@@ -474,7 +475,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_BIN_SELECT_LO"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t value = poly::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t value = xe::load_and_swap<uint32_t>(ptr);
|
||||
// bin_select_ = (bin_select_ & 0xFFFFFFFF00000000ull) | value;
|
||||
out_info->actions.emplace_back(PacketAction::SetBinSelect(value));
|
||||
break;
|
||||
@@ -483,7 +484,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
static const PacketTypeInfo op_info = {PacketCategory::kGeneric,
|
||||
"PM4_SET_BIN_SELECT_HI"};
|
||||
out_info->type_info = &op_info;
|
||||
uint32_t value = poly::load_and_swap<uint32_t>(ptr);
|
||||
uint32_t value = xe::load_and_swap<uint32_t>(ptr);
|
||||
// bin_select_ =
|
||||
// (bin_select_ & 0xFFFFFFFFull) | (static_cast<uint64_t>(value) << 32);
|
||||
break;
|
||||
@@ -513,7 +514,7 @@ bool DisasmPacketType3(const uint8_t* base_ptr, uint32_t packet,
|
||||
bool DisasmPacket(const uint8_t* base_ptr, PacketInfo* out_info) {
|
||||
std::memset(out_info, 0, sizeof(PacketInfo));
|
||||
|
||||
const uint32_t packet = poly::load_and_swap<uint32_t>(base_ptr);
|
||||
const uint32_t packet = xe::load_and_swap<uint32_t>(base_ptr);
|
||||
const uint32_t packet_type = packet >> 30;
|
||||
switch (packet_type) {
|
||||
case 0x00:
|
||||
@@ -531,7 +532,7 @@ bool DisasmPacket(const uint8_t* base_ptr, PacketInfo* out_info) {
|
||||
}
|
||||
|
||||
PacketCategory GetPacketCategory(const uint8_t* base_ptr) {
|
||||
const uint32_t packet = poly::load_and_swap<uint32_t>(base_ptr);
|
||||
const uint32_t packet = xe::load_and_swap<uint32_t>(base_ptr);
|
||||
const uint32_t packet_type = packet >> 30;
|
||||
switch (packet_type) {
|
||||
case 0x00:
|
||||
@@ -597,7 +598,7 @@ class TraceReader {
|
||||
bool Open(const std::wstring& path) {
|
||||
Close();
|
||||
|
||||
mmap_ = poly::MappedMemory::Open(path, poly::MappedMemory::Mode::kRead);
|
||||
mmap_ = MappedMemory::Open(path, MappedMemory::Mode::kRead);
|
||||
if (!mmap_) {
|
||||
return false;
|
||||
}
|
||||
@@ -658,8 +659,7 @@ class TraceReader {
|
||||
bool pending_break = false;
|
||||
while (trace_ptr < trace_data_ + trace_size_) {
|
||||
++current_frame.command_count;
|
||||
auto type =
|
||||
static_cast<TraceCommandType>(poly::load<uint32_t>(trace_ptr));
|
||||
auto type = static_cast<TraceCommandType>(xe::load<uint32_t>(trace_ptr));
|
||||
switch (type) {
|
||||
case TraceCommandType::kPrimaryBufferStart: {
|
||||
auto cmd =
|
||||
@@ -759,7 +759,7 @@ class TraceReader {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<poly::MappedMemory> mmap_;
|
||||
std::unique_ptr<MappedMemory> mmap_;
|
||||
const uint8_t* trace_data_;
|
||||
size_t trace_size_;
|
||||
std::vector<Frame> frames_;
|
||||
@@ -1266,8 +1266,8 @@ void DrawVertexFetcher(const Memory* memory, gl4::GL4Shader* shader,
|
||||
const uint8_t* vstart = addr + i * desc.stride_words * 4;
|
||||
for (uint32_t el_index = 0; el_index < desc.element_count; ++el_index) {
|
||||
const auto& el = desc.elements[el_index];
|
||||
#define LOADEL(type, wo) \
|
||||
GpuSwap(poly::load<type>(vstart + (el.offset_words + wo) * 4), \
|
||||
#define LOADEL(type, wo) \
|
||||
GpuSwap(xe::load<type>(vstart + (el.offset_words + wo) * 4), \
|
||||
Endian(fetch->endian))
|
||||
switch (el.format) {
|
||||
case VertexFormat::k_32:
|
||||
@@ -1402,7 +1402,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
auto frame = player.current_frame();
|
||||
const auto& command = frame->commands[player.current_command_index()];
|
||||
auto packet_head = command.head_ptr + sizeof(PacketStartCommand);
|
||||
uint32_t packet = poly::load_and_swap<uint32_t>(packet_head);
|
||||
uint32_t packet = xe::load_and_swap<uint32_t>(packet_head);
|
||||
uint32_t packet_type = packet >> 30;
|
||||
assert_true(packet_type == 0x03);
|
||||
uint32_t opcode = (packet >> 8) & 0x7F;
|
||||
@@ -1418,8 +1418,8 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
std::memset(&draw_info, 0, sizeof(draw_info));
|
||||
switch (opcode) {
|
||||
case PM4_DRAW_INDX: {
|
||||
uint32_t dword0 = poly::load_and_swap<uint32_t>(packet_head + 4);
|
||||
uint32_t dword1 = poly::load_and_swap<uint32_t>(packet_head + 8);
|
||||
uint32_t dword0 = xe::load_and_swap<uint32_t>(packet_head + 4);
|
||||
uint32_t dword1 = xe::load_and_swap<uint32_t>(packet_head + 8);
|
||||
draw_info.index_count = dword1 >> 16;
|
||||
draw_info.prim_type = static_cast<PrimitiveType>(dword1 & 0x3F);
|
||||
uint32_t src_sel = (dword1 >> 6) & 0x3;
|
||||
@@ -1427,8 +1427,8 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
// Indexed draw.
|
||||
draw_info.is_auto_index = false;
|
||||
draw_info.index_buffer_ptr =
|
||||
poly::load_and_swap<uint32_t>(packet_head + 12);
|
||||
uint32_t index_size = poly::load_and_swap<uint32_t>(packet_head + 16);
|
||||
xe::load_and_swap<uint32_t>(packet_head + 12);
|
||||
uint32_t index_size = xe::load_and_swap<uint32_t>(packet_head + 16);
|
||||
draw_info.index_endianness = static_cast<Endian>(index_size >> 30);
|
||||
index_size &= 0x00FFFFFF;
|
||||
bool index_32bit = (dword1 >> 11) & 0x1;
|
||||
@@ -1445,7 +1445,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
break;
|
||||
}
|
||||
case PM4_DRAW_INDX_2: {
|
||||
uint32_t dword0 = poly::load_and_swap<uint32_t>(packet_head + 4);
|
||||
uint32_t dword0 = xe::load_and_swap<uint32_t>(packet_head + 4);
|
||||
uint32_t src_sel = (dword0 >> 6) & 0x3;
|
||||
assert_true(src_sel == 0x2); // 'SrcSel=AutoIndex'
|
||||
draw_info.prim_type = static_cast<PrimitiveType>(dword0 & 0x3F);
|
||||
@@ -1654,7 +1654,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
regs[XE_GPU_REG_RB_BLENDCONTROL_3].u32,
|
||||
};
|
||||
ImGui::Columns(2);
|
||||
for (int i = 0; i < poly::countof(color_info); ++i) {
|
||||
for (int i = 0; i < xe::countof(color_info); ++i) {
|
||||
uint32_t blend_control = rb_blendcontrol[i];
|
||||
// A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND
|
||||
auto src_blend = (blend_control & 0x0000001F) >> 0;
|
||||
@@ -1711,7 +1711,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Columns(4);
|
||||
for (int i = 0; i < poly::countof(color_info); ++i) {
|
||||
for (int i = 0; i < xe::countof(color_info); ++i) {
|
||||
uint32_t write_mask = (rb_color_mask >> (i * 4)) & 0xF;
|
||||
uint32_t color_base = color_info[i] & 0xFFF;
|
||||
auto color_format =
|
||||
@@ -1883,9 +1883,9 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
uint32_t value = element_size == 4
|
||||
? GpuSwap(poly::load<uint32_t>(data_ptr),
|
||||
? GpuSwap(xe::load<uint32_t>(data_ptr),
|
||||
draw_info.index_endianness)
|
||||
: GpuSwap(poly::load<uint16_t>(data_ptr),
|
||||
: GpuSwap(xe::load<uint16_t>(data_ptr),
|
||||
draw_info.index_endianness);
|
||||
ImGui::Text(" %d", value);
|
||||
ImGui::NextColumn();
|
||||
@@ -2047,7 +2047,7 @@ void DrawPacketDisassemblerUI(xe::ui::MainWindow* window, TracePlayer& player,
|
||||
const PacketStartCommand* pending_packet = nullptr;
|
||||
auto trace_ptr = start_ptr;
|
||||
while (trace_ptr < end_ptr) {
|
||||
auto type = static_cast<TraceCommandType>(poly::load<uint32_t>(trace_ptr));
|
||||
auto type = static_cast<TraceCommandType>(xe::load<uint32_t>(trace_ptr));
|
||||
switch (type) {
|
||||
case TraceCommandType::kPrimaryBufferStart: {
|
||||
auto cmd =
|
||||
@@ -2190,17 +2190,17 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
||||
// Passed as a named argument.
|
||||
// TODO(benvanik): find something better than gflags that supports
|
||||
// unicode.
|
||||
path = poly::to_wstring(FLAGS_target_trace_file);
|
||||
path = xe::to_wstring(FLAGS_target_trace_file);
|
||||
} else {
|
||||
// Passed as an unnamed argument.
|
||||
path = args[1];
|
||||
}
|
||||
// Normalize the path and make absolute.
|
||||
auto abs_path = poly::to_absolute_path(path);
|
||||
auto abs_path = xe::to_absolute_path(path);
|
||||
|
||||
auto window = emulator->main_window();
|
||||
auto loop = window->loop();
|
||||
auto file_name = poly::find_name_from_path(path);
|
||||
auto file_name = xe::find_name_from_path(path);
|
||||
window->set_title(std::wstring(L"Xenia GPU Trace Viewer: ") + file_name);
|
||||
|
||||
auto graphics_system = emulator->graphics_system();
|
||||
@@ -2265,10 +2265,10 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
||||
imgui_setup = true;
|
||||
}
|
||||
auto& io = ImGui::GetIO();
|
||||
auto current_ticks = poly::threading::ticks();
|
||||
auto current_ticks = xe::threading::ticks();
|
||||
static uint64_t last_ticks = 0;
|
||||
io.DeltaTime = (current_ticks - last_ticks) /
|
||||
float(poly::threading::ticks_per_second());
|
||||
float(xe::threading::ticks_per_second());
|
||||
last_ticks = current_ticks;
|
||||
|
||||
io.DisplaySize =
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#ifndef XENIA_GPU_XENOS_H_
|
||||
#define XENIA_GPU_XENOS_H_
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/byte_order.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/gpu/ucode.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -239,7 +239,7 @@ inline uint32_t GpuSwap(uint32_t value, Endian endianness) {
|
||||
case Endian::k8in32:
|
||||
// Swap bytes.
|
||||
// NOTE: we are likely doing two swaps here. Wasteful. Oh well.
|
||||
return poly::byte_swap(value);
|
||||
return xe::byte_swap(value);
|
||||
case Endian::k16in32:
|
||||
// Swap half words.
|
||||
return ((value >> 16) & 0xFFFF) | (value << 16);
|
||||
|
||||
Reference in New Issue
Block a user