mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 10:42:47 +01:00
gl_shader_gen: Add uniform handling for indirect const buffer access.
This commit is contained in:
parent
6e386a334b
commit
4112aa68a6
3 changed files with 40 additions and 4 deletions
|
@ -654,7 +654,16 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr
|
||||||
buffer_draw_state.bindpoint = current_bindpoint + bindpoint;
|
buffer_draw_state.bindpoint = current_bindpoint + bindpoint;
|
||||||
|
|
||||||
boost::optional<VAddr> addr = gpu.memory_manager->GpuToCpuAddress(buffer.address);
|
boost::optional<VAddr> addr = gpu.memory_manager->GpuToCpuAddress(buffer.address);
|
||||||
std::vector<u8> data(used_buffer.GetSize() * sizeof(float));
|
|
||||||
|
std::vector<u8> data;
|
||||||
|
if (used_buffer.IsIndirect()) {
|
||||||
|
// Buffer is accessed indirectly, so upload the entire thing
|
||||||
|
data.resize(buffer.size * sizeof(float));
|
||||||
|
} else {
|
||||||
|
// Buffer is accessed directly, upload just what we use
|
||||||
|
data.resize(used_buffer.GetSize() * sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
Memory::ReadBlock(*addr, data.data(), data.size());
|
Memory::ReadBlock(*addr, data.data(), data.size());
|
||||||
|
|
||||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_draw_state.ssbo);
|
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_draw_state.ssbo);
|
||||||
|
|
|
@ -377,6 +377,21 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetUniformIndirect(u64 index, s64 offset, const Register& index_reg,
|
||||||
|
GLSLRegister::Type type) {
|
||||||
|
declr_const_buffers[index].MarkAsUsedIndirect(index, stage);
|
||||||
|
std::string value = 'c' + std::to_string(index) + "[(floatBitsToInt(" +
|
||||||
|
GetRegister(index_reg, 0) + ") + " + std::to_string(offset) + ") / 4]";
|
||||||
|
|
||||||
|
if (type == GLSLRegister::Type::Float) {
|
||||||
|
return value;
|
||||||
|
} else if (type == GLSLRegister::Type::Integer) {
|
||||||
|
return "floatBitsToInt(" + value + ')';
|
||||||
|
} else {
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Add declarations for registers
|
/// Add declarations for registers
|
||||||
void GenerateDeclarations() {
|
void GenerateDeclarations() {
|
||||||
for (const auto& reg : regs) {
|
for (const auto& reg : regs) {
|
||||||
|
|
|
@ -22,17 +22,28 @@ class ConstBufferEntry {
|
||||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void MarkAsUsed(unsigned index, unsigned offset, Maxwell::ShaderStage stage) {
|
void MarkAsUsed(u64 index, u64 offset, Maxwell::ShaderStage stage) {
|
||||||
is_used = true;
|
is_used = true;
|
||||||
this->index = index;
|
this->index = static_cast<unsigned>(index);
|
||||||
|
this->stage = stage;
|
||||||
|
max_offset = std::max(max_offset, static_cast<unsigned>(offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MarkAsUsedIndirect(u64 index, Maxwell::ShaderStage stage) {
|
||||||
|
is_used = true;
|
||||||
|
is_indirect = true;
|
||||||
|
this->index = static_cast<unsigned>(index);
|
||||||
this->stage = stage;
|
this->stage = stage;
|
||||||
max_offset = std::max(max_offset, offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsUsed() const {
|
bool IsUsed() const {
|
||||||
return is_used;
|
return is_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsIndirect() const {
|
||||||
|
return is_indirect;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned GetIndex() const {
|
unsigned GetIndex() const {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +62,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_used{};
|
bool is_used{};
|
||||||
|
bool is_indirect{};
|
||||||
unsigned index{};
|
unsigned index{};
|
||||||
unsigned max_offset{};
|
unsigned max_offset{};
|
||||||
Maxwell::ShaderStage stage;
|
Maxwell::ShaderStage stage;
|
||||||
|
|
Loading…
Reference in a new issue