mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl:
* add some dummy shader. Can be modify inside the debugger apitrace * glclear* commands` seem to depend on scissor test and depth mask. Allow full write for the depth buffer * texture debug, try to output some nice colors for the depth buffers git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5365 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
7ff8abe376
commit
636c16f2df
|
@ -584,7 +584,7 @@ void GSDeviceOGL::DebugOutput()
|
|||
} else {
|
||||
if (m_state.rtv != NULL) m_state.rtv->Save(format("/tmp/out_f%d__d%d__tex.bmp", g_frame_count, g_draw_count));
|
||||
}
|
||||
//if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count));
|
||||
if (m_state.dsv != NULL) m_state.dsv->Save(format("/tmp/ds_out_%d.bmp", g_draw_count));
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
//DebugBB();
|
||||
|
@ -668,7 +668,17 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
|
|||
OMSetFBO(m_fbo);
|
||||
static_cast<GSTextureOGL*>(t)->Attach(GL_DEPTH_STENCIL_ATTACHMENT);
|
||||
// FIXME can you clean depth and stencil separately
|
||||
// XXX: glClear* depends on the scissor test!!! Disable it because the viewport
|
||||
// could be smaller than the texture and we really want to clean all pixels.
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
if (m_state.dss != NULL && m_state.dss->IsMaskEnable()) {
|
||||
glClearBufferfv(GL_DEPTH, 0, &c);
|
||||
} else {
|
||||
glDepthMask(true);
|
||||
glClearBufferfv(GL_DEPTH, 0, &c);
|
||||
glDepthMask(false);
|
||||
}
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
OMSetFBO(fbo_old);
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,8 @@ public:
|
|||
if (!m_stencil_enable) return;
|
||||
fprintf(stderr, "Stencil %s. Both pass op %s\n", NameOfParam(m_stencil_func), NameOfParam(m_stencil_spass_dpass_op));
|
||||
}
|
||||
|
||||
bool IsMaskEnable() { return m_depth_mask; }
|
||||
};
|
||||
|
||||
class GSDeviceOGL : public GSDevice
|
||||
|
|
|
@ -46,21 +46,6 @@ void GSDeviceOGL::CreateTextureFX()
|
|||
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
||||
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
|
||||
|
||||
//{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
//{"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
//float2 t : TEXCOORD0;
|
||||
//float q : TEXCOORD1;
|
||||
//
|
||||
//{"POSITION", 0, DXGI_FORMAT_R16G16_UINT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
//{"POSITION", 1, DXGI_FORMAT_R32_UINT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
//uint2 p : POSITION0;
|
||||
//uint z : POSITION1;
|
||||
//
|
||||
//{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
//{"COLOR", 1, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
//float4 c : COLOR0;
|
||||
//float4 f : COLOR1;
|
||||
|
||||
GSInputLayoutOGL vert_format[] =
|
||||
{
|
||||
// FIXME
|
||||
|
@ -74,6 +59,13 @@ void GSDeviceOGL::CreateTextureFX()
|
|||
{6 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertex) , (const GLvoid*)(28) } ,
|
||||
};
|
||||
m_vb = new GSVertexBufferStateOGL(sizeof(GSVertex), vert_format, countof(vert_format));
|
||||
|
||||
// Compile some dummy shaders to allow modification inside Apitrace for debug
|
||||
GLuint dummy;
|
||||
std::string macro = "";
|
||||
CompileShaderFromSource("tfx.glsl", "vs_main", GL_VERTEX_SHADER, &dummy, macro);
|
||||
CompileShaderFromSource("tfx.glsl", "gs_main", GL_GEOMETRY_SHADER, &dummy, macro);
|
||||
CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &dummy, macro);
|
||||
}
|
||||
|
||||
void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <limits.h>
|
||||
#include "GSTextureOGL.h"
|
||||
static int g_state_texture_unit = -1;
|
||||
static int g_state_texture_id = -1;
|
||||
|
@ -372,16 +373,22 @@ void GSTextureOGL::Save(const string& fn, const void* image, uint32 pitch)
|
|||
|
||||
for(int h = m_size.y; h > 0; h--, data -= pitch)
|
||||
{
|
||||
if (IsDss()) {
|
||||
if (false && IsDss()) {
|
||||
// Only get the depth and convert it to an integer
|
||||
uint8* better_data = data;
|
||||
for (int w = m_size.x; w > 0; w--, better_data += 8) {
|
||||
float* input = (float*)better_data;
|
||||
// FIXME how to dump 32 bits value into 8bits component color
|
||||
uint32 depth = (uint32)ldexpf(*input, 32);
|
||||
uint8 small_depth = depth >> 24;
|
||||
uint8 better_data[4] = {small_depth, small_depth, small_depth, 0 };
|
||||
fwrite(&better_data, 1, 4, fp);
|
||||
GLuint depth_integer = (GLuint)(*input * (float)UINT_MAX);
|
||||
uint8 r = (depth_integer >> 0) & 0xFF;
|
||||
uint8 g = (depth_integer >> 8) & 0xFF;
|
||||
uint8 b = (depth_integer >> 16) & 0xFF;
|
||||
uint8 a = (depth_integer >> 24) & 0xFF;
|
||||
|
||||
fwrite(&r, 1, 1, fp);
|
||||
fwrite(&g, 1, 1, fp);
|
||||
fwrite(&b, 1, 1, fp);
|
||||
fwrite(&a, 1, 1, fp);
|
||||
}
|
||||
} else {
|
||||
// swap red and blue
|
||||
|
@ -402,7 +409,6 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
|
|||
{
|
||||
// Collect the texture data
|
||||
uint32 pitch = 4 * m_size.x;
|
||||
if (IsDss()) pitch *= 2;
|
||||
char* image = (char*)malloc(pitch * m_size.y);
|
||||
bool status = true;
|
||||
|
||||
|
@ -413,8 +419,14 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
|
|||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
} else if(IsDss()) {
|
||||
EnableUnit(0);
|
||||
glGetTexImage(m_texture_target, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, image);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
||||
|
||||
//EnableUnit(0);
|
||||
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0);
|
||||
glReadPixels(0, 0, m_size.x, m_size.y, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image);
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
} else {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define VS_BPPZ 0
|
||||
#define VS_TME 1
|
||||
#define VS_FST 1
|
||||
#define VS_LOGZ 0
|
||||
#endif
|
||||
|
||||
#ifndef GS_IIP
|
||||
|
@ -57,7 +58,7 @@ layout(location = 6) in vec4 i_f;
|
|||
layout(location = 0) out vertex VSout;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
invariant vec4 gl_Position;
|
||||
float gl_PointSize;
|
||||
float gl_ClipDistance[];
|
||||
};
|
||||
|
@ -542,16 +543,13 @@ void atst(vec4 c)
|
|||
{
|
||||
// nothing to do
|
||||
}
|
||||
else if(PS_ATST == 2)
|
||||
{
|
||||
}
|
||||
else if(PS_ATST == 2 ) // l
|
||||
{
|
||||
if (PS_SPRITEHACK == 0)
|
||||
if ((AREF - a) < 0.0f)
|
||||
discard;
|
||||
}
|
||||
else if(PS_ATST == 2 ) // le
|
||||
else if(PS_ATST == 3 ) // le
|
||||
{
|
||||
if ((AREF - a) < 0.0f)
|
||||
discard;
|
||||
|
|
Loading…
Reference in New Issue