rpcsx/rpcs3/Emu/RSX/GL/GLProgramBuffer.h

61 lines
2 KiB
C
Raw Normal View History

2013-11-09 22:29:49 +01:00
#pragma once
#include "GLVertexProgram.h"
#include "GLFragmentProgram.h"
2015-05-16 01:10:27 +02:00
#include "../Common/ProgramStateCache.h"
2013-11-09 22:29:49 +01:00
2015-05-16 01:10:27 +02:00
struct GLTraits
2013-11-09 22:29:49 +01:00
{
using vertex_program_type = GLVertexProgram;
using fragment_program_type = GLFragmentProgram;
using pipeline_storage_type = gl::glsl::program;
using pipeline_properties = void*;
2013-11-09 22:29:49 +01:00
2015-05-16 01:10:27 +02:00
static
void recompile_fragment_program(const RSXFragmentProgram &RSXFP, fragment_program_type& fragmentProgramData, size_t ID)
2015-05-16 01:10:27 +02:00
{
fragmentProgramData.Decompile(RSXFP);
2015-05-16 01:10:27 +02:00
fragmentProgramData.Compile();
//checkForGlError("m_fragment_prog.Compile");
fs::file(fs::get_config_dir() + "shaderlog/FragmentProgram.glsl", fs::rewrite).write(fragmentProgramData.shader);
2015-05-16 01:10:27 +02:00
}
static
void recompile_vertex_program(const RSXVertexProgram &RSXVP, vertex_program_type& vertexProgramData, size_t ID)
2015-05-16 01:10:27 +02:00
{
vertexProgramData.Decompile(RSXVP);
2015-05-16 01:10:27 +02:00
vertexProgramData.Compile();
//checkForGlError("m_vertex_prog.Compile");
fs::file(fs::get_config_dir() + "shaderlog/VertexProgram.glsl", fs::rewrite).write(vertexProgramData.shader);
2015-05-16 01:10:27 +02:00
}
2013-11-09 22:29:49 +01:00
2015-05-16 01:10:27 +02:00
static
pipeline_storage_type build_pipeline(const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties &pipelineProperties)
2015-05-16 01:10:27 +02:00
{
pipeline_storage_type result;
__glcheck result.create()
.attach(gl::glsl::shader_view(vertexProgramData.id))
.attach(gl::glsl::shader_view(fragmentProgramData.id))
.bind_fragment_data_location("ocol0", 0)
.bind_fragment_data_location("ocol1", 1)
.bind_fragment_data_location("ocol2", 2)
.bind_fragment_data_location("ocol3", 3)
.make();
__glcheck result.use();
2013-11-09 22:29:49 +01:00
LOG_NOTICE(RSX, "*** prog id = %d", result.id());
2015-05-16 01:10:27 +02:00
LOG_NOTICE(RSX, "*** vp id = %d", vertexProgramData.id);
LOG_NOTICE(RSX, "*** fp id = %d", fragmentProgramData.id);
2013-11-09 22:29:49 +01:00
2015-05-16 01:10:27 +02:00
LOG_NOTICE(RSX, "*** vp shader = \n%s", vertexProgramData.shader.c_str());
LOG_NOTICE(RSX, "*** fp shader = \n%s", fragmentProgramData.shader.c_str());
2013-11-09 22:29:49 +01:00
2015-05-16 01:10:27 +02:00
return result;
}
};
class GLProgramBuffer : public program_state_cache<GLTraits>
2015-05-16 01:10:27 +02:00
{
};