gsdx-ogl: only enable AMD hack when linking ps2 related shader. Otherwise SV_Target1 in convert is wrongly remapped

zzogl: check harder that the previous primitive exist.


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5232 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2012-05-26 09:58:37 +00:00
parent 1b099aedd1
commit c6d8af0c7f
6 changed files with 14 additions and 6 deletions

View File

@ -39,6 +39,7 @@ GSDeviceOGL::GSDeviceOGL()
, m_pipeline(0)
, m_fbo(0)
, m_fbo_read(0)
, m_enable_shader_AMD_hack(false)
, m_vb_sr(NULL)
, m_srv_changed(false)
, m_ss_changed(false)
@ -377,6 +378,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
// ****************************************************************
// HW renderer shader
// ****************************************************************
m_enable_shader_AMD_hack = true; // ....
CreateTextureFX();
// ****************************************************************
@ -1252,7 +1254,7 @@ GLuint GSDeviceOGL::glCreateShaderProgramv_AMD_BUG_WORKAROUND(GLenum type, GLs
if (compiled) {
glAttachShader(program, shader);
// HACK TO SET CORRECTLY THE INDEX
if (type == GL_FRAGMENT_SHADER) {
if (type == GL_FRAGMENT_SHADER && m_enable_shader_AMD_hack) {
glBindFragDataLocationIndexed(program, 0, 0, "SV_Target0");
glBindFragDataLocationIndexed(program, 0, 1, "SV_Target1");
}

View File

@ -481,6 +481,8 @@ class GSDeviceOGL : public GSDevice
GSVertexBufferStateOGL* m_vb; // vb_state for HW renderer
GSVertexBufferStateOGL* m_vb_sr; // vb_state for StretchRect
bool m_enable_shader_AMD_hack;
struct {
GLuint ps[2]; // program object
GSUniformBufferOGL* cb; // uniform buffer object

View File

@ -109,7 +109,7 @@ void ps_main1()
c.a *= 256.0f / 127.0f; // hm, 0.5 won't give us 1.0 if we just multiply with 2
highp uvec4 i = uvec4(c * vec4(0x001f, 0x03e0, 0x7c00, 0x8000));
highp uvec4 i = uvec4(c * vec4(uint(0x001f), uint(0x03e0), uint(0x7c00), uint(0x8000)));
SV_Target1 = (i.x & uint(0x001f)) | (i.y & uint(0x03e0)) | (i.z & uint(0x7c00)) | (i.w & uint(0x8000));
}

View File

@ -86,6 +86,10 @@ void vs_main()
// example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty
// input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel
// example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133
// Greg TEST
//float logz = log2(1+float(z))/32 * 0.999f;
//vec4 p = vec4(i_p, logz, 0) - vec4(0.05f, 0.05f, 0, 0);
vec4 p = vec4(i_p, z, 0) - vec4(0.05f, 0.05f, 0, 0);
vec4 final_p = p * VertexScale - VertexOffset;

View File

@ -145,7 +145,7 @@ void Kick::DrawPrim(u32 prim_type)
break;
case PRIM_LINE_STRIP:
if (likely(ValidPrevPrim)) {
if (likely(ValidPrevPrim) && curvb.nCount != 0) {
assert(curvb.nCount >= 1);
p[0] = p[-1];
} else {
@ -165,7 +165,7 @@ void Kick::DrawPrim(u32 prim_type)
break;
case PRIM_TRIANGLE_STRIP:
if (likely(ValidPrevPrim)) {
if (likely(ValidPrevPrim) && curvb.nCount != 0) {
assert(curvb.nCount >= 2);
p[0] = p[-2];
p[1] = p[-1];
@ -180,7 +180,7 @@ void Kick::DrawPrim(u32 prim_type)
break;
case PRIM_TRIANGLE_FAN:
if (likely(ValidPrevPrim)) {
if (likely(ValidPrevPrim) && curvb.nCount != 0) {
assert(curvb.nCount >= 2);
VertexGPU* TriFanVert = curvb.pBufferData + gs.nTriFanVert;
p[0] = TriFanVert[0];

View File

@ -51,7 +51,7 @@ class Kick
void Output_Vertex(VertexGPU vert, u32 id);
bool ValidPrevPrim;
public:
Kick() { }
Kick() : ValidPrevPrim(false) { }
~Kick() { }
void KickVertex(bool adc);