gsdx-ogl:

* add a new define (DISABLE_DUAL_BLEND) to easily test blend mode


git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@5040 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2012-01-03 16:12:34 +00:00
parent 90c52c27f6
commit cc6e486742
3 changed files with 66 additions and 27 deletions

View File

@ -54,10 +54,13 @@
//#define LOUD_DEBUGGING
#define SHADER_DEBUG
#define DUMP_START (70)
#define DUMP_LENGTH (130)
//#define DUMP_START (70)
//#define DUMP_LENGTH (130)
//#define DUMP_ONLY_FRAME (112)
// It seems dual blending does not work (at least on AMD)
//#define DISABLE_DUAL_BLEND
#ifdef DUMP_START
static uint32 g_draw_count = 0;
static uint32 g_frame_count = 0;
@ -527,22 +530,15 @@ void GSDeviceOGL::DrawPrimitive()
}
if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_in_%d.bmp", g_draw_count));
string topo;
switch (m_state.topology) {
case GL_TRIANGLE_STRIP: topo = "triangle_strip"; break;
case GL_TRIANGLES: topo = "triangle"; break;
case GL_LINES: topo = "line"; break;
case GL_POINTS: topo = "point"; break;
default: topo = "!!!!";
}
fprintf(stderr, "Draw %d (Frame %d), %d elem of %s\n", g_draw_count, g_frame_count, m_state.vb_state->get_count(), topo.c_str() );
fprintf(stderr, "Draw %d (Frame %d)\n", g_draw_count, g_frame_count);
fprintf(stderr, "vs: %d ; gs: %d ; ps: %d\n", m_state.vs, m_state.gs, m_state.ps);
m_state.vb->debug();
m_state.bs->debug();
m_state.dss->debug();
}
#endif
m_state.vb_state->draw_arrays(m_state.topology);
m_state.vb->draw_arrays();
// DUMP OUTPUT
#ifdef DUMP_START
@ -956,7 +952,7 @@ GSTexture* GSDeviceOGL::Resolve(GSTexture* t)
void GSDeviceOGL::EndScene()
{
m_state.vb_state->draw_done();
m_state.vb->draw_done();
}
void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb)
@ -967,22 +963,22 @@ void GSDeviceOGL::SetUniformBuffer(GSUniformBufferOGL* cb)
}
}
void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb_state)
void GSDeviceOGL::IASetVertexState(GSVertexBufferStateOGL* vb)
{
if (m_state.vb_state != vb_state) {
m_state.vb_state = vb_state;
vb_state->bind();
if (m_state.vb != vb) {
m_state.vb = vb;
vb->bind();
}
}
void GSDeviceOGL::IASetVertexBuffer(const void* vertices, size_t count)
{
m_state.vb_state->upload(vertices, count);
m_state.vb->upload(vertices, count);
}
void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology)
{
m_state.topology = topology;
m_state.vb->SetTopology(topology);
}
void GSDeviceOGL::VSSetShader(GLuint vs)
@ -1190,6 +1186,9 @@ void GSDeviceOGL::CompileShaderFromSource(const std::string& glsl_file, const st
std::string entry_main = format("#define %s main\n", entry.c_str());
std::string header = version + shader_type + entry_main + macro_sel;
#ifdef DISABLE_DUAL_BLEND
header += "#define DISABLE_DUAL_BLEND 1\n";
#endif
// *****************************************************
// Read the source file
@ -1343,13 +1342,19 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi
#define D3DBLEND_ONE GL_ONE
#define D3DBLEND_ZERO GL_ZERO
#define D3DBLEND_SRCALPHA GL_SRC1_ALPHA
#define D3DBLEND_INVDESTALPHA GL_ONE_MINUS_DST_ALPHA
#define D3DBLEND_DESTALPHA GL_DST_ALPHA
#define D3DBLEND_DESTCOLOR GL_DST_COLOR
#define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC1_ALPHA
#define D3DBLEND_BLENDFACTOR GL_CONSTANT_COLOR
#define D3DBLEND_INVBLENDFACTOR GL_ONE_MINUS_CONSTANT_COLOR
#ifdef DISABLE_DUAL_BLEND
#define D3DBLEND_SRCALPHA GL_SRC_ALPHA
#define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC_ALPHA
#else
#define D3DBLEND_SRCALPHA GL_SRC1_ALPHA
#define D3DBLEND_INVSRCALPHA GL_ONE_MINUS_SRC1_ALPHA
#endif
const GSDeviceOGL::D3D9Blend GSDeviceOGL::m_blendMapD3D9[3*3*3*3] =
{

View File

@ -118,10 +118,12 @@ public:
case GL_ONE: return "ONE";
case GL_ZERO: return "ZERO";
case GL_SRC1_ALPHA: return "SRC1 ALPHA";
case GL_SRC_ALPHA: return "SRC ALPHA";
case GL_ONE_MINUS_DST_ALPHA: return "1 - DST ALPHA";
case GL_DST_ALPHA: return "DST ALPHA";
case GL_DST_COLOR: return "DST COLOR";
case GL_ONE_MINUS_SRC1_ALPHA: return "1 - SRC1 ALPHA";
case GL_ONE_MINUS_SRC_ALPHA: return "1 - SRC ALPHA";
case GL_CONSTANT_COLOR: return "CST";
case GL_ONE_MINUS_CONSTANT_COLOR: return "1 - CST";
default: return "UKN";
@ -283,6 +285,7 @@ class GSVertexBufferStateOGL {
GLuint m_vb;
GLuint m_va;
const GLenum m_target;
GLenum m_topology;
void allocate(size_t new_limit)
{
@ -359,9 +362,9 @@ public:
}
}
void draw_arrays(GLenum topology)
void draw_arrays()
{
glDrawArrays(topology, m_start, m_count);
glDrawArrays(m_topology, m_start, m_count);
}
void draw_done()
@ -370,13 +373,39 @@ public:
m_count = 0;
}
uint32 get_count() { return m_count; }
void SetTopology(GLenum topology) { m_topology = topology; }
~GSVertexBufferStateOGL()
{
glDeleteBuffers(1, &m_vb);
glDeleteVertexArrays(1, &m_va);
}
void debug()
{
uint32 element;
string topo;
switch (m_topology) {
case GL_POINTS:
element = m_count;
topo = "point";
break;
case GL_LINES:
element = m_count/2;
topo = "line";
break;
case GL_TRIANGLES:
element = m_count/3;
topo = "triangle";
break;
case GL_TRIANGLE_STRIP:
element = m_count - 3;
topo = "triangle strip";
break;
}
fprintf(stderr, "%d elements of %s\n", element, topo.c_str());
}
};
class GSDeviceOGL : public GSDevice
@ -662,8 +691,7 @@ class GSDeviceOGL : public GSDevice
struct
{
GSVertexBufferStateOGL* vb_state;
GLenum topology; // (ie GL_TRIANGLES...)
GSVertexBufferStateOGL* vb;
GLuint vs; // program
GSUniformBufferOGL* cb; // uniform current buffer
GLuint gs; // program
@ -778,7 +806,7 @@ class GSDeviceOGL : public GSDevice
void IASetPrimitiveTopology(GLenum topology);
void IASetVertexBuffer(const void* vertices, size_t count);
void IASetVertexState(GSVertexBufferStateOGL* vb_state);
void IASetVertexState(GSVertexBufferStateOGL* vb);
void SetUniformBuffer(GSUniformBufferOGL* cb);

View File

@ -257,8 +257,12 @@ void gs_main()
layout(location = 0) in vertex PSin;
// Same buffer but 2 colors for dual source blending
#ifndef DISABLE_DUAL_BLEND
layout(location = 0, index = 1) out vec4 SV_Target0;
layout(location = 0, index = 0) out vec4 SV_Target1;
#else
layout(location = 0) out vec4 SV_Target1;
#endif
layout(binding = 0) uniform sampler2D TextureSampler;
layout(binding = 1) uniform sampler2D PaletteSampler;
@ -619,7 +623,9 @@ void ps_main()
// FIXME: I'm not sure about the value of others field
// output.c1 = c.a * 2; // used for alpha blending
#ifndef DISABLE_DUAL_BLEND
SV_Target0 = vec4(c.a*2, c.a*2, c.a*2, c.a * 2);
#endif
if(PS_AOUT != 0) // 16 bit output
{