mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 14:05:39 +01:00
GPU: Implement the BindStorageBuffer macro method in HLE.
This macro binds the SSBO Info Buffer as the current ConstBuffer. This buffer is usually bound to c0 during shader execution. Games seem to use this macro instead of directly writing the address for some reason.
This commit is contained in:
parent
85d820b1b4
commit
7b6868e908
@ -13,6 +13,7 @@ constexpr u32 MacroRegistersStart = 0xE00;
|
||||
|
||||
const std::unordered_map<u32, Maxwell3D::MethodInfo> Maxwell3D::method_handlers = {
|
||||
{0xE24, {"SetShader", 5, &Maxwell3D::SetShader}},
|
||||
{0xE2A, {"BindStorageBuffer", 1, &Maxwell3D::BindStorageBuffer}},
|
||||
};
|
||||
|
||||
Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {}
|
||||
@ -200,6 +201,26 @@ void Maxwell3D::SetShader(const std::vector<u32>& parameters) {
|
||||
ProcessCBBind(shader_stage);
|
||||
}
|
||||
|
||||
void Maxwell3D::BindStorageBuffer(const std::vector<u32>& parameters) {
|
||||
/**
|
||||
* Parameters description:
|
||||
* [0] = Buffer offset >> 2
|
||||
*/
|
||||
|
||||
u32 buffer_offset = parameters[0] << 2;
|
||||
|
||||
// Perform the same operations as the real macro code.
|
||||
// Note: This value is hardcoded in the macro's code.
|
||||
static constexpr u32 DefaultCBSize = 0x5F00;
|
||||
regs.const_buffer.cb_size = DefaultCBSize;
|
||||
|
||||
GPUVAddr address = regs.ssbo_info.BufferAddress();
|
||||
regs.const_buffer.cb_address_high = address >> 32;
|
||||
regs.const_buffer.cb_address_low = address & 0xFFFFFFFF;
|
||||
|
||||
regs.const_buffer.cb_pos = buffer_offset;
|
||||
}
|
||||
|
||||
void Maxwell3D::ProcessCBBind(Regs::ShaderStage stage) {
|
||||
// Bind the buffer currently in CB_ADDRESS to the specified index in the desired shader stage.
|
||||
auto& shader = state.shader_stages[static_cast<size_t>(stage)];
|
||||
|
@ -166,7 +166,19 @@ public:
|
||||
|
||||
u32 tex_cb_index;
|
||||
|
||||
INSERT_PADDING_WORDS(0x4B3);
|
||||
INSERT_PADDING_WORDS(0x395);
|
||||
|
||||
struct {
|
||||
/// Compressed address of a buffer that holds information about bound SSBOs.
|
||||
/// This address is usually bound to c0 in the shaders.
|
||||
u32 buffer_address;
|
||||
|
||||
GPUVAddr BufferAddress() const {
|
||||
return static_cast<GPUVAddr>(buffer_address) << 8;
|
||||
}
|
||||
} ssbo_info;
|
||||
|
||||
INSERT_PADDING_WORDS(0x11D);
|
||||
};
|
||||
std::array<u32, NUM_REGS> reg_array;
|
||||
};
|
||||
@ -229,6 +241,7 @@ private:
|
||||
|
||||
/// Method call handlers
|
||||
void SetShader(const std::vector<u32>& parameters);
|
||||
void BindStorageBuffer(const std::vector<u32>& parameters);
|
||||
|
||||
struct MethodInfo {
|
||||
const char* name;
|
||||
@ -252,6 +265,7 @@ ASSERT_REG_POSITION(shader_config[0], 0x800);
|
||||
ASSERT_REG_POSITION(const_buffer, 0x8E0);
|
||||
ASSERT_REG_POSITION(cb_bind[0], 0x904);
|
||||
ASSERT_REG_POSITION(tex_cb_index, 0x982);
|
||||
ASSERT_REG_POSITION(ssbo_info, 0xD18);
|
||||
|
||||
#undef ASSERT_REG_POSITION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user