More style.
This commit is contained in:
@@ -483,7 +483,8 @@ void CommandProcessor::EnableReadPointerWriteBack(uint32_t ptr,
|
||||
// CP_RB_CNTL Ring Buffer Control 0x704
|
||||
// block_size = RB_BLKSZ, number of quadwords read between updates of the
|
||||
// read pointer.
|
||||
read_ptr_update_freq_ = (uint32_t)pow(2.0, (double)block_size) / 4;
|
||||
read_ptr_update_freq_ =
|
||||
static_cast<uint32_t>(pow(2.0, static_cast<double>(block_size)) / 4);
|
||||
}
|
||||
|
||||
void CommandProcessor::UpdateWritePointer(uint32_t value) {
|
||||
@@ -1595,22 +1596,22 @@ bool CommandProcessor::IssueDraw() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommandProcessor::SetShadowRegister(uint32_t& dest,
|
||||
bool CommandProcessor::SetShadowRegister(uint32_t* dest,
|
||||
uint32_t register_name) {
|
||||
uint32_t value = register_file_->values[register_name].u32;
|
||||
if (dest == value) {
|
||||
if (*dest == value) {
|
||||
return false;
|
||||
}
|
||||
dest = value;
|
||||
*dest = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommandProcessor::SetShadowRegister(float& dest, uint32_t register_name) {
|
||||
bool CommandProcessor::SetShadowRegister(float* dest, uint32_t register_name) {
|
||||
float value = register_file_->values[register_name].f32;
|
||||
if (dest == value) {
|
||||
if (*dest == value) {
|
||||
return false;
|
||||
}
|
||||
dest = value;
|
||||
*dest = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1628,9 +1629,9 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateShaders(
|
||||
register_file_->values[XE_GPU_REG_SQ_PS_CONST].u32 == 0x00000000);
|
||||
|
||||
bool dirty = false;
|
||||
dirty |=
|
||||
SetShadowRegister(regs.pa_su_sc_mode_cntl, XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(regs.sq_program_cntl, XE_GPU_REG_SQ_PROGRAM_CNTL);
|
||||
dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl,
|
||||
XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(®s.sq_program_cntl, XE_GPU_REG_SQ_PROGRAM_CNTL);
|
||||
dirty |= regs.vertex_shader != active_vertex_shader_;
|
||||
dirty |= regs.pixel_shader != active_pixel_shader_;
|
||||
dirty |= regs.prim_type != prim_type;
|
||||
@@ -1769,17 +1770,17 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRenderTargets() {
|
||||
auto& regs = update_render_targets_regs_;
|
||||
|
||||
bool dirty = false;
|
||||
dirty |= SetShadowRegister(regs.rb_modecontrol, XE_GPU_REG_RB_MODECONTROL);
|
||||
dirty |= SetShadowRegister(regs.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO);
|
||||
dirty |= SetShadowRegister(regs.rb_color_info, XE_GPU_REG_RB_COLOR_INFO);
|
||||
dirty |= SetShadowRegister(regs.rb_color1_info, XE_GPU_REG_RB_COLOR1_INFO);
|
||||
dirty |= SetShadowRegister(regs.rb_color2_info, XE_GPU_REG_RB_COLOR2_INFO);
|
||||
dirty |= SetShadowRegister(regs.rb_color3_info, XE_GPU_REG_RB_COLOR3_INFO);
|
||||
dirty |= SetShadowRegister(regs.rb_color_mask, XE_GPU_REG_RB_COLOR_MASK);
|
||||
dirty |= SetShadowRegister(regs.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL);
|
||||
dirty |= SetShadowRegister(®s.rb_modecontrol, XE_GPU_REG_RB_MODECONTROL);
|
||||
dirty |= SetShadowRegister(®s.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO);
|
||||
dirty |= SetShadowRegister(®s.rb_color_info, XE_GPU_REG_RB_COLOR_INFO);
|
||||
dirty |= SetShadowRegister(®s.rb_color1_info, XE_GPU_REG_RB_COLOR1_INFO);
|
||||
dirty |= SetShadowRegister(®s.rb_color2_info, XE_GPU_REG_RB_COLOR2_INFO);
|
||||
dirty |= SetShadowRegister(®s.rb_color3_info, XE_GPU_REG_RB_COLOR3_INFO);
|
||||
dirty |= SetShadowRegister(®s.rb_color_mask, XE_GPU_REG_RB_COLOR_MASK);
|
||||
dirty |= SetShadowRegister(®s.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK);
|
||||
dirty |= SetShadowRegister(regs.rb_depth_info, XE_GPU_REG_RB_DEPTH_INFO);
|
||||
SetShadowRegister(®s.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK);
|
||||
dirty |= SetShadowRegister(®s.rb_depth_info, XE_GPU_REG_RB_DEPTH_INFO);
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -1893,30 +1894,30 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateViewportState() {
|
||||
auto& regs = update_viewport_state_regs_;
|
||||
|
||||
bool dirty = false;
|
||||
// dirty |= SetShadowRegister(state_regs.pa_cl_clip_cntl,
|
||||
// dirty |= SetShadowRegister(&state_regs.pa_cl_clip_cntl,
|
||||
// XE_GPU_REG_PA_CL_CLIP_CNTL);
|
||||
dirty |= SetShadowRegister(regs.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO);
|
||||
dirty |= SetShadowRegister(regs.pa_cl_vte_cntl, XE_GPU_REG_PA_CL_VTE_CNTL);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.pa_su_sc_mode_cntl, XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(regs.pa_sc_window_offset,
|
||||
dirty |= SetShadowRegister(®s.rb_surface_info, XE_GPU_REG_RB_SURFACE_INFO);
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vte_cntl, XE_GPU_REG_PA_CL_VTE_CNTL);
|
||||
dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl,
|
||||
XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(®s.pa_sc_window_offset,
|
||||
XE_GPU_REG_PA_SC_WINDOW_OFFSET);
|
||||
dirty |= SetShadowRegister(regs.pa_sc_window_scissor_tl,
|
||||
dirty |= SetShadowRegister(®s.pa_sc_window_scissor_tl,
|
||||
XE_GPU_REG_PA_SC_WINDOW_SCISSOR_TL);
|
||||
dirty |= SetShadowRegister(regs.pa_sc_window_scissor_br,
|
||||
dirty |= SetShadowRegister(®s.pa_sc_window_scissor_br,
|
||||
XE_GPU_REG_PA_SC_WINDOW_SCISSOR_BR);
|
||||
dirty |= SetShadowRegister(regs.pa_cl_vport_xoffset,
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vport_xoffset,
|
||||
XE_GPU_REG_PA_CL_VPORT_XOFFSET);
|
||||
dirty |= SetShadowRegister(regs.pa_cl_vport_yoffset,
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vport_yoffset,
|
||||
XE_GPU_REG_PA_CL_VPORT_YOFFSET);
|
||||
dirty |= SetShadowRegister(regs.pa_cl_vport_zoffset,
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vport_zoffset,
|
||||
XE_GPU_REG_PA_CL_VPORT_ZOFFSET);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.pa_cl_vport_xscale, XE_GPU_REG_PA_CL_VPORT_XSCALE);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.pa_cl_vport_yscale, XE_GPU_REG_PA_CL_VPORT_YSCALE);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.pa_cl_vport_zscale, XE_GPU_REG_PA_CL_VPORT_ZSCALE);
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vport_xscale,
|
||||
XE_GPU_REG_PA_CL_VPORT_XSCALE);
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vport_yscale,
|
||||
XE_GPU_REG_PA_CL_VPORT_YSCALE);
|
||||
dirty |= SetShadowRegister(®s.pa_cl_vport_zscale,
|
||||
XE_GPU_REG_PA_CL_VPORT_ZSCALE);
|
||||
|
||||
// Much of this state machine is extracted from:
|
||||
// https://github.com/freedreno/mesa/blob/master/src/mesa/drivers/dri/r200/r200_state.c
|
||||
@@ -2051,13 +2052,13 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRasterizerState() {
|
||||
auto& regs = update_rasterizer_state_regs_;
|
||||
|
||||
bool dirty = false;
|
||||
dirty |=
|
||||
SetShadowRegister(regs.pa_su_sc_mode_cntl, XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(regs.pa_sc_screen_scissor_tl,
|
||||
dirty |= SetShadowRegister(®s.pa_su_sc_mode_cntl,
|
||||
XE_GPU_REG_PA_SU_SC_MODE_CNTL);
|
||||
dirty |= SetShadowRegister(®s.pa_sc_screen_scissor_tl,
|
||||
XE_GPU_REG_PA_SC_SCREEN_SCISSOR_TL);
|
||||
dirty |= SetShadowRegister(regs.pa_sc_screen_scissor_br,
|
||||
dirty |= SetShadowRegister(®s.pa_sc_screen_scissor_br,
|
||||
XE_GPU_REG_PA_SC_SCREEN_SCISSOR_BR);
|
||||
dirty |= SetShadowRegister(regs.multi_prim_ib_reset_index,
|
||||
dirty |= SetShadowRegister(®s.multi_prim_ib_reset_index,
|
||||
XE_GPU_REG_VGT_MULTI_PRIM_IB_RESET_INDX);
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
@@ -2149,17 +2150,17 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateBlendState() {
|
||||
|
||||
bool dirty = false;
|
||||
dirty |=
|
||||
SetShadowRegister(regs.rb_blendcontrol[0], XE_GPU_REG_RB_BLENDCONTROL_0);
|
||||
SetShadowRegister(®s.rb_blendcontrol[0], XE_GPU_REG_RB_BLENDCONTROL_0);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.rb_blendcontrol[1], XE_GPU_REG_RB_BLENDCONTROL_1);
|
||||
SetShadowRegister(®s.rb_blendcontrol[1], XE_GPU_REG_RB_BLENDCONTROL_1);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.rb_blendcontrol[2], XE_GPU_REG_RB_BLENDCONTROL_2);
|
||||
SetShadowRegister(®s.rb_blendcontrol[2], XE_GPU_REG_RB_BLENDCONTROL_2);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.rb_blendcontrol[3], XE_GPU_REG_RB_BLENDCONTROL_3);
|
||||
dirty |= SetShadowRegister(regs.rb_blend_rgba[0], XE_GPU_REG_RB_BLEND_RED);
|
||||
dirty |= SetShadowRegister(regs.rb_blend_rgba[1], XE_GPU_REG_RB_BLEND_GREEN);
|
||||
dirty |= SetShadowRegister(regs.rb_blend_rgba[2], XE_GPU_REG_RB_BLEND_BLUE);
|
||||
dirty |= SetShadowRegister(regs.rb_blend_rgba[3], XE_GPU_REG_RB_BLEND_ALPHA);
|
||||
SetShadowRegister(®s.rb_blendcontrol[3], XE_GPU_REG_RB_BLENDCONTROL_3);
|
||||
dirty |= SetShadowRegister(®s.rb_blend_rgba[0], XE_GPU_REG_RB_BLEND_RED);
|
||||
dirty |= SetShadowRegister(®s.rb_blend_rgba[1], XE_GPU_REG_RB_BLEND_GREEN);
|
||||
dirty |= SetShadowRegister(®s.rb_blend_rgba[2], XE_GPU_REG_RB_BLEND_BLUE);
|
||||
dirty |= SetShadowRegister(®s.rb_blend_rgba[3], XE_GPU_REG_RB_BLEND_ALPHA);
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -2234,9 +2235,9 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateDepthStencilState() {
|
||||
auto& regs = update_depth_stencil_state_regs_;
|
||||
|
||||
bool dirty = false;
|
||||
dirty |= SetShadowRegister(regs.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL);
|
||||
dirty |= SetShadowRegister(®s.rb_depthcontrol, XE_GPU_REG_RB_DEPTHCONTROL);
|
||||
dirty |=
|
||||
SetShadowRegister(regs.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK);
|
||||
SetShadowRegister(®s.rb_stencilrefmask, XE_GPU_REG_RB_STENCILREFMASK);
|
||||
if (!dirty) {
|
||||
return UpdateStatus::kCompatible;
|
||||
}
|
||||
@@ -2891,7 +2892,8 @@ bool CommandProcessor::IssueCopy() {
|
||||
if (depth_clear_enabled && depth_target != kAnyTarget) {
|
||||
// Clear the current depth buffer.
|
||||
// TODO(benvanik): verify format.
|
||||
GLfloat depth = {(copy_depth_clear & 0xFFFFFF00) / float(0xFFFFFF00)};
|
||||
GLfloat depth = {(copy_depth_clear & 0xFFFFFF00) /
|
||||
static_cast<float>(0xFFFFFF00)};
|
||||
GLint stencil = copy_depth_clear & 0xFF;
|
||||
GLboolean old_depth_mask;
|
||||
GLint old_stencil_mask;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -64,7 +65,7 @@ enum class SwapMode {
|
||||
|
||||
class CommandProcessor {
|
||||
public:
|
||||
CommandProcessor(GL4GraphicsSystem* graphics_system);
|
||||
explicit CommandProcessor(GL4GraphicsSystem* graphics_system);
|
||||
~CommandProcessor();
|
||||
|
||||
uint32_t counter() const { return counter_; }
|
||||
@@ -299,8 +300,8 @@ class CommandProcessor {
|
||||
xe::ui::gl::CircularBuffer scratch_buffer_;
|
||||
|
||||
private:
|
||||
bool SetShadowRegister(uint32_t& dest, uint32_t register_name);
|
||||
bool SetShadowRegister(float& dest, uint32_t register_name);
|
||||
bool SetShadowRegister(uint32_t* dest, uint32_t register_name);
|
||||
bool SetShadowRegister(float* dest, uint32_t register_name);
|
||||
struct UpdateRenderTargetsRegisters {
|
||||
uint32_t rb_modecontrol;
|
||||
uint32_t rb_surface_info;
|
||||
|
||||
@@ -155,7 +155,7 @@ bool DrawBatcher::BeginDraw() {
|
||||
|
||||
GLsizei header_size = sizeof(CommonHeader);
|
||||
|
||||
// TODO(benvanik); consts sizing.
|
||||
// TODO(benvanik): consts sizing.
|
||||
// GLsizei float_consts_size = sizeof(float4) * 512;
|
||||
// GLsizei bool_consts_size = sizeof(uint32_t) * 8;
|
||||
// GLsizei loop_consts_size = sizeof(uint32_t) * 32;
|
||||
@@ -286,9 +286,9 @@ bool DrawBatcher::Flush(FlushMode mode) {
|
||||
case PrimitiveType::kRectangleList:
|
||||
prim_type = GL_TRIANGLES;
|
||||
// Rect lists aren't culled. There may be other things they skip too.
|
||||
// assert_true((register_file_->values[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32
|
||||
// &
|
||||
// 0x3) == 0);
|
||||
// assert_true(
|
||||
// (register_file_->values[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32
|
||||
// & 0x3) == 0);
|
||||
break;
|
||||
case PrimitiveType::kQuadList:
|
||||
prim_type = GL_LINES_ADJACENCY;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_
|
||||
#define XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_
|
||||
#ifndef XENIA_GPU_GL4_DRAW_BATCHER_H_
|
||||
#define XENIA_GPU_GL4_DRAW_BATCHER_H_
|
||||
|
||||
#include "xenia/gpu/gl4/gl4_shader.h"
|
||||
#include "xenia/gpu/register_file.h"
|
||||
@@ -53,7 +53,7 @@ class DrawBatcher {
|
||||
kReconfigure,
|
||||
};
|
||||
|
||||
DrawBatcher(RegisterFile* register_file);
|
||||
explicit DrawBatcher(RegisterFile* register_file);
|
||||
|
||||
bool Initialize(CircularBuffer* array_data_buffer);
|
||||
void Shutdown();
|
||||
@@ -72,7 +72,7 @@ class DrawBatcher {
|
||||
}
|
||||
void set_alpha_test(bool enabled, uint32_t func, float ref) {
|
||||
active_draw_.header->alpha_test.x = enabled ? 1.0f : 0.0f;
|
||||
active_draw_.header->alpha_test.y = float(func);
|
||||
active_draw_.header->alpha_test.y = static_cast<float>(func);
|
||||
active_draw_.header->alpha_test.z = ref;
|
||||
}
|
||||
void set_texture_sampler(int index, GLuint64 handle) {
|
||||
@@ -159,4 +159,4 @@ class DrawBatcher {
|
||||
} // namespace gpu
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_
|
||||
#endif // XENIA_GPU_GL4_DRAW_BATCHER_H_
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/gpu/gl4/gl4_graphics_system.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "xenia/base/clock.h"
|
||||
@@ -74,7 +75,7 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
|
||||
// Watch for paint requests to do our swap.
|
||||
target_window->on_painting.AddListener(
|
||||
[this](xe::ui::UIEvent& e) { Swap(e); });
|
||||
[this](xe::ui::UIEvent* e) { Swap(e); });
|
||||
|
||||
// Create rendering control.
|
||||
// This must happen on the UI thread.
|
||||
@@ -290,7 +291,7 @@ void GL4GraphicsSystem::MarkVblank() {
|
||||
DispatchInterruptCallback(0, 2);
|
||||
}
|
||||
|
||||
void GL4GraphicsSystem::Swap(xe::ui::UIEvent& e) {
|
||||
void GL4GraphicsSystem::Swap(xe::ui::UIEvent* e) {
|
||||
// Check for pending swap.
|
||||
auto& swap_state = command_processor_->swap_state();
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace gl4 {
|
||||
|
||||
class GL4GraphicsSystem : public GraphicsSystem {
|
||||
public:
|
||||
GL4GraphicsSystem(Emulator* emulator);
|
||||
explicit GL4GraphicsSystem(Emulator* emulator);
|
||||
~GL4GraphicsSystem() override;
|
||||
|
||||
std::unique_ptr<ui::GraphicsContext> CreateContext(
|
||||
@@ -51,7 +51,7 @@ class GL4GraphicsSystem : public GraphicsSystem {
|
||||
|
||||
private:
|
||||
void MarkVblank();
|
||||
void Swap(xe::ui::UIEvent& e);
|
||||
void Swap(xe::ui::UIEvent* e);
|
||||
uint32_t ReadRegister(uint32_t addr);
|
||||
void WriteRegister(uint32_t addr, uint32_t value);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace xe {
|
||||
namespace gpu {
|
||||
namespace gl4 {
|
||||
|
||||
using namespace xe::gpu::xenos;
|
||||
using xe::gpu::xenos::VertexFormat;
|
||||
|
||||
GL4Shader::GL4Shader(ShaderType shader_type, uint64_t data_hash,
|
||||
const uint32_t* dword_ptr, uint32_t dword_count)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "xenia/gpu/gl4/gl4_shader_translator.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
@@ -19,7 +21,8 @@ namespace gpu {
|
||||
namespace gl4 {
|
||||
|
||||
using namespace xe::gpu::ucode;
|
||||
using namespace xe::gpu::xenos;
|
||||
|
||||
using xe::gpu::xenos::VertexFormat;
|
||||
|
||||
#define Append(...) output_.AppendFormat(__VA_ARGS__)
|
||||
|
||||
@@ -68,7 +71,8 @@ void GL4ShaderTranslator::Reset(GL4Shader* shader) {
|
||||
}
|
||||
|
||||
std::string GL4ShaderTranslator::TranslateVertexShader(
|
||||
GL4Shader* vertex_shader, const xe_gpu_program_cntl_t& program_cntl) {
|
||||
GL4Shader* vertex_shader,
|
||||
const xenos::xe_gpu_program_cntl_t& program_cntl) {
|
||||
Reset(vertex_shader);
|
||||
|
||||
// Normal shaders only, for now.
|
||||
@@ -105,13 +109,13 @@ std::string GL4ShaderTranslator::TranslateVertexShader(
|
||||
|
||||
#if FLOW_CONTROL
|
||||
// Add temporary integer registers for loops that we may use.
|
||||
// Each loop uses an address, counter, and constant
|
||||
// TODO: Implement only for the used loops in the shader
|
||||
// Each loop uses an address, counter, and constant.
|
||||
// TODO(benvanik): Implement only for the used loops in the shader.
|
||||
for (uint32_t n = 0; n < 32; n++) {
|
||||
Append(" int i%d_cnt = 0;\n", n);
|
||||
Append(" int i%d_addr = 0;\n", n);
|
||||
}
|
||||
#endif
|
||||
#endif // FLOW_CONTROL
|
||||
|
||||
Append(" vec4 t;\n");
|
||||
Append(" vec4 pv;\n"); // Previous Vector result.
|
||||
@@ -127,7 +131,7 @@ std::string GL4ShaderTranslator::TranslateVertexShader(
|
||||
}
|
||||
|
||||
std::string GL4ShaderTranslator::TranslatePixelShader(
|
||||
GL4Shader* pixel_shader, const xe_gpu_program_cntl_t& program_cntl) {
|
||||
GL4Shader* pixel_shader, const xenos::xe_gpu_program_cntl_t& program_cntl) {
|
||||
Reset(pixel_shader);
|
||||
|
||||
// We need an input VS to make decisions here.
|
||||
@@ -161,7 +165,7 @@ std::string GL4ShaderTranslator::TranslatePixelShader(
|
||||
return output_.to_string();
|
||||
}
|
||||
|
||||
void GL4ShaderTranslator::AppendSrcReg(const instr_alu_t& op, int i) {
|
||||
void GL4ShaderTranslator::AppendSrcReg(const ucode::instr_alu_t& op, int i) {
|
||||
switch (i) {
|
||||
case 1: {
|
||||
int const_slot = 0;
|
||||
@@ -184,9 +188,10 @@ void GL4ShaderTranslator::AppendSrcReg(const instr_alu_t& op, int i) {
|
||||
}
|
||||
}
|
||||
|
||||
void GL4ShaderTranslator::AppendSrcReg(const instr_alu_t& op, uint32_t num,
|
||||
uint32_t type, uint32_t swiz,
|
||||
uint32_t negate, int const_slot) {
|
||||
void GL4ShaderTranslator::AppendSrcReg(const ucode::instr_alu_t& op,
|
||||
uint32_t num, uint32_t type,
|
||||
uint32_t swiz, uint32_t negate,
|
||||
int const_slot) {
|
||||
if (negate) {
|
||||
Append("-");
|
||||
}
|
||||
@@ -271,7 +276,7 @@ void GL4ShaderTranslator::PrintSrcReg(uint32_t num, uint32_t type,
|
||||
}
|
||||
}
|
||||
|
||||
void GL4ShaderTranslator::PrintVectorDstReg(const instr_alu_t& alu) {
|
||||
void GL4ShaderTranslator::PrintVectorDstReg(const ucode::instr_alu_t& alu) {
|
||||
Append("%s%u", alu.export_data ? "export" : "R", alu.vector_dest);
|
||||
auto mask = alu.scalar_write_mask;
|
||||
if (mask != 0xf) {
|
||||
@@ -283,7 +288,7 @@ void GL4ShaderTranslator::PrintVectorDstReg(const instr_alu_t& alu) {
|
||||
}
|
||||
}
|
||||
|
||||
void GL4ShaderTranslator::PrintScalarDstReg(const instr_alu_t& alu) {
|
||||
void GL4ShaderTranslator::PrintScalarDstReg(const ucode::instr_alu_t& alu) {
|
||||
Append("%s%u", alu.export_data ? "export" : "R",
|
||||
alu.export_data ? alu.vector_dest : alu.scalar_dest);
|
||||
auto mask = alu.scalar_write_mask;
|
||||
@@ -494,7 +499,7 @@ void GL4ShaderTranslator::AppendOpDestRegName(const ucode::instr_alu_t& op,
|
||||
}
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_ADDv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_ADDv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
Append(" + ");
|
||||
@@ -503,7 +508,7 @@ bool GL4ShaderTranslator::TranslateALU_ADDv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MULv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MULv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
Append(" * ");
|
||||
@@ -512,7 +517,7 @@ bool GL4ShaderTranslator::TranslateALU_MULv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MAXv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MAXv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
if (alu.src1_reg == alu.src2_reg && alu.src1_sel == alu.src2_sel &&
|
||||
alu.src1_swiz == alu.src2_swiz &&
|
||||
@@ -530,7 +535,7 @@ bool GL4ShaderTranslator::TranslateALU_MAXv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MINv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MINv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("min(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -541,7 +546,7 @@ bool GL4ShaderTranslator::TranslateALU_MINv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_SETXXv(const instr_alu_t& alu,
|
||||
bool GL4ShaderTranslator::TranslateALU_SETXXv(const ucode::instr_alu_t& alu,
|
||||
const char* op) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("vec4((");
|
||||
@@ -564,20 +569,20 @@ bool GL4ShaderTranslator::TranslateALU_SETXXv(const instr_alu_t& alu,
|
||||
EndAppendVectorOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETEv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETEv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXv(alu, "==");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXv(alu, ">");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTEv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTEv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXv(alu, ">=");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETNEv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETNEv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXv(alu, "!=");
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_FRACv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_FRACv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("fract(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -586,7 +591,7 @@ bool GL4ShaderTranslator::TranslateALU_FRACv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_TRUNCv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_TRUNCv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("trunc(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -595,7 +600,7 @@ bool GL4ShaderTranslator::TranslateALU_TRUNCv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_FLOORv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_FLOORv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("floor(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -604,7 +609,7 @@ bool GL4ShaderTranslator::TranslateALU_FLOORv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MULADDv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MULADDv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -616,7 +621,7 @@ bool GL4ShaderTranslator::TranslateALU_MULADDv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDXXv(const instr_alu_t& alu,
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDXXv(const ucode::instr_alu_t& alu,
|
||||
const char* op) {
|
||||
BeginAppendVectorOp(alu);
|
||||
// TODO(benvanik): check argument order - could be 3 as compare and 1 and 2 as
|
||||
@@ -649,17 +654,17 @@ bool GL4ShaderTranslator::TranslateALU_CNDXXv(const instr_alu_t& alu,
|
||||
EndAppendVectorOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDEv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDEv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_CNDXXv(alu, "==");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDGTEv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDGTEv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_CNDXXv(alu, ">=");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDGTv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_CNDGTv(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_CNDXXv(alu, ">");
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_DOT4v(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_DOT4v(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("dot(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -670,7 +675,7 @@ bool GL4ShaderTranslator::TranslateALU_DOT4v(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_DOT3v(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_DOT3v(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("dot(vec4(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -681,7 +686,7 @@ bool GL4ShaderTranslator::TranslateALU_DOT3v(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_DOT2ADDv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_DOT2ADDv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("dot(vec4(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -694,7 +699,7 @@ bool GL4ShaderTranslator::TranslateALU_DOT2ADDv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_CUBEv(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_CUBEv(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("cube(");
|
||||
AppendVectorOpSrcReg(alu, 1);
|
||||
@@ -705,7 +710,7 @@ bool GL4ShaderTranslator::TranslateALU_CUBEv(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MAX4v(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MAX4v(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendVectorOp(alu);
|
||||
Append("max(");
|
||||
Append("max(");
|
||||
@@ -793,7 +798,7 @@ bool GL4ShaderTranslator::TranslateALU_MOVAv(const ucode::instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_ADDs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_ADDs(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
Append(".x + ");
|
||||
@@ -803,7 +808,8 @@ bool GL4ShaderTranslator::TranslateALU_ADDs(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_ADD_PREVs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_ADD_PREVs(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
AppendSrcReg(alu, 3);
|
||||
Append(".x + ps");
|
||||
@@ -811,7 +817,7 @@ bool GL4ShaderTranslator::TranslateALU_ADD_PREVs(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MULs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MULs(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
Append(".x * ");
|
||||
@@ -821,7 +827,8 @@ bool GL4ShaderTranslator::TranslateALU_MULs(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MUL_PREVs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MUL_PREVs(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
AppendSrcReg(alu, 3);
|
||||
Append(".x * ps");
|
||||
@@ -831,7 +838,7 @@ bool GL4ShaderTranslator::TranslateALU_MUL_PREVs(const instr_alu_t& alu) {
|
||||
|
||||
// ...
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MAXs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MAXs(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
if ((alu.src3_swiz & 0x3) == (((alu.src3_swiz >> 2) + 1) & 0x3)) {
|
||||
// This is a mov.
|
||||
@@ -847,7 +854,7 @@ bool GL4ShaderTranslator::TranslateALU_MAXs(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MINs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MINs(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
Append("min(");
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
@@ -858,7 +865,7 @@ bool GL4ShaderTranslator::TranslateALU_MINs(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_SETXXs(const instr_alu_t& alu,
|
||||
bool GL4ShaderTranslator::TranslateALU_SETXXs(const ucode::instr_alu_t& alu,
|
||||
const char* op) {
|
||||
BeginAppendScalarOp(alu);
|
||||
Append("(");
|
||||
@@ -867,16 +874,16 @@ bool GL4ShaderTranslator::TranslateALU_SETXXs(const instr_alu_t& alu,
|
||||
EndAppendScalarOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETEs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETEs(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXs(alu, "==");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTs(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXs(alu, ">");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTEs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETGTEs(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXs(alu, ">=");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SETNEs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SETNEs(const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_SETXXs(alu, "!=");
|
||||
}
|
||||
|
||||
@@ -907,7 +914,7 @@ bool GL4ShaderTranslator::TranslateALU_FLOORs(const ucode::instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_EXP_IEEE(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_EXP_IEEE(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
Append("pow(2.0, ");
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
@@ -936,7 +943,8 @@ bool GL4ShaderTranslator::TranslateALU_LOG_IEEE(const ucode::instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_RECIP_CLAMP(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_RECIP_CLAMP(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
// if result == -inf result = -flt_max
|
||||
// if result == +inf result = flt_max
|
||||
BeginAppendScalarOp(alu);
|
||||
@@ -946,7 +954,7 @@ bool GL4ShaderTranslator::TranslateALU_RECIP_CLAMP(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_RECIP_FF(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_RECIP_FF(const ucode::instr_alu_t& alu) {
|
||||
// if result == -inf result = -zero
|
||||
// if result == +inf result = zero
|
||||
BeginAppendScalarOp(alu);
|
||||
@@ -956,7 +964,8 @@ bool GL4ShaderTranslator::TranslateALU_RECIP_FF(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_RECIP_IEEE(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_RECIP_IEEE(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
Append("1.0 / ");
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
@@ -1037,7 +1046,7 @@ bool GL4ShaderTranslator::TranslateALU_MOVA_FLOORs(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_SUBs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SUBs(const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
Append(".x - ");
|
||||
@@ -1056,8 +1065,8 @@ bool GL4ShaderTranslator::TranslateALU_SUB_PREVs(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETXXs(const instr_alu_t& alu,
|
||||
const char* op) {
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETXXs(
|
||||
const ucode::instr_alu_t& alu, const char* op) {
|
||||
Append(" p = ");
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
Append(".x %s 0.0;\n", op);
|
||||
@@ -1066,16 +1075,20 @@ bool GL4ShaderTranslator::TranslateALU_PRED_SETXXs(const instr_alu_t& alu,
|
||||
EndAppendScalarOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETEs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETEs(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_PRED_SETXXs(alu, "==");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETNEs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETNEs(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_PRED_SETXXs(alu, "!=");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETGTs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETGTs(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_PRED_SETXXs(alu, ">");
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETGTEs(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_PRED_SETGTEs(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_PRED_SETXXs(alu, ">=");
|
||||
}
|
||||
|
||||
@@ -1105,7 +1118,8 @@ bool GL4ShaderTranslator::TranslateALU_PRED_SET_POPs(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_SQRT_IEEE(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SQRT_IEEE(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
Append("sqrt(");
|
||||
AppendScalarOpSrcReg(alu, 3);
|
||||
@@ -1114,7 +1128,8 @@ bool GL4ShaderTranslator::TranslateALU_SQRT_IEEE(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_MUL_CONST_0(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MUL_CONST_0(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
uint32_t src3_swiz = alu.src3_swiz & ~0x3C;
|
||||
uint32_t swiz_a = ((src3_swiz >> 6) - 1) & 0x3;
|
||||
@@ -1130,11 +1145,13 @@ bool GL4ShaderTranslator::TranslateALU_MUL_CONST_0(const instr_alu_t& alu) {
|
||||
EndAppendScalarOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_MUL_CONST_1(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_MUL_CONST_1(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_MUL_CONST_0(alu);
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_ADD_CONST_0(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_ADD_CONST_0(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
uint32_t src3_swiz = alu.src3_swiz & ~0x3C;
|
||||
uint32_t swiz_a = ((src3_swiz >> 6) - 1) & 0x3;
|
||||
@@ -1150,11 +1167,13 @@ bool GL4ShaderTranslator::TranslateALU_ADD_CONST_0(const instr_alu_t& alu) {
|
||||
EndAppendScalarOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_ADD_CONST_1(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_ADD_CONST_1(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
return TranslateALU_ADD_CONST_0(alu);
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_SUB_CONST_0(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SUB_CONST_0(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
BeginAppendScalarOp(alu);
|
||||
uint32_t src3_swiz = alu.src3_swiz & ~0x3C;
|
||||
uint32_t swiz_a = ((src3_swiz >> 6) - 1) & 0x3;
|
||||
@@ -1170,7 +1189,8 @@ bool GL4ShaderTranslator::TranslateALU_SUB_CONST_0(const instr_alu_t& alu) {
|
||||
EndAppendScalarOp(alu);
|
||||
return true;
|
||||
}
|
||||
bool GL4ShaderTranslator::TranslateALU_SUB_CONST_1(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_SUB_CONST_1(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
// Handled as switch on scalar_opc.
|
||||
return TranslateALU_SUB_CONST_0(alu);
|
||||
}
|
||||
@@ -1193,7 +1213,8 @@ bool GL4ShaderTranslator::TranslateALU_COS(const ucode::instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU_RETAIN_PREV(const instr_alu_t& alu) {
|
||||
bool GL4ShaderTranslator::TranslateALU_RETAIN_PREV(
|
||||
const ucode::instr_alu_t& alu) {
|
||||
// TODO(benvanik): figure out how this is used.
|
||||
// It seems like vector writes to export regs will use this to write 1's to
|
||||
// components (like w in position).
|
||||
@@ -1203,7 +1224,7 @@ bool GL4ShaderTranslator::TranslateALU_RETAIN_PREV(const instr_alu_t& alu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef bool (GL4ShaderTranslator::*TranslateFn)(const instr_alu_t& alu);
|
||||
typedef bool (GL4ShaderTranslator::*TranslateFn)(const ucode::instr_alu_t& alu);
|
||||
typedef struct {
|
||||
uint32_t num_srcs;
|
||||
const char* name;
|
||||
@@ -1214,7 +1235,8 @@ typedef struct {
|
||||
#define ALU_INSTR_IMPL(opc, num_srcs) \
|
||||
{ num_srcs, #opc, &GL4ShaderTranslator::TranslateALU_##opc }
|
||||
|
||||
bool GL4ShaderTranslator::TranslateALU(const instr_alu_t* alu, int sync) {
|
||||
bool GL4ShaderTranslator::TranslateALU(const ucode::instr_alu_t* alu,
|
||||
int sync) {
|
||||
static TranslateInfo vector_alu_instrs[0x20] = {
|
||||
ALU_INSTR_IMPL(ADDv, 2), // 0
|
||||
ALU_INSTR_IMPL(MULv, 2), // 1
|
||||
@@ -1446,8 +1468,8 @@ bool GL4ShaderTranslator::TranslateBlocks(GL4Shader* shader) {
|
||||
#endif // FLOW_CONTROL
|
||||
|
||||
// Process all execution blocks.
|
||||
instr_cf_t cfa;
|
||||
instr_cf_t cfb;
|
||||
ucode::instr_cf_t cfa;
|
||||
ucode::instr_cf_t cfb;
|
||||
auto data = shader->data();
|
||||
bool needs_break = false;
|
||||
for (uint32_t idx = 0; idx < shader->dword_count(); idx += 3) {
|
||||
@@ -1496,7 +1518,7 @@ bool GL4ShaderTranslator::TranslateBlocks(GL4Shader* shader) {
|
||||
else if (cfb.opc == LOOP_END) {
|
||||
TranslateLoopEnd(cfb.loop);
|
||||
}
|
||||
#endif
|
||||
#endif // FLOW_CONTROL
|
||||
|
||||
if (cfa.opc == EXEC_END || cfb.opc == EXEC_END) {
|
||||
break;
|
||||
@@ -1545,7 +1567,7 @@ static const struct {
|
||||
#undef INSTR
|
||||
};
|
||||
|
||||
bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) {
|
||||
bool GL4ShaderTranslator::TranslateExec(const ucode::instr_cf_exec_t& cf) {
|
||||
Append(" // %s ADDR(0x%x) CNT(0x%x)", cf_instructions[cf.opc].name,
|
||||
cf.address, cf.count);
|
||||
if (cf.yeild) {
|
||||
@@ -1616,7 +1638,8 @@ bool GL4ShaderTranslator::TranslateExec(const instr_cf_exec_t& cf) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
const instr_alu_t* alu = (const instr_alu_t*)(dwords_ + alu_off * 3);
|
||||
const ucode::instr_alu_t* alu =
|
||||
(const ucode::instr_alu_t*)(dwords_ + alu_off * 3);
|
||||
AppendPredPre(cf.is_cond_exec(), cf.pred_condition, alu->pred_select,
|
||||
alu->pred_condition);
|
||||
if (!TranslateALU(alu, sync)) {
|
||||
@@ -1702,8 +1725,8 @@ bool GL4ShaderTranslator::TranslateLoopEnd(const ucode::instr_cf_loop_t& cf) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateVertexFetch(const instr_fetch_vtx_t* vtx,
|
||||
int sync) {
|
||||
bool GL4ShaderTranslator::TranslateVertexFetch(
|
||||
const ucode::instr_fetch_vtx_t* vtx, int sync) {
|
||||
static const struct {
|
||||
const char* name;
|
||||
} fetch_types[0xff] = {
|
||||
@@ -1834,8 +1857,8 @@ bool GL4ShaderTranslator::TranslateVertexFetch(const instr_fetch_vtx_t* vtx,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GL4ShaderTranslator::TranslateTextureFetch(const instr_fetch_tex_t* tex,
|
||||
int sync) {
|
||||
bool GL4ShaderTranslator::TranslateTextureFetch(
|
||||
const ucode::instr_fetch_tex_t* tex, int sync) {
|
||||
int src_component_count = 0;
|
||||
const char* sampler_type;
|
||||
switch (tex->dimension) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/gpu/gl4/texture_cache.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
@@ -22,7 +23,7 @@ namespace xe {
|
||||
namespace gpu {
|
||||
namespace gl4 {
|
||||
|
||||
using namespace xe::gpu::xenos;
|
||||
using xe::gpu::xenos::Endian;
|
||||
|
||||
struct TextureConfig {
|
||||
TextureFormat texture_format;
|
||||
|
||||
@@ -2201,12 +2201,12 @@ int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||
exit(1);
|
||||
}
|
||||
});
|
||||
window->on_closed.AddListener([&loop](xe::ui::UIEvent& e) {
|
||||
window->on_closed.AddListener([&loop](xe::ui::UIEvent* e) {
|
||||
loop->Quit();
|
||||
XELOGI("User-initiated death!");
|
||||
exit(1);
|
||||
});
|
||||
loop->on_quit.AddListener([&window](xe::ui::UIEvent& e) { window.reset(); });
|
||||
loop->on_quit.AddListener([&window](xe::ui::UIEvent* e) { window.reset(); });
|
||||
window->Resize(1920, 1200);
|
||||
|
||||
X_STATUS result = emulator->Setup(window.get());
|
||||
@@ -2246,21 +2246,21 @@ int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
window->on_key_char.AddListener([graphics_system](xe::ui::KeyEvent& e) {
|
||||
window->on_key_char.AddListener([graphics_system](xe::ui::KeyEvent* e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
if (e.key_code() > 0 && e.key_code() < 0x10000) {
|
||||
if (e.key_code() == 0x74 /* VK_F5 */) {
|
||||
if (e->key_code() > 0 && e->key_code() < 0x10000) {
|
||||
if (e->key_code() == 0x74 /* VK_F5 */) {
|
||||
graphics_system->ClearCaches();
|
||||
} else {
|
||||
io.AddInputCharacter(e.key_code());
|
||||
io.AddInputCharacter(e->key_code());
|
||||
}
|
||||
}
|
||||
e.set_handled(true);
|
||||
e->set_handled(true);
|
||||
});
|
||||
window->on_mouse_down.AddListener([](xe::ui::MouseEvent& e) {
|
||||
window->on_mouse_down.AddListener([](xe::ui::MouseEvent* e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
switch (e.button()) {
|
||||
io.MousePos = ImVec2(float(e->x()), float(e->y()));
|
||||
switch (e->button()) {
|
||||
case xe::ui::MouseEvent::Button::kLeft:
|
||||
io.MouseDown[0] = true;
|
||||
break;
|
||||
@@ -2269,14 +2269,14 @@ int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||
break;
|
||||
}
|
||||
});
|
||||
window->on_mouse_move.AddListener([](xe::ui::MouseEvent& e) {
|
||||
window->on_mouse_move.AddListener([](xe::ui::MouseEvent* e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
io.MousePos = ImVec2(float(e->x()), float(e->y()));
|
||||
});
|
||||
window->on_mouse_up.AddListener([](xe::ui::MouseEvent& e) {
|
||||
window->on_mouse_up.AddListener([](xe::ui::MouseEvent* e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
switch (e.button()) {
|
||||
io.MousePos = ImVec2(float(e->x()), float(e->y()));
|
||||
switch (e->button()) {
|
||||
case xe::ui::MouseEvent::Button::kLeft:
|
||||
io.MouseDown[0] = false;
|
||||
break;
|
||||
@@ -2285,13 +2285,13 @@ int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||
break;
|
||||
}
|
||||
});
|
||||
window->on_mouse_wheel.AddListener([](xe::ui::MouseEvent& e) {
|
||||
window->on_mouse_wheel.AddListener([](xe::ui::MouseEvent* e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
io.MouseWheel += float(e.dy() / 120.0f);
|
||||
io.MousePos = ImVec2(float(e->x()), float(e->y()));
|
||||
io.MouseWheel += float(e->dy() / 120.0f);
|
||||
});
|
||||
|
||||
window->on_painting.AddListener([&](xe::ui::UIEvent& e) {
|
||||
window->on_painting.AddListener([&](xe::ui::UIEvent* e) {
|
||||
static bool imgui_setup = false;
|
||||
if (!imgui_setup) {
|
||||
ImImpl_Setup();
|
||||
@@ -2305,7 +2305,7 @@ int trace_viewer_main(const std::vector<std::wstring>& args) {
|
||||
last_ticks = current_ticks;
|
||||
|
||||
io.DisplaySize =
|
||||
ImVec2(float(e.target()->width()), float(e.target()->height()));
|
||||
ImVec2(float(e->target()->width()), float(e->target()->height()));
|
||||
|
||||
BYTE keystate[256];
|
||||
GetKeyboardState(keystate);
|
||||
|
||||
@@ -62,7 +62,7 @@ class GraphicsSystem {
|
||||
virtual void ClearCaches() {}
|
||||
|
||||
protected:
|
||||
GraphicsSystem(Emulator* emulator);
|
||||
explicit GraphicsSystem(Emulator* emulator);
|
||||
|
||||
Emulator* emulator_ = nullptr;
|
||||
Memory* memory_ = nullptr;
|
||||
|
||||
@@ -31,7 +31,7 @@ const RegisterInfo* RegisterFile::GetRegisterInfo(uint32_t index) {
|
||||
#undef XE_GPU_REGISTER
|
||||
default:
|
||||
return nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "xenia/gpu/texture_info.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "third_party/xxhash/xxhash.h"
|
||||
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
|
||||
@@ -82,7 +82,7 @@ struct EventCommand {
|
||||
|
||||
class TraceWriter {
|
||||
public:
|
||||
TraceWriter(uint8_t* membase);
|
||||
explicit TraceWriter(uint8_t* membase);
|
||||
~TraceWriter();
|
||||
|
||||
bool is_open() const { return file_ != nullptr; }
|
||||
|
||||
@@ -149,13 +149,13 @@ void print_export_comment(StringBuffer* output, uint32_t num, ShaderType type) {
|
||||
}
|
||||
}
|
||||
|
||||
#define INSTR(opc, num_srcs) \
|
||||
{ num_srcs, #opc }
|
||||
struct {
|
||||
uint32_t num_srcs;
|
||||
const char* name;
|
||||
} vector_instructions[0x20] =
|
||||
{
|
||||
#define INSTR(opc, num_srcs) \
|
||||
{ num_srcs, #opc }
|
||||
INSTR(ADDv, 2), // 0
|
||||
INSTR(MULv, 2), // 1
|
||||
INSTR(MAXv, 2), // 2
|
||||
@@ -167,7 +167,7 @@ struct {
|
||||
INSTR(FRACv, 1), // 8
|
||||
INSTR(TRUNCv, 1), // 9
|
||||
INSTR(FLOORv, 1), // 10
|
||||
INSTR(MULADDv, 3), // 111
|
||||
INSTR(MULADDv, 3), // 11
|
||||
INSTR(CNDEv, 3), // 12
|
||||
INSTR(CNDGTEv, 3), // 13
|
||||
INSTR(CNDGTv, 3), // 14
|
||||
@@ -229,16 +229,16 @@ struct {
|
||||
INSTR(KILLNEs, 1), // 38
|
||||
INSTR(KILLONEs, 1), // 39
|
||||
INSTR(SQRT_IEEE, 1), // 40
|
||||
{0, 0},
|
||||
INSTR(MUL_CONST_0, 2), // 42
|
||||
INSTR(MUL_CONST_1, 2), // 43
|
||||
INSTR(ADD_CONST_0, 2), // 44
|
||||
INSTR(ADD_CONST_1, 2), // 45
|
||||
INSTR(SUB_CONST_0, 2), // 46
|
||||
INSTR(SUB_CONST_1, 2), // 47
|
||||
INSTR(SIN, 1), // 48
|
||||
INSTR(COS, 1), // 49
|
||||
INSTR(RETAIN_PREV, 1), // 50
|
||||
{0, 0}, //
|
||||
INSTR(MUL_CONST_0, 2), // 42
|
||||
INSTR(MUL_CONST_1, 2), // 43
|
||||
INSTR(ADD_CONST_0, 2), // 44
|
||||
INSTR(ADD_CONST_1, 2), // 45
|
||||
INSTR(SUB_CONST_0, 2), // 46
|
||||
INSTR(SUB_CONST_1, 2), // 47
|
||||
INSTR(SIN, 1), // 48
|
||||
INSTR(COS, 1), // 49
|
||||
INSTR(RETAIN_PREV, 1), // 50
|
||||
#undef INSTR
|
||||
};
|
||||
|
||||
@@ -701,7 +701,7 @@ struct {
|
||||
static void print_cf(StringBuffer* output, const instr_cf_t* cf, int level) {
|
||||
output->Append(levels[level]);
|
||||
|
||||
const uint16_t* words = (uint16_t*)cf;
|
||||
auto words = reinterpret_cast<const uint16_t*>(cf);
|
||||
output->AppendFormat(" %04x %04x %04x \t", words[0], words[1],
|
||||
words[2]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user