shader: Fix VertexA Shaders.
This commit is contained in:
parent
ec9a78885e
commit
562af30181
|
@ -171,20 +171,29 @@ IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b
|
||||||
IR::Program result{};
|
IR::Program result{};
|
||||||
Optimization::VertexATransformPass(vertex_a);
|
Optimization::VertexATransformPass(vertex_a);
|
||||||
Optimization::VertexBTransformPass(vertex_b);
|
Optimization::VertexBTransformPass(vertex_b);
|
||||||
std::swap(result.blocks, vertex_a.blocks);
|
for (const auto& term : vertex_a.syntax_list) {
|
||||||
result.blocks.insert(result.blocks.end(), vertex_b.blocks.begin(), vertex_b.blocks.end());
|
if (term.type == IR::AbstractSyntaxNode::Type::Return) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
result.syntax_list.push_back(term);
|
||||||
|
}
|
||||||
|
for (const auto& term : vertex_b.syntax_list) {
|
||||||
|
result.syntax_list.push_back(term);
|
||||||
|
}
|
||||||
|
result.blocks = GenerateBlocks(result.syntax_list);
|
||||||
|
result.post_order_blocks = vertex_b.post_order_blocks;
|
||||||
|
for (const auto& block : vertex_a.post_order_blocks) {
|
||||||
|
result.post_order_blocks.push_back(block);
|
||||||
|
}
|
||||||
result.stage = Stage::VertexB;
|
result.stage = Stage::VertexB;
|
||||||
result.info = vertex_a.info;
|
result.info = vertex_a.info;
|
||||||
result.local_memory_size = std::max(vertex_a.local_memory_size, vertex_b.local_memory_size);
|
result.local_memory_size = std::max(vertex_a.local_memory_size, vertex_b.local_memory_size);
|
||||||
|
|
||||||
for (size_t index = 0; index < 32; ++index) {
|
for (size_t index = 0; index < 32; ++index) {
|
||||||
result.info.input_generics[index].used |= vertex_b.info.input_generics[index].used;
|
result.info.input_generics[index].used |= vertex_b.info.input_generics[index].used;
|
||||||
result.info.stores_generics[index] |= vertex_b.info.stores_generics[index];
|
result.info.stores_generics[index] |= vertex_b.info.stores_generics[index];
|
||||||
}
|
}
|
||||||
Optimization::JoinTextureInfo(result.info, vertex_b.info);
|
Optimization::JoinTextureInfo(result.info, vertex_b.info);
|
||||||
Optimization::JoinStorageInfo(result.info, vertex_b.info);
|
Optimization::JoinStorageInfo(result.info, vertex_b.info);
|
||||||
Optimization::DualVertexJoinPass(result);
|
|
||||||
result.post_order_blocks = PostOrder(result.syntax_list.front());
|
|
||||||
Optimization::DeadCodeEliminationPass(result);
|
Optimization::DeadCodeEliminationPass(result);
|
||||||
Optimization::VerificationPass(result);
|
Optimization::VerificationPass(result);
|
||||||
Optimization::CollectShaderInfoPass(env_vertex_b, result);
|
Optimization::CollectShaderInfoPass(env_vertex_b, result);
|
||||||
|
|
|
@ -13,16 +13,24 @@
|
||||||
|
|
||||||
namespace Shader::Optimization {
|
namespace Shader::Optimization {
|
||||||
|
|
||||||
void VertexATransformPass(IR::Program&) {
|
void VertexATransformPass(IR::Program& program) {
|
||||||
throw NotImplementedException("VertexA pass");
|
for (IR::Block* const block : program.blocks) {
|
||||||
|
for (IR::Inst& inst : block->Instructions()) {
|
||||||
|
if (inst.GetOpcode() == IR::Opcode::Epilogue) {
|
||||||
|
return inst.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexBTransformPass(IR::Program&) {
|
void VertexBTransformPass(IR::Program& program) {
|
||||||
throw NotImplementedException("VertexA pass");
|
for (IR::Block* const block : program.blocks) {
|
||||||
}
|
for (IR::Inst& inst : block->Instructions()) {
|
||||||
|
if (inst.GetOpcode() == IR::Opcode::Prologue) {
|
||||||
void DualVertexJoinPass(IR::Program&) {
|
return inst.Invalidate();
|
||||||
throw NotImplementedException("VertexA pass");
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Shader::Optimization
|
} // namespace Shader::Optimization
|
||||||
|
|
|
@ -25,7 +25,6 @@ void VerificationPass(const IR::Program& program);
|
||||||
// Dual Vertex
|
// Dual Vertex
|
||||||
void VertexATransformPass(IR::Program& program);
|
void VertexATransformPass(IR::Program& program);
|
||||||
void VertexBTransformPass(IR::Program& program);
|
void VertexBTransformPass(IR::Program& program);
|
||||||
void DualVertexJoinPass(IR::Program& program);
|
|
||||||
void JoinTextureInfo(Info& base, Info& source);
|
void JoinTextureInfo(Info& base, Info& source);
|
||||||
void JoinStorageInfo(Info& base, Info& source);
|
void JoinStorageInfo(Info& base, Info& source);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace OpenGL {
|
||||||
namespace {
|
namespace {
|
||||||
using Shader::Backend::GLASM::EmitGLASM;
|
using Shader::Backend::GLASM::EmitGLASM;
|
||||||
using Shader::Backend::SPIRV::EmitSPIRV;
|
using Shader::Backend::SPIRV::EmitSPIRV;
|
||||||
|
using Shader::Maxwell::MergeDualVertexPrograms;
|
||||||
using Shader::Maxwell::TranslateProgram;
|
using Shader::Maxwell::TranslateProgram;
|
||||||
using VideoCommon::ComputeEnvironment;
|
using VideoCommon::ComputeEnvironment;
|
||||||
using VideoCommon::FileEnvironment;
|
using VideoCommon::FileEnvironment;
|
||||||
|
@ -446,6 +447,8 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
|
||||||
size_t env_index{};
|
size_t env_index{};
|
||||||
u32 total_storage_buffers{};
|
u32 total_storage_buffers{};
|
||||||
std::array<Shader::IR::Program, Maxwell::MaxShaderProgram> programs;
|
std::array<Shader::IR::Program, Maxwell::MaxShaderProgram> programs;
|
||||||
|
const bool uses_vertex_a{key.unique_hashes[0] != 0};
|
||||||
|
const bool uses_vertex_b{key.unique_hashes[1] != 0};
|
||||||
for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) {
|
for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) {
|
||||||
if (key.unique_hashes[index] == 0) {
|
if (key.unique_hashes[index] == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -454,12 +457,23 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
|
||||||
++env_index;
|
++env_index;
|
||||||
|
|
||||||
const u32 cfg_offset{static_cast<u32>(env.StartAddress() + sizeof(Shader::ProgramHeader))};
|
const u32 cfg_offset{static_cast<u32>(env.StartAddress() + sizeof(Shader::ProgramHeader))};
|
||||||
Shader::Maxwell::Flow::CFG cfg(env, pools.flow_block, cfg_offset);
|
Shader::Maxwell::Flow::CFG cfg(env, pools.flow_block, cfg_offset, index == 0);
|
||||||
|
if (!uses_vertex_a || index != 1) {
|
||||||
|
// Normal path
|
||||||
programs[index] = TranslateProgram(pools.inst, pools.block, env, cfg);
|
programs[index] = TranslateProgram(pools.inst, pools.block, env, cfg);
|
||||||
|
|
||||||
for (const auto& desc : programs[index].info.storage_buffers_descriptors) {
|
for (const auto& desc : programs[index].info.storage_buffers_descriptors) {
|
||||||
total_storage_buffers += desc.count;
|
total_storage_buffers += desc.count;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// VertexB path when VertexA is present.
|
||||||
|
Shader::IR::Program& program_va{programs[0]};
|
||||||
|
Shader::IR::Program program_vb{TranslateProgram(pools.inst, pools.block, env, cfg)};
|
||||||
|
for (const auto& desc : program_vb.info.storage_buffers_descriptors) {
|
||||||
|
total_storage_buffers += desc.count;
|
||||||
|
}
|
||||||
|
programs[index] = MergeDualVertexPrograms(program_va, program_vb, env);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const u32 glasm_storage_buffer_limit{device.GetMaxGLASMStorageBufferBlocks()};
|
const u32 glasm_storage_buffer_limit{device.GetMaxGLASMStorageBufferBlocks()};
|
||||||
const bool glasm_use_storage_buffers{total_storage_buffers <= glasm_storage_buffer_limit};
|
const bool glasm_use_storage_buffers{total_storage_buffers <= glasm_storage_buffer_limit};
|
||||||
|
@ -472,7 +486,9 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
|
||||||
if (!device.UseAssemblyShaders()) {
|
if (!device.UseAssemblyShaders()) {
|
||||||
source_program.handle = glCreateProgram();
|
source_program.handle = glCreateProgram();
|
||||||
}
|
}
|
||||||
for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) {
|
|
||||||
|
for (size_t index = uses_vertex_a && uses_vertex_b ? 1 : 0; index < Maxwell::MaxShaderProgram;
|
||||||
|
++index) {
|
||||||
if (key.unique_hashes[index] == 0) {
|
if (key.unique_hashes[index] == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue