mirror of https://github.com/PCSX2/pcsx2.git
zzogl: plug vertex array object and remove most deprecated variable from shader. Only remains gl_FragData
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5210 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
7d7ca41187
commit
e7de58c3e2
|
@ -87,10 +87,12 @@ static __forceinline void GL_STENCILFUNC_SET()
|
|||
// sets the data stream
|
||||
static __forceinline void SET_STREAM()
|
||||
{
|
||||
#ifndef GLSL4_API
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8);
|
||||
glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12);
|
||||
glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16);
|
||||
glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// global alpha blending settings
|
||||
|
|
|
@ -682,6 +682,9 @@ bool ZZCreate(int _width, int _height)
|
|||
|
||||
glBufferDataARB(GL_ARRAY_BUFFER, 4*sizeof(VertexGPU), &verts[0], GL_STATIC_DRAW);
|
||||
|
||||
// FIXME Done inside ZZoglShadersGLSL4 for the moment
|
||||
// Move it later
|
||||
#ifndef GLSL4_API
|
||||
// setup the default vertex declaration
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
|
@ -689,6 +692,7 @@ bool ZZCreate(int _width, int _height)
|
|||
glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
GL_REPORT_ERROR();
|
||||
#endif
|
||||
|
||||
// some cards don't support this
|
||||
// glClientActiveTexture(GL_TEXTURE0);
|
||||
|
|
|
@ -61,6 +61,7 @@ inline bool ZZshActiveParameter(ZZshParameter param) {return (param !=NULL); }
|
|||
|
||||
#ifdef GLSL4_API
|
||||
#include "GSUniformBufferOGL.h"
|
||||
#include "GSVertexArrayOGL.h"
|
||||
#endif
|
||||
|
||||
#ifdef GLSL_API
|
||||
|
@ -363,7 +364,6 @@ struct SamplerParam {
|
|||
struct FRAGMENTSHADER
|
||||
{
|
||||
FRAGMENTSHADER() : prog(sZero)
|
||||
, Shader(0)
|
||||
, program(0)
|
||||
, sFinal(2)
|
||||
, sBitwiseANDX(3)
|
||||
|
@ -403,7 +403,6 @@ struct FRAGMENTSHADER
|
|||
}
|
||||
|
||||
ZZshShaderLink prog; // it link to FRAGMENTSHADER structure, for compability between GLSL and CG
|
||||
ZZshShader Shader; // useless with separate build
|
||||
ZZshProgram program;
|
||||
ZZshShaderType ShaderType; // Not every PS and VS are used together, only compatible ones.
|
||||
|
||||
|
@ -705,6 +704,7 @@ extern GSUniformBufferOGL *constant_buffer;
|
|||
extern GSUniformBufferOGL *common_buffer;
|
||||
extern GSUniformBufferOGL *vertex_buffer;
|
||||
extern GSUniformBufferOGL *fragment_buffer;
|
||||
extern GSVertexBufferStateOGL *vertex_array;
|
||||
|
||||
static void init_shader();
|
||||
static void PutParametersInProgram(VERTEXSHADER* vs, FRAGMENTSHADER* ps, int context);
|
||||
|
|
|
@ -118,6 +118,7 @@ GSUniformBufferOGL *constant_buffer;
|
|||
GSUniformBufferOGL *common_buffer;
|
||||
GSUniformBufferOGL *vertex_buffer;
|
||||
GSUniformBufferOGL *fragment_buffer;
|
||||
GSVertexBufferStateOGL *vertex_array;
|
||||
|
||||
COMMONSHADER g_cs;
|
||||
static GLuint s_pipeline = 0;
|
||||
|
@ -168,8 +169,6 @@ bool ZZshStartUsingShaders() {
|
|||
g_nPixelShaderVer = SHADER_ACCURATE|SHADER_REDUCED;
|
||||
|
||||
pfrag = ZZshLoadShadeEffect(0, 0, 1, 1, 0, temp, 0, &bFailed);
|
||||
if( pfrag != NULL )
|
||||
glLinkProgram(pfrag->Shader);
|
||||
if( bFailed || pfrag == NULL || glGetError() != GL_NO_ERROR) {
|
||||
g_nPixelShaderVer = SHADER_REDUCED;
|
||||
ZZLog::Error_Log("Basic shader test failed.");
|
||||
|
@ -222,6 +221,8 @@ void ZZshExitCleaning() {
|
|||
delete vertex_buffer;
|
||||
delete fragment_buffer;
|
||||
|
||||
delete vertex_array;
|
||||
|
||||
glDeleteProgramPipelines(1, &s_pipeline);
|
||||
}
|
||||
|
||||
|
@ -405,17 +406,20 @@ static void PutParametersAndRun(VERTEXSHADER* vs, FRAGMENTSHADER* ps) {
|
|||
}
|
||||
|
||||
inline bool ZZshCheckShaderCompatibility(VERTEXSHADER* vs, FRAGMENTSHADER* ps) {
|
||||
if (vs == NULL) return false;
|
||||
if (vs->ShaderType == ZZ_SH_ZERO) return true; // ZeroPS is compatible with everything
|
||||
if (ps == NULL) return false;
|
||||
|
||||
return (vs->ShaderType == ps->ShaderType);
|
||||
}
|
||||
|
||||
static void ZZshSetShader(VERTEXSHADER* vs, FRAGMENTSHADER* ps) {
|
||||
if (vs == NULL || ps == NULL) return;
|
||||
if (vs == NULL || ps == NULL) {
|
||||
// if (vs == NULL) fprintf(stderr, "VS is null !!! \n");
|
||||
// if (ps == NULL) fprintf(stderr, "PS is null !!! \n");
|
||||
return;
|
||||
}
|
||||
|
||||
UNIFORM_ERROR_LOG("SHADER: %s(%d) \t+\t%s(%d)", ShaderNames[vs->program], vs->program, ShaderNames[ps->program], ps->program);
|
||||
// FIXME all Shader are compatible now
|
||||
// I keep for the moment to avoid useless running of the program
|
||||
if (!ZZshCheckShaderCompatibility(vs, ps)) { // We don't need to link uncompatible shaders
|
||||
return;
|
||||
}
|
||||
|
@ -461,10 +465,21 @@ static void init_shader() {
|
|||
|
||||
constant_buffer->bind();
|
||||
constant_buffer->upload((void*)&g_cs.uniform_buffer_constant);
|
||||
|
||||
|
||||
glGenProgramPipelines(1, &s_pipeline);
|
||||
glBindProgramPipeline(s_pipeline);
|
||||
|
||||
// FIXME maybe GL_UNSIGNED_SHORT could be better than GL_SHORT
|
||||
GSInputLayoutOGL vert_format[] =
|
||||
{
|
||||
{0 , 4 , GL_SHORT , GL_FALSE , sizeof(VertexGPU) , (const GLvoid*)(0) } , // vertex
|
||||
{1 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(VertexGPU) , (const GLvoid*)(8) } , // color
|
||||
{2 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(VertexGPU) , (const GLvoid*)(12) } , // z value. FIXME WTF 4 unsigned byte, why not a full integer
|
||||
{3 , 3 , GL_FLOAT , GL_FALSE , sizeof(VertexGPU) , (const GLvoid*)(16) } , // tex coord
|
||||
};
|
||||
|
||||
vertex_array = new GSVertexBufferStateOGL(sizeof(VertexGPU), vert_format, 4);
|
||||
|
||||
}
|
||||
|
||||
static void PutParametersInProgram(VERTEXSHADER* vs, FRAGMENTSHADER* ps, int context) {
|
||||
|
@ -487,7 +502,7 @@ static void SetupFragmentProgramParameters(FRAGMENTSHADER* pf, int context, int
|
|||
// uniform parameters
|
||||
pf->prog.link = (void*)pf; // Setting autolink
|
||||
pf->prog.isFragment = true; // Setting autolink
|
||||
pf->ShaderType = ShaderTypes[pf->Shader];
|
||||
pf->ShaderType = ShaderTypes[pf->program];
|
||||
|
||||
g_cs.set_texture(g_cs.sBlocks, ptexBlocks);
|
||||
g_cs.set_texture(g_cs.sConv16to32, ptexConv16to32);
|
||||
|
|
|
@ -103,17 +103,16 @@ struct vertex
|
|||
|
||||
|
||||
#ifdef VERTEX_SHADER
|
||||
// The standard GL3 core interface
|
||||
out gl_PerVertex {
|
||||
invariant vec4 gl_Position;
|
||||
float gl_PointSize;
|
||||
float gl_ClipDistance[];
|
||||
};
|
||||
|
||||
// FIXME: deprecated variable
|
||||
// not supported in VS
|
||||
// in vec4 gl_Color;
|
||||
// in vec4 gl_SecondaryColor;
|
||||
layout(location = 0) in uvec2 Vert;
|
||||
layout(location = 1) in vec4 Color;
|
||||
layout(location = 2) in vec4 SecondaryColor;
|
||||
layout(location = 3) in vec3 TexCoord;
|
||||
|
||||
layout(location = 0) out vertex VSout;
|
||||
|
||||
|
@ -866,65 +865,65 @@ void Convert32to16PS() {
|
|||
|
||||
#ifdef VERTEX_SHADER
|
||||
|
||||
float4 OutPosition(float4 vertex) {
|
||||
float4 OutPosition() {
|
||||
float4 Position;
|
||||
Position.xy = gl_Vertex.xy * g_fPosXY.xy + g_fPosXY.zw;
|
||||
Position.z = (log(g_fc0.y + dot(g_fZ, gl_SecondaryColor.zyxw)) * g_fZNorm.x + g_fZNorm.y) * g_fZMin.y + dot(g_fZ, gl_SecondaryColor.zyxw) * g_fZMin.x ;
|
||||
Position.xy = Vert.xy * g_fPosXY.xy + g_fPosXY.zw;
|
||||
Position.z = (log(g_fc0.y + dot(g_fZ, SecondaryColor.zyxw)) * g_fZNorm.x + g_fZNorm.y) * g_fZMin.y + dot(g_fZ, SecondaryColor.zyxw) * g_fZMin.x ;
|
||||
Position.w = g_fc0.y;
|
||||
return Position;
|
||||
}
|
||||
|
||||
// just smooth shadering
|
||||
void RegularVS() {
|
||||
gl_Position = OutPosition(gl_Vertex);
|
||||
VSout.color = gl_Color;
|
||||
DOZWRITE(VSout.z = gl_SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
gl_Position = OutPosition();
|
||||
VSout.color = Color;
|
||||
DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z.w = g_fc0.y;)
|
||||
}
|
||||
|
||||
// diffuse texture mapping
|
||||
void TextureVS() {
|
||||
gl_Position = OutPosition(gl_Vertex);
|
||||
VSout.color = gl_Color;
|
||||
gl_Position = OutPosition();
|
||||
VSout.color = Color;
|
||||
#ifdef PERSPECTIVE_CORRECT_TEX
|
||||
VSout.tex.xyz = gl_MultiTexCoord0.xyz;
|
||||
VSout.tex.xyz = TexCoord.xyz;
|
||||
#else
|
||||
VSout.tex.xy = gl_MultiTexCoord0.xy/gl_MultiTexCoord0.z;
|
||||
VSout.tex.xy = TexCoord.xy/TexCoord.z;
|
||||
#endif
|
||||
DOZWRITE(VSout.z = gl_SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z.w = g_fc0.y;)
|
||||
}
|
||||
|
||||
void RegularFogVS() {
|
||||
float4 position = OutPosition(gl_Vertex);
|
||||
float4 position = OutPosition();
|
||||
gl_Position = position;
|
||||
VSout.color = gl_Color;
|
||||
VSout.color = Color;
|
||||
VSout.fog = position.z * g_fBilinear.w;
|
||||
DOZWRITE(VSout.z = gl_SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z.w = g_fc0.y;)
|
||||
}
|
||||
|
||||
void TextureFogVS() {
|
||||
float4 position = OutPosition(gl_Vertex);
|
||||
float4 position = OutPosition();
|
||||
gl_Position = position;
|
||||
VSout.color = gl_Color;
|
||||
VSout.color = Color;
|
||||
#ifdef PERSPECTIVE_CORRECT_TEX
|
||||
VSout.tex.xyz = gl_MultiTexCoord0.xyz;
|
||||
VSout.tex.xyz = TexCoord.xyz;
|
||||
#else
|
||||
VSout.tex.xy = gl_MultiTexCoord0.xy/gl_MultiTexCoord0.z;
|
||||
VSout.tex.xy = TexCoord.xy/TexCoord.z;
|
||||
#endif
|
||||
VSout.fog = position.z * g_fBilinear.w;
|
||||
DOZWRITE(VSout.z = gl_SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;)
|
||||
DOZWRITE(VSout.z.w = g_fc0.y;)
|
||||
}
|
||||
|
||||
void BitBltVS() {
|
||||
vec4 position;
|
||||
position.xy = gl_Vertex.xy * g_fBitBltPos.xy + g_fBitBltPos.zw;
|
||||
position.xy = Vert.xy * g_fBitBltPos.xy + g_fBitBltPos.zw;
|
||||
position.zw = g_fc0.xy;
|
||||
gl_Position = position;
|
||||
|
||||
VSout.tex.xy = gl_MultiTexCoord0.xy * g_fBitBltTex.xy + g_fBitBltTex.zw;
|
||||
VSout.tex.xy = TexCoord.xy * g_fBitBltTex.xy + g_fBitBltTex.zw;
|
||||
VSout.z.xy = position.xy * g_fBitBltTrans.xy + g_fBitBltTrans.zw;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue