Remove fragment program

This commit is contained in:
Vincent Lejeune 2015-10-11 19:50:59 +02:00
parent 67f1f0fea3
commit 1e431edf09
6 changed files with 14 additions and 32 deletions

View File

@ -314,7 +314,7 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
void D3D12GSRender::FillPixelShaderConstantsBuffer() void D3D12GSRender::FillPixelShaderConstantsBuffer()
{ {
// Get constant from fragment program // Get constant from fragment program
const std::vector<size_t> &fragmentOffset = m_cachePSO.getFragmentConstantOffsetsCache(m_cur_fragment_prog); const std::vector<size_t> &fragmentOffset = m_cachePSO.getFragmentConstantOffsetsCache(&fragment_program);
size_t bufferSize = fragmentOffset.size() * 4 * sizeof(float) + 1; size_t bufferSize = fragmentOffset.size() * 4 * sizeof(float) + 1;
// Multiple of 256 never 0 // Multiple of 256 never 0
bufferSize = (bufferSize + 255) & ~255; bufferSize = (bufferSize + 255) & ~255;
@ -333,7 +333,7 @@ void D3D12GSRender::FillPixelShaderConstantsBuffer()
bool isCommandBufferSetConstant = false; bool isCommandBufferSetConstant = false;
for (const auto& entry : fragment_constants) for (const auto& entry : fragment_constants)
{ {
size_t fragmentId = entry.first - m_cur_fragment_prog->offset; size_t fragmentId = entry.first - fragment_program.offset;
if (fragmentId == offsetInFP) if (fragmentId == offsetInFP)
{ {
isCommandBufferSetConstant = true; isCommandBufferSetConstant = true;
@ -346,7 +346,7 @@ void D3D12GSRender::FillPixelShaderConstantsBuffer()
} }
if (!isCommandBufferSetConstant) if (!isCommandBufferSetConstant)
{ {
auto data = vm::ps3::ptr<u32>::make(m_cur_fragment_prog->addr + (u32)offsetInFP); auto data = vm::ps3::ptr<u32>::make(fragment_program.addr + (u32)offsetInFP);
u32 c0 = (data[0] >> 16 | data[0] << 16); u32 c0 = (data[0] >> 16 | data[0] << 16);
u32 c1 = (data[1] >> 16 | data[1] << 16); u32 c1 = (data[1] >> 16 | data[1] << 16);

View File

@ -310,6 +310,7 @@ private:
// Copy of RTT to be used as texture // Copy of RTT to be used as texture
std::unordered_map<u32, ID3D12Resource* > m_texturesRTTs; std::unordered_map<u32, ID3D12Resource* > m_texturesRTTs;
RSXFragmentProgram fragment_program;
PipelineStateObjectCache m_cachePSO; PipelineStateObjectCache m_cachePSO;
std::pair<ID3D12PipelineState *, size_t> *m_PSO; std::pair<ID3D12PipelineState *, size_t> *m_PSO;

View File

@ -52,16 +52,10 @@ void D3D12GSRender::notifyRasterizerStateChange()
bool D3D12GSRender::LoadProgram() bool D3D12GSRender::LoadProgram()
{ {
if (m_PSO != nullptr) u32 shader_program = rsx::method_registers[NV4097_SET_SHADER_PROGRAM];
return true; fragment_program.offset = shader_program & ~0x3;
fragment_program.addr = rsx::get_address(fragment_program.offset, (shader_program & 0x3) - 1);
if (!m_cur_fragment_prog) fragment_program.ctrl = rsx::method_registers[NV4097_SET_SHADER_CONTROL];
{
LOG_WARNING(RSX, "LoadProgram: m_cur_shader_prog == NULL");
return false;
}
m_cur_fragment_prog->ctrl = m_shader_ctrl;
if (!m_cur_vertex_prog) if (!m_cur_vertex_prog)
{ {
@ -306,7 +300,7 @@ bool D3D12GSRender::LoadProgram()
prop.IASet = m_IASet; prop.IASet = m_IASet;
m_PSO = m_cachePSO.getGraphicPipelineState(m_cur_vertex_prog, m_cur_fragment_prog, prop, std::make_pair(m_device.Get(), m_rootSignatures)); m_PSO = m_cachePSO.getGraphicPipelineState(m_cur_vertex_prog, &fragment_program, prop, std::make_pair(m_device.Get(), m_rootSignatures));
return m_PSO != nullptr; return m_PSO != nullptr;
} }

View File

@ -1062,7 +1062,7 @@ void GLGSRender::InitVertexData()
void GLGSRender::InitFragmentData() void GLGSRender::InitFragmentData()
{ {
if (!m_cur_fragment_prog) /* if (!m_cur_fragment_prog)
{ {
LOG_ERROR(RSX, "InitFragmentData: m_cur_shader_prog == NULL"); LOG_ERROR(RSX, "InitFragmentData: m_cur_shader_prog == NULL");
return; return;
@ -1088,7 +1088,7 @@ void GLGSRender::InitFragmentData()
float f3 = (float&)c3; float f3 = (float&)c3;
glUniform4f(l, f0, f1, f2, f3); glUniform4f(l, f0, f1, f2, f3);
checkForGlError("glUniform4f " + name + fmt::format(" %u [%f %f %f %f]", l, f0, f1, f2, f3)); checkForGlError("glUniform4f " + name + fmt::format(" %u [%f %f %f %f]", l, f0, f1, f2, f3));
} }*/
/* for (const RSXTransformConstant& c : m_fragment_constants) /* for (const RSXTransformConstant& c : m_fragment_constants)
{ {
@ -1111,7 +1111,7 @@ void GLGSRender::InitFragmentData()
bool GLGSRender::LoadProgram() bool GLGSRender::LoadProgram()
{ {
if (!m_cur_fragment_prog) /* if (!m_cur_fragment_prog)
{ {
LOG_WARNING(RSX, "LoadProgram: m_cur_shader_prog == NULL"); LOG_WARNING(RSX, "LoadProgram: m_cur_shader_prog == NULL");
return false; return false;
@ -1127,7 +1127,7 @@ bool GLGSRender::LoadProgram()
GLProgram *result = m_prog_buffer.getGraphicPipelineState(m_cur_vertex_prog, m_cur_fragment_prog, nullptr, nullptr); GLProgram *result = m_prog_buffer.getGraphicPipelineState(m_cur_vertex_prog, m_cur_fragment_prog, nullptr, nullptr);
m_program.id = result->id; m_program.id = result->id;
m_program.Use(); m_program.Use();*/
return true; return true;
} }

View File

@ -938,16 +938,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const
// Shader // Shader
case NV4097_SET_SHADER_PROGRAM: case NV4097_SET_SHADER_PROGRAM:
{
m_cur_fragment_prog = &m_fragment_progs[m_cur_fragment_prog_num];
const u32 a0 = ARGS(0);
m_cur_fragment_prog->offset = a0 & ~0x3;
m_cur_fragment_prog->addr = rsx::get_address(m_cur_fragment_prog->offset, (a0 & 0x3) - 1);
m_cur_fragment_prog->ctrl = 0x40;
notifyProgramChange(); notifyProgramChange();
break; break;
}
case NV4097_SET_SHADER_CONTROL: case NV4097_SET_SHADER_CONTROL:
{ {
@ -2146,7 +2138,6 @@ void RSXThread::End()
m_indexed_array.Reset(); m_indexed_array.Reset();
fragment_constants.clear(); fragment_constants.clear();
m_cur_fragment_prog_num = 0;
m_clear_surface_mask = 0; m_clear_surface_mask = 0;
m_begin_end = 0; m_begin_end = 0;
@ -2274,8 +2265,6 @@ void RSXThread::Init(const u32 ioAddress, const u32 ioSize, const u32 ctrlAddres
local_mem_addr = localAddress; local_mem_addr = localAddress;
m_cur_vertex_prog = nullptr; m_cur_vertex_prog = nullptr;
m_cur_fragment_prog = nullptr;
m_cur_fragment_prog_num = 0;
m_used_gcm_commands.clear(); m_used_gcm_commands.clear();

View File

@ -156,9 +156,7 @@ public:
std::unordered_map<u32, color4_base<f32>> transform_constants; std::unordered_map<u32, color4_base<f32>> transform_constants;
std::unordered_map<u32, color4_base<f32>> fragment_constants; std::unordered_map<u32, color4_base<f32>> fragment_constants;
u32 m_shader_ctrl, m_cur_fragment_prog_num; u32 m_shader_ctrl;
RSXFragmentProgram m_fragment_progs[rsx::limits::fragment_count];
RSXFragmentProgram* m_cur_fragment_prog;
RSXVertexProgram m_vertex_progs[rsx::limits::vertex_count]; RSXVertexProgram m_vertex_progs[rsx::limits::vertex_count];
RSXVertexProgram* m_cur_vertex_prog; RSXVertexProgram* m_cur_vertex_prog;