Merge branch 'GLSL-master'

Merge an endless story. The branch name is a lie, it was started as glsl, but now it is a complete reworked opengl3 backend.

It just began with simple changes which aren't supported on osx.
They either support ogl2 OR ogl3 core, but mixing isn't allowed.
As the branch name says, the vicious circle starts with GLSL, but just implementing one wasn't possible either:
- OSX supports only GLSL100 which doesn't support our shaders.
- Vertex Array Objects are needed for ogl3, but not supported on ogl2
- immediate mode isn't supported any more, so we must implement vertex buffers
- uniform buffers are recommended as else we would need tons glUniform
- postprocessing shaders have to be converted to glsl
- lots of smaller outdated issues and bug fixes :-)

Thanks at all for testing and at Sonic for converting all of our shaders to glsl130

And sorry for all upcoming bugs...
This commit is contained in:
degasus 2013-03-15 22:49:26 +01:00
commit e1a081ad2d
152 changed files with 53010 additions and 48645 deletions

1
.gitignore vendored
View file

@ -36,5 +36,6 @@ Source/Core/Common/Src/scmrev.h
.sconsign.dblite
Externals/scons-local/*
.DS_Store
*~
#Ignore transifix configuration directory
.tx

View file

@ -655,6 +655,7 @@ file(WRITE ${PROJECT_BINARY_DIR}/Source/Core/Common/Src/scmrev.h
)
include_directories("${PROJECT_BINARY_DIR}/Source/Core/Common/Src")
########################################
# Start compiling our code
#

View file

@ -1,109 +1,61 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
//Change this number to increase the pixel size.
int pixelSize = 3;
float pixelSize = 3;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
int val = uv0[0];
int val2 = uv0[1];
val = val % pixelSize;
val2 = val2 % pixelSize;
if(val == 0 && val2 == 0 ){
if (c0.r < 0.1 && c0.r >= 0)
red = 0.1;
if (c0.r < 0.20 && c0.r >= 0.1)
red = 0.20;
if (c0.r <0.40 && c0.r >= 0.20)
red = 0.40;
if (c0.r <0.60 && c0.r >= 0.40)
red = 0.60;
if (c0.r <0.80 && c0.r >= 0.60)
red = 0.80;
if (c0.r >= 0.80)
red = 1;
if (c0.b < 0.1 && c0.b >= 0)
blue = 0.1;
if (c0.b < 0.20 && c0.b >= 0.1)
blue = 0.20;
if (c0.b <0.40 && c0.b >= 0.20)
blue = 0.40;
if (c0.b <0.60 && c0.b >= 0.40)
blue = 0.60;
if (c0.b <0.80 && c0.b >= 0.60)
blue = 0.80;
if (c0.b >= 0.80)
blue = 1;
if (c0.g < 0.1 && c0.g >= 0)
green = 0.1;
if (c0.g < 0.20 && c0.g >= 0.1)
green = 0.20;
if (c0.g <0.40 && c0.g >= 0.20)
green = 0.40;
if (c0.g <0.60 && c0.g >= 0.40)
green = 0.60;
if (c0.g <0.80 && c0.g >= 0.60)
green = 0.80;
if (c0.g >= 0.80)
green = 1;
}
else{
float4 c1 = texRECT(samp0, uv0-float2(val, val2)).rgba;
if (c1.r < 0.1 && c1.r >= 0)
red = 0.1;
if (c1.r < 0.20 && c1.r >= 0.1)
red = 0.20;
if (c1.r <0.40 && c1.r >= 0.20)
red = 0.40;
if (c1.r <0.60 && c1.r >= 0.40)
red = 0.60;
if (c1.r <0.80 && c1.r >= 0.60)
red = 0.80;
if (c1.r >= 0.80)
red = 1;
if (c1.b < 0.1 && c1.b >= 0)
blue = 0.1;
if (c1.b < 0.20 && c1.b >= 0.1)
blue = 0.20;
if (c1.b <0.40 && c1.b >= 0.20)
blue = 0.40;
if (c1.b <0.60 && c1.b >= 0.40)
blue = 0.60;
if (c1.b <0.80 && c1.b >= 0.60)
blue = 0.80;
if (c1.b >= 0.80)
blue = 1;
if (c1.g < 0.1 && c1.g >= 0)
green = 0.1;
if (c1.g < 0.20 && c1.g >= 0.1)
green = 0.20;
if (c1.g <0.40 && c1.g >= 0.20)
green = 0.40;
if (c1.g <0.60 && c1.g >= 0.40)
green = 0.60;
if (c1.g <0.80 && c1.g >= 0.60)
green = 0.80;
if (c1.g >= 0.80)
green = 1;
}
ocol0 = float4(red, green, blue, c0.a);
vec2 pos = floor(uv0 * resolution.xy / pixelSize) * pixelSize * resolution.zw;
vec4 c0 = texture(samp9, pos);
if (c0.r < 0.1)
red = 0.1;
else if (c0.r < 0.20)
red = 0.20;
else if (c0.r < 0.40)
red = 0.40;
else if (c0.r < 0.60)
red = 0.60;
else if (c0.r < 0.80)
red = 0.80;
else
red = 1.0;
if (c0.b < 0.1)
blue = 0.1;
else if (c0.b < 0.20)
blue = 0.20;
else if (c0.b < 0.40)
blue = 0.40;
else if (c0.b < 0.60)
blue = 0.60;
else if (c0.b < 0.80)
blue = 0.80;
else
blue = 1.0;
if (c0.g < 0.1)
green = 0.1;
else if (c0.g < 0.20)
green = 0.20;
else if (c0.g < 0.40)
green = 0.40;
else if (c0.g < 0.60)
green = 0.60;
else if (c0.g < 0.80)
green = 0.80;
else
green = 1.0;
ocol0 = vec4(red, green, blue, c0.a);
}

View file

@ -1,157 +1,86 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
//Change this number to increase the pixel size.
int pixelSize = 2;
float pixelSize = 2;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
int val = uv0[0];
int val2 = uv0[1];
val = val % pixelSize;
val2 = val2 % pixelSize;
if(val == 0 && val2 == 0 ){
if (c0.r < 0.06 && c0.r >= 0)
red = 0.06;
if (c0.r < 0.13 && c0.r >= 0.06)
red = 0.13;
if (c0.r < 0.26 && c0.r >= 0.13)
red = 0.26;
if (c0.r < 0.33 && c0.r >= 0.26)
red = 0.33;
if (c0.r <0.46 && c0.r >= 0.33)
red = 0.46;
if (c0.r <0.60 && c0.r >= 0.46)
red = 0.60;
if (c0.r <0.73 && c0.r >= 0.60)
red = 0.73;
if (c0.r <0.80 && c0.r >= 0.73)
red = 0.80;
if (c0.r <0.93 && c0.r >= 0.80)
red = 0.93;
if (c0.r <=1 && c0.r >= 0.93)
red = 1;
if (c0.b < 0.06 && c0.b >= 0)
blue = 0.06;
if (c0.b < 0.13 && c0.b >= 0.06)
blue = 0.13;
if (c0.b < 0.26 && c0.b >= 0.13)
blue = 0.26;
if (c0.b < 0.33 && c0.b >= 0.26)
blue = 0.33;
if (c0.b <0.46 && c0.b >= 0.33)
blue = 0.46;
if (c0.b <0.60 && c0.b >= 0.46)
blue = 0.60;
if (c0.b <0.73 && c0.b >= 0.60)
blue = 0.73;
if (c0.b <0.80 && c0.b >= 0.73)
blue = 0.80;
if( c0.b <0.93 && c0.b >= 0.80)
blue = 0.93;
if (c0.b <=1 && c0.b >= 0.93)
blue = 1;
if (c0.g < 0.06 && c0.g >= 0)
green = 0.06;
if (c0.g < 0.13 && c0.g >= 0.06)
green = 0.13;
if (c0.g < 0.26 && c0.g >= 0.13)
green = 0.26;
if (c0.g < 0.33 && c0.g >= 0.26)
green = 0.33;
if (c0.g <0.46 && c0.g >= 0.33)
green = 0.46;
if (c0.g <0.60 && c0.g >= 0.46)
green = 0.60;
if (c0.g <0.73 && c0.g >= 0.60)
green = 0.73;
if (c0.g <0.80 && c0.g >= 0.73)
green = 0.80;
if( c0.g <0.93 && c0.g >= 0.80)
green = 0.93;
if (c0.g <=1 && c0.g >= 0.93)
green = 1;
}
else{
float4 c1 = texRECT(samp0, uv0-float2(val, val2)).rgba;
if (c1.r < 0.06 && c1.r >= 0)
red = 0.06;
if (c1.r < 0.13 && c1.r >= 0.06)
red = 0.13;
if (c1.r < 0.26 && c1.r >= 0.13)
red = 0.26;
if (c1.r < 0.33 && c1.r >= 0.26)
red = 0.33;
if (c1.r <0.46 && c1.r >= 0.33)
red = 0.46;
if (c1.r <0.60 && c1.r >= 0.46)
red = 0.60;
if (c1.r <0.73 && c1.r >= 0.60)
red = 0.73;
if (c1.r <0.80 && c1.r >= 0.73)
red = 0.80;
if (c1.r <0.93 && c1.r >= 0.80)
red = 0.93;
if (c1.r <=1 && c1.r >= 0.93)
red = 1;
if (c1.b < 0.06 && c1.b >= 0)
blue = 0.06;
if (c1.b < 0.13 && c1.b >= 0.06)
blue = 0.13;
if (c1.b < 0.26 && c1.b >= 0.13)
blue = 0.26;
if (c1.b < 0.33 && c1.b >= 0.26)
blue = 0.33;
if (c1.b <0.46 && c1.b >= 0.33)
blue = 0.46;
if (c1.b <0.60 && c1.b >= 0.46)
blue = 0.60;
if (c1.b <0.73 && c1.b >= 0.60)
blue = 0.73;
if (c1.b <0.80 && c1.b >= 0.73)
blue = 0.80;
if( c1.b <0.93 && c1.b >= 0.80)
blue = 0.93;
if (c1.b <=1 && c1.b >= 0.93)
blue = 1;
if (c1.g < 0.06 && c1.g >= 0)
green = 0.06;
if (c1.g < 0.13 && c1.g >= 0.06)
green = 0.13;
if (c1.g < 0.26 && c1.g >= 0.13)
green = 0.26;
if (c1.g < 0.33 && c1.g >= 0.26)
green = 0.33;
if (c1.g <0.46 && c1.g >= 0.33)
green = 0.46;
if (c1.g <0.60 && c1.g >= 0.46)
green = 0.60;
if (c1.g <0.73 && c1.g >= 0.60)
green = 0.73;
if (c1.g <0.80 && c1.g >= 0.73)
green = 0.80;
if( c1.g <0.93 && c1.g >= 0.80)
green = 0.93;
if ( c1.g >= 0.93)
green = 1;
}
ocol0 = float4(red, green, blue, c0.a);
vec2 pos = floor(uv0 * resolution.xy / pixelSize) * pixelSize * resolution.zw;
vec4 c0 = texture(samp9, pos);
if (c0.r < 0.06)
red = 0.06;
else if (c0.r < 0.13)
red = 0.13;
else if (c0.r < 0.26)
red = 0.26;
else if (c0.r < 0.33)
red = 0.33;
else if (c0.r < 0.46)
red = 0.46;
else if (c0.r < 0.60)
red = 0.60;
else if (c0.r < 0.73)
red = 0.73;
else if (c0.r < 0.80)
red = 0.80;
else if (c0.r < 0.93)
red = 0.93;
else
red = 1.0;
if (c0.b < 0.06)
blue = 0.06;
else if (c0.b < 0.13)
blue = 0.13;
else if (c0.b < 0.26)
blue = 0.26;
else if (c0.b < 0.33)
blue = 0.33;
else if (c0.b < 0.46)
blue = 0.46;
else if (c0.b < 0.60)
blue = 0.60;
else if (c0.b < 0.73)
blue = 0.73;
else if (c0.b < 0.80)
blue = 0.80;
else if( c0.b < 0.93)
blue = 0.93;
else
blue = 1.0;
if (c0.g < 0.06)
green = 0.06;
else if (c0.g < 0.13)
green = 0.13;
else if (c0.g < 0.26)
green = 0.26;
else if (c0.g < 0.33)
green = 0.33;
else if (c0.g < 0.46)
green = 0.46;
else if (c0.g < 0.60)
green = 0.60;
else if (c0.g < 0.73)
green = 0.73;
else if (c0.g < 0.80)
green = 0.80;
else if( c0.g < 0.93)
green = 0.93;
else
green = 1.0;
ocol0 = vec4(red, green, blue, c0.a);
}

View file

@ -1,11 +1,14 @@
//dummy shader:
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.r, c0.g, c0.b, c0.a);
ocol0 = texture(samp9, uv0);
}
/*
And now that's over with, the contents of this readme file!
For best results, turn Wordwrap formatting on...

View file

@ -1,18 +1,21 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float blue = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float blue = 0.0;
if (c0.r > 0.15 && c0.b > 0.15)
{
blue = 0.5;
red = 0.5;
}
float green = max(c0.r + c0.b, c0.g);
if (c0.r > 0.15 && c0.b > 0.15)
{
blue = 0.5;
red = 0.5;
}
ocol0 = float4(red, green, blue, 1.0);
}
float green = max(c0.r + c0.b, c0.g);
ocol0 = vec4(red, green, blue, 1.0);
}

View file

@ -1,6 +1,11 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
ocol0 = (texRECT(samp0, uv0+1).rgba - texRECT(samp0, uv0-1).rgba)*8;
ocol0 = (texture(samp9, uv0+resolution.zw) - texture(samp9, uv0-resolution.zw))*8;
}

View file

@ -1,6 +1,13 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
ocol0 = texRECT(samp0, uv0+1).rgba * 1.3 * abs(texRECT(samp0, uv0+1).rgba - texRECT(samp0, uv0-1).rgba)*8;
vec4 a = texture(samp9, uv0+resolution.zw);
vec4 b = texture(samp9, uv0-resolution.zw);
ocol0 = ( a*a*1.3 - b )*8;
}

View file

@ -0,0 +1,95 @@
uniform sampler2D samp8; // textures
uniform sampler2D samp9;
const int char_width = 8;
const int char_height = 13;
const int char_count = 95;
const int char_pixels = char_width*char_height;
const vec2 char_dim = vec2(char_width, char_height);
const vec2 font_scale = vec2(1.0/char_width/char_count, 1.0/char_height);
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
vec2 char_pos = floor(uv0*resolution.xy/char_dim);
vec2 pixel_offset = floor(uv0*resolution.xy) - char_pos*char_dim;
float mindiff = char_width*char_height*100; // just a big number
float minc = 0.0;
vec4 mina = vec4(0.0, 0.0, 0.0, 0.0);
vec4 minb = vec4(0.0, 0.0, 0.0, 0.0);
for(int i=0; i<char_count; i++) {
vec4 ff = vec4(0.0, 0.0, 0.0, 0.0);
vec4 f = vec4(0.0, 0.0, 0.0, 0.0);
vec4 ft = vec4(0.0, 0.0, 0.0, 0.0);
vec4 t = vec4(0.0, 0.0, 0.0, 0.0);
vec4 tt = vec4(0.0, 0.0, 0.0, 0.0);
for(int x=0; x<char_width; x++) {
for(int y=0; y<char_height; y++) {
vec2 tex_pos = char_pos*char_dim + vec2(x,y) + 0.5;
vec4 tex = texture(samp9, tex_pos * resolution.zw);
vec2 font_pos = vec2(x+i*char_width, y) + 0.5;
vec4 font = texture(samp8, font_pos * font_scale);
// generates sum of texture and font and their squares
ff += font*font;
f += font;
ft += font*tex;
t += tex;
tt += tex*tex;
}
}
/*
The next lines are a bit harder, hf :-)
The idea is to find the perfect char with the perfect background color and the perfect font color.
As this is an equation with three unknowns, we can't just try all chars and color combinations.
As criterion how "perfect" the selection is, we compare the "mean squared error" of the resulted colors of all chars.
So, now the big issue: how to calculate the MSE without knowing the two colors ...
In the next steps, "a" is the font color, "b" is the background color, "f" is the font value at this pixel, "t" is the texture value
So the square error of one pixel is:
e = ( t - a⋅f - b⋅(1-f) ) ^ 2
In longer:
e = a^2⋅f^2 - 2⋅a⋅b⋅f^2 + 2⋅a⋅b⋅f - 2⋅a⋅f⋅t + b^2⋅f^2 - 2⋅b^2⋅f + b^2 + 2⋅b⋅f⋅t - 2⋅b⋅t + t^2
The sum of all errors is: (as shortcut, ff,f,ft,t,tt are now the sums like declared above, sum(1) is the count of pixels)
sum(e) = a^2⋅ff - 2⋅a^2⋅ff + 2⋅a⋅b⋅f - 2⋅a⋅ft + b^2⋅ff - 2⋅b^2⋅f + b^2⋅sum(1) + 2⋅b⋅ft - 2⋅b⋅t + tt
To find the minimum, we have to derive this by "a" and "b":
d/da sum(e) = 2⋅a⋅ff + 2⋅b⋅f - 2⋅b⋅ff - 2⋅ft
d/db sum(e) = 2⋅a⋅f - 2⋅a⋅ff - 4⋅b⋅f + 2⋅b⋅ff + 2⋅b⋅sum(1) + 2⋅ft - 2⋅t
So, both equations must be zero at minimum and there is only one solution.
*/
vec4 a = (f*ft - ff*t + f*t - ft*char_pixels) / (f*f - ff*char_pixels);
vec4 b = (f*ft - ff*t) / (f*f - ff*char_pixels);
vec4 diff = a*a*ff + 2.0*a*b*f - 2.0*a*b*ff - 2.0*a*ft + b*b *(-2.0*f + ff + char_pixels) + 2.0*b*ft - 2.0*b*t + tt;
float diff_f = dot(diff, vec4(1.0, 1.0, 1.0, 1.0));
if(diff_f < mindiff) {
mindiff = diff_f;
minc = i;
mina = a;
minb = b;
}
}
vec2 font_pos_res = vec2(minc*char_width, 0) + pixel_offset + 0.5;
vec4 col = texture(samp8, font_pos_res * font_scale);
ocol0 = mina * col + minb * (vec4(1.0,1.0,1.0,1.0) - col);
}

View file

@ -1,16 +1,22 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 to_gray = float4(0.3,0.59,0.11,0);
float x1 = dot(to_gray, texRECT(samp0, uv0+float2(1,1)));
float x0 = dot(to_gray, texRECT(samp0, uv0+float2(-1,-1)));
float x3 = dot(to_gray, texRECT(samp0, uv0+float2(1,-1)));
float x2 = dot(to_gray, texRECT(samp0, uv0+float2(-1,1)));
float edge = (x1 - x0) * (x1 - x0);
float edge2 = (x3 - x2) * (x3 - x2);
edge += edge2;
float4 color = texRECT(samp0, uv0).rgba;
vec4 to_gray = vec4(0.3,0.59,0.11,0);
float x1 = dot(to_gray, texture(samp9, uv0+vec2(1,1)*resolution.zw));
float x0 = dot(to_gray, texture(samp9, uv0+vec2(-1,-1)*resolution.zw));
float x3 = dot(to_gray, texture(samp9, uv0+vec2(1,-1)*resolution.zw));
float x2 = dot(to_gray, texture(samp9, uv0+vec2(-1,1)*resolution.zw));
float edge = (x1 - x0) * (x1 - x0) + (x3 - x2) * (x3 - x2);
float4 color = texture(samp9, uv0).rgba;
ocol0 = max(color - float4(edge, edge, edge, edge) * 12, float4(0,0,0,0));
ocol0 = color - vec4(edge, edge, edge, edge) * 12.0;
}

View file

@ -1,24 +1,25 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
//Changethis to increase the number of colors.
float numColors =8;
int numColors =8;
float4 to_gray = float4(0.3,0.59,0.11,0);
float x1 = dot(to_gray, texRECT(samp0, uv0+float2(1,1)));
float x0 = dot(to_gray, texRECT(samp0, uv0+float2(-1,-1)));
float x3 = dot(to_gray, texRECT(samp0, uv0+float2(1,-1)));
float x2 = dot(to_gray, texRECT(samp0, uv0+float2(-1,1)));
float edge = (x1 - x0) * (x1 - x0);
float edge2 = (x3 - x2) * (x3 - x2);
edge += edge2;
float4 color = texRECT(samp0, uv0).rgba;
float x1 = dot(to_gray, texture(samp9, uv0+vec2(1,1)*resolution.zw));
float x0 = dot(to_gray, texture(samp9, uv0+vec2(-1,-1)*resolution.zw));
float x3 = dot(to_gray, texture(samp9, uv0+vec2(1,-1)*resolution.zw));
float x2 = dot(to_gray, texture(samp9, uv0+vec2(-1,1)*resolution.zw));
float edge = (x1 - x0) * (x1 - x0) + (x3 - x2) * (x3 - x2);
float4 color = texture(samp9, uv0).rgba;
float4 c0 = max(color - float4(edge, edge, edge, edge) * 12, float4(0,0,0,0));
float4 c0 = color - float4(edge, edge, edge, edge) * 12;
//Change this number to increase the pixel size.
int pixelSize = 1;
float red = 0.0;
@ -27,19 +28,11 @@ void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
bool rr = false;
bool bb = false;
bool gg = false;
int val = uv0[0];
int val2 = uv0[1];
int count = 1;
double colorN = 0.0;
double colorB = 0.0;
val = val % pixelSize;
val2 = val2 % pixelSize;
float colorN = 0.0;
float colorB = 0.0;
//if(val == 0 && val2 == 0 )
// c0 = texRECT(samp0, uv0).rgba;
//else
// c0 = texRECT(samp0, uv0-float2(val, val2)).rgba;
for(count = 1; count <= numColors ; count++){
colorN = count / numColors;

View file

@ -1,36 +1,41 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0, in float2 uv1 : TEXCOORD1)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c_center = texRECT(samp0, uv0.xy).rgba;
float4 c_center = texture(samp9, uv0);
float4 bloom_sum = float4(0.0, 0.0, 0.0, 0.0);
uv0 += float2(0.3, 0.3);
float radius1 = 1.3;
bloom_sum += texRECT(samp0, uv0 + float2(-1.5, -1.5) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(-2.5, 0) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(-1.5, 1.5) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(0, 2.5) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(1.5, 1.5) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(2.5, 0) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(1.5, -1.5) * radius1);
bloom_sum += texRECT(samp0, uv0 + float2(0, -2.5) * radius1);
vec2 pos = uv0 + float2(0.3, 0.3) * resolution.zw;
float2 radius1 = 1.3 * resolution.zw;
bloom_sum += texture(samp9, pos + float2(-1.5, -1.5) * radius1);
bloom_sum += texture(samp9, pos + float2(-2.5, 0) * radius1);
bloom_sum += texture(samp9, pos + float2(-1.5, 1.5) * radius1);
bloom_sum += texture(samp9, pos + float2(0, 2.5) * radius1);
bloom_sum += texture(samp9, pos + float2(1.5, 1.5) * radius1);
bloom_sum += texture(samp9, pos + float2(2.5, 0) * radius1);
bloom_sum += texture(samp9, pos + float2(1.5, -1.5) * radius1);
bloom_sum += texture(samp9, pos + float2(0, -2.5) * radius1);
float radius2 = 4.6;
bloom_sum += texRECT(samp0, uv0 + float2(-1.5, -1.5) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(-2.5, 0) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(-1.5, 1.5) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(0, 2.5) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(1.5, 1.5) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(2.5, 0) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(1.5, -1.5) * radius2);
bloom_sum += texRECT(samp0, uv0 + float2(0, -2.5) * radius2);
float2 radius2 = 4.6 * resolution.zw;
bloom_sum += texture(samp9, pos + float2(-1.5, -1.5) * radius2);
bloom_sum += texture(samp9, pos + float2(-2.5, 0) * radius2);
bloom_sum += texture(samp9, pos + float2(-1.5, 1.5) * radius2);
bloom_sum += texture(samp9, pos + float2(0, 2.5) * radius2);
bloom_sum += texture(samp9, pos + float2(1.5, 1.5) * radius2);
bloom_sum += texture(samp9, pos + float2(2.5, 0) * radius2);
bloom_sum += texture(samp9, pos + float2(1.5, -1.5) * radius2);
bloom_sum += texture(samp9, pos + float2(0, -2.5) * radius2);
bloom_sum *= 0.07;
bloom_sum -= float4(0.3, 0.3, 0.3, 0.3);
bloom_sum = max(bloom_sum, float4(0,0,0,0));
float2 vpos = (uv1 - float2(.5, .5)) * 2;
float2 vpos = (uv0 - float2(.5, .5)) * 2;
float dist = (dot(vpos, vpos));
dist = 1 - 0.4*dist;

View file

@ -1,8 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
c0 += c0 * 2;
ocol0 = float4(c0.r, c0.g, c0.b, c0.a);
}
ocol0 = texture(samp9, uv0) * 3;
}

View file

@ -1,20 +1,17 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float green = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float green = 0.0;
if (c0.r < 0.35 || c0.b > 0.35)
{
green = c0.g + (c0.b / 2);
}
else
{
//red = 1 - c0.r + (c0.b / 2);
red = c0.r + 0.4;
}
ocol0 = float4(red, green, 0.0, 1.0);
}
if (c0.r < 0.35 || c0.b > 0.35)
green = c0.g + (c0.b / 2);
else
red = c0.r + 0.4;
ocol0 = vec4(red, green, 0.0, 1.0);
}

View file

@ -1,22 +1,24 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r < 0.50 || c0.b > 0.5)
{
blue = c0.r;
red = c0.g;
}
else
{
blue = c0.r;
green = c0.r;
}
ocol0 = float4(red, green, blue, 1.0);
}
if (c0.r < 0.50 || c0.b > 0.5)
{
blue = c0.r;
red = c0.g;
}
else
{
blue = c0.r;
green = c0.r;
}
ocol0 = vec4(red, green, blue, 1.0);
}

View file

@ -1,12 +1,17 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c1 = texRECT(samp0, uv0 - float2(1, 0)).rgba;
float4 c2 = texRECT(samp0, uv0 - float2(0, 1)).rgba;
float4 c3 = texRECT(samp0, uv0 + float2(1, 0)).rgba;
float4 c4 = texRECT(samp0, uv0 + float2(0, 1)).rgba;
float4 c0 = texture(samp9, uv0);
float4 c1 = texture(samp9, uv0 - float2(1, 0)*resolution.zw);
float4 c2 = texture(samp9, uv0 - float2(0, 1)*resolution.zw);
float4 c3 = texture(samp9, uv0 + float2(1, 0)*resolution.zw);
float4 c4 = texture(samp9, uv0 + float2(0, 1)*resolution.zw);
float red = c0.r;
float blue = c0.b;

View file

@ -1,9 +1,14 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c1 = texRECT(samp0, uv0 + float2(5,5)).rgba;
float4 c0 = texture(samp9, uv0).rgba;
float4 c1 = texture(samp9, uv0 + float2(5,5)*resolution.zw).rgba;
float y = (0.222 * c1.r) + (0.707 * c1.g) + (0.071 * c1.b);
float y2 = ((0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b)) / 3;
float red = c0.r;

View file

@ -1,39 +1,36 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float green = 0.0;
float blue = 0.0;
red = c0.r;
red = c0.r;
if (c0.r > 0.0)
{
if (c0.g > c0.r)
{
green = (c0.g - (c0.g - c0.r)) / 3;
}
}
if (c0.b > 0.0 && c0.r < 0.25)
{
red = c0.b;
green = c0.b / 3;
}
if (c0.r > 0.0)
if (c0.g > c0.r)
green = (c0.g - (c0.g - c0.r)) / 3;
if (c0.g > 0.0 && c0.r < 0.25)
{
red = c0.g;
green = c0.g / 3;
}
if (c0.b > 0.0 && c0.r < 0.25)
{
red = c0.b;
green = c0.b / 3;
}
if (((c0.r + c0.g + c0.b) / 3) > 0.9)
{
green = c0.r / 3;
}
ocol0 = float4(red, green, blue, 1.0);
}
if (c0.g > 0.0 && c0.r < 0.25)
{
red = c0.g;
green = c0.g / 3;
}
if (((c0.r + c0.g + c0.b) / 3) > 0.9)
green = c0.r / 3;
ocol0 = vec4(red, green, blue, 1.0);
}

View file

@ -1,15 +1,18 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
float avg = (c0.r + c0.g + c0.b) / 3;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float green = 0.0;
float blue = 0.0;
float avg = (c0.r + c0.g + c0.b) / 3;
red = c0.r + (c0.g / 2) + (c0.b / 3);
green = c0.r / 3;
ocol0 = float4(red, green, blue, 1.0);
}
red = c0.r + (c0.g / 2) + (c0.b / 3);
green = c0.r / 3;
ocol0 = vec4(red, green, blue, 1.0);
}

View file

@ -1,10 +1,15 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c1 = texRECT(samp0, uv0 + float2(1,1)).rgba;
float4 c2 = texRECT(samp0, uv0 + float2(-1,-1)).rgba;
float4 c0 = texture(samp9, uv0);
float4 c1 = texture(samp9, uv0 + float2(1,1)*resolution.zw);
float4 c2 = texture(samp9, uv0 + float2(-1,-1)*resolution.zw);
float red = c0.r;
float green = c0.g;
float blue = c0.b;

View file

@ -1,8 +1,11 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float avg = (c0.r + c0.g + c0.b) / 3.0;
ocol0 = float4(avg, avg, avg, c0.a);
vec4 c0 = texture(samp9, uv0);
float avg = (c0.r + c0.g + c0.b) / 3.0;
ocol0 = vec4(avg, avg, avg, c0.a);
}

View file

@ -1,9 +1,12 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
// Info: http://www.oreillynet.com/cs/user/view/cs_msg/8691
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
ocol0 = float4(avg, avg, avg, c0.a);
vec4 c0 = texture(samp9, uv0);
// Info: http://www.oreillynet.com/cs/user/view/cs_msg/8691
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
ocol0 = vec4(avg, avg, avg, c0.a);
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(1.0, 1.0, 1.0, 1.0) - c0;
ocol0 = vec4(1.0, 1.0, 1.0, 1.0) - texture(samp9, uv0);
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(0.0, 0.0, 0.7, 1.0) - c0;
}
ocol0 = vec4(0.0, 0.0, 0.7, 1.0) - texture(samp9, uv0);
}

View file

@ -1,9 +1,14 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c1 = texRECT(samp0, uv0 + float2(5,5)).rgba;
float4 c0 = texture(samp9, uv0);
float4 c1 = texture(samp9, uv0 + float2(5,5)*resolution.zw);
ocol0 = c0 - c1;
}

View file

@ -1,10 +1,15 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 emboss = (texRECT(samp0, uv0+1).rgba - texRECT(samp0, uv0-1).rgba)*2.0f;
emboss -= (texRECT(samp0, uv0+float2(1,-1)).rgba - texRECT(samp0, uv0+float2(-1,1)).rgba);
float4 color = texRECT(samp0, uv0).rgba;
float4 emboss = (texture(samp9, uv0+resolution.zw) - texture(samp9, uv0-resolution.zw))*2.0;
emboss -= (texture(samp9, uv0+float2(1,-1)*resolution.zw).rgba - texture(samp9, uv0+float2(-1,1)*resolution.zw).rgba);
float4 color = texture(samp9, uv0).rgba;
if (color.r > 0.8 && color.b + color.b < 0.2)
ocol0 = float4(1,0,0,0);
else {

View file

@ -1,8 +1,11 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c0 = texture(samp9, uv0).rgba;
float green = c0.g;
if (c0.g < 0.50)

View file

@ -1,21 +1,26 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
//variables
int internalresolution = 1278;
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c0 = texture(samp9, uv0).rgba;
//blur
float4 blurtotal = float4(0, 0, 0, 0);
float blursize = 1.5;
blurtotal += texRECT(samp0, uv0 + float2(-blursize, -blursize));
blurtotal += texRECT(samp0, uv0 + float2(-blursize, blursize));
blurtotal += texRECT(samp0, uv0 + float2( blursize, -blursize));
blurtotal += texRECT(samp0, uv0 + float2( blursize, blursize));
blurtotal += texRECT(samp0, uv0 + float2(-blursize, 0));
blurtotal += texRECT(samp0, uv0 + float2( blursize, 0));
blurtotal += texRECT(samp0, uv0 + float2( 0, -blursize));
blurtotal += texRECT(samp0, uv0 + float2( 0, blursize));
blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2(-blursize, blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2(-blursize, 0)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, 0)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( 0, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( 0, blursize)*resolution.zw);
blurtotal *= 0.125;
c0 = blurtotal;
//greyscale
@ -23,8 +28,8 @@ void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
// brighten
grey = grey * 0.5 + 0.7;
// darken edges
float x = uv0[0];
float y = uv0[1];
float x = uv0.x * resolution.x;
float y = uv0.y * resolution.y;
if (x > internalresolution/2) x = internalresolution-x;
if (y > internalresolution/2) y = internalresolution-y;
if (x > internalresolution/2*0.95) x = internalresolution/2*0.95;

View file

@ -1,21 +1,26 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
//variables
int internalresolution = 1278;
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c0 = texture(samp9, uv0).rgba;
//blur
float4 blurtotal = float4(0, 0, 0, 0);
float blursize = 1.5;
blurtotal += texRECT(samp0, uv0 + float2(-blursize, -blursize));
blurtotal += texRECT(samp0, uv0 + float2(-blursize, blursize));
blurtotal += texRECT(samp0, uv0 + float2( blursize, -blursize));
blurtotal += texRECT(samp0, uv0 + float2( blursize, blursize));
blurtotal += texRECT(samp0, uv0 + float2(-blursize, 0));
blurtotal += texRECT(samp0, uv0 + float2( blursize, 0));
blurtotal += texRECT(samp0, uv0 + float2( 0, -blursize));
blurtotal += texRECT(samp0, uv0 + float2( 0, blursize));
blurtotal += texture(samp9, uv0 + float2(-blursize, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2(-blursize, blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2(-blursize, 0)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( blursize, 0)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( 0, -blursize)*resolution.zw);
blurtotal += texture(samp9, uv0 + float2( 0, blursize)*resolution.zw);
blurtotal *= 0.125;
c0 = blurtotal;
//greyscale
@ -24,12 +29,12 @@ void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
// This would have been much simpler if I could get the stupid modulo (%) to work
// If anyone who is more well versed in Cg knows how to do this it'd be slightly more efficient
// float lineIntensity = ((uv0[1] % 9) - 4) / 40;
float vPos = uv0[1] / 9;
float lineIntensity = (((vPos - (int)vPos) * 9) - 4) / 40;
float vPos = uv0.y*resolution.y / 9;
float lineIntensity = (((vPos - floor(vPos)) * 9) - 4) / 40;
grey = grey * 0.5 + 0.7 + lineIntensity;
// darken edges
float x = uv0[0];
float y = uv0[1];
float x = uv0.x * resolution.x;
float y = uv0.y * resolution.y;
if (x > internalresolution/2) x = internalresolution-x;
if (y > internalresolution/2) y = internalresolution-y;
if (x > internalresolution/2*0.95) x = internalresolution/2*0.95;

View file

@ -1,8 +1,11 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c0 = texture(samp9, uv0).rgba;
float red = 0.0;
float green = 0.0;
float blue = 0.0;

View file

@ -1,6 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
inline float bound(float color)
out vec4 ocol0;
in vec2 uv0;
float bound(float color)
{
if (color < 0.35)
{
@ -13,9 +16,9 @@ inline float bound(float color)
return 1.0;
}
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
void main()
{
float4 c0 = texRECT(samp0, uv0 + float2(0,0)).rgba;
float4 c0 = texture(samp9, uv0);
ocol0 = float4(bound(c0.r), bound(c0.g), bound(c0.b), c0.a);
}

View file

@ -1,69 +1,70 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = c0.r;
float blue = c0.b;
float green = c0.g;
float factor = 2;
float max = 0.8;
float min = 0.3;
if(c0.r > c0.g && c0.b > c0.g){
if(c0.r < c0.b + 0.05 && c0.b < c0.r + 0.05){
red = 0.7;
blue = 0.7;
green = 0.05;
}
else if(c0.r > c0.b + 0.05){
red = 0.7;
blue = 0.05;
green = 0.05;
}
else if (c0.b > c0.r + 0.05){
red = 0.05;
blue = 0.7;
green = 0.05;
}
}
vec4 c0 = texture(samp9, uv0);
float red = c0.r;
float blue = c0.b;
float green = c0.g;
float factor = 2;
float max = 0.8;
float min = 0.3;
if(c0.r > c0.b && c0.g > c0.b){
if(c0.r < c0.g + 0.05 && c0.g < c0.r + 0.05){
red = 0.7;
blue = 0.05;
green = 0.7;
if(c0.r > c0.g && c0.b > c0.g){
if(c0.r < c0.b + 0.05 && c0.b < c0.r + 0.05){
red = 0.7;
blue = 0.7;
green = 0.05;
}
else if(c0.r > c0.b + 0.05){
red = 0.7;
blue = 0.05;
green = 0.05;
}
else if (c0.b > c0.r + 0.05){
red = 0.05;
blue = 0.7;
green = 0.05;
}
}
else if(c0.r > c0.g + 0.05){
red = 0.7;
blue = 0.05;
green = 0.05;
}
else if (c0.g > c0.r + 0.05){
red = 0.05;
blue = 0.05;
green = 0.7;
}
}
if(c0.g > c0.r && c0.b > c0.r){
if(c0.g < c0.b + 0.05 && c0.b < c0.g + 0.05){
red = 0.05;
blue = 0.7;
green = 0.7;
if(c0.r > c0.b && c0.g > c0.b){
if(c0.r < c0.g + 0.05 && c0.g < c0.r + 0.05){
red = 0.7;
blue = 0.05;
green = 0.7;
}
else if(c0.r > c0.g + 0.05){
red = 0.7;
blue = 0.05;
green = 0.05;
}
else if (c0.g > c0.r + 0.05){
red = 0.05;
blue = 0.05;
green = 0.7;
}
}
else if(c0.g > c0.b + 0.05){
red = 0.05;
blue = 0.05;
green = 0.7;
}
else if (c0.b > c0.g + 0.05){
red = 0.05;
blue = 0.7;
green = 0.05;
}
}
ocol0 = float4(red, green, blue, c0.a);
}
if(c0.g > c0.r && c0.b > c0.r){
if(c0.g < c0.b + 0.05 && c0.b < c0.g + 0.05){
red = 0.05;
blue = 0.7;
green = 0.7;
}
else if(c0.g > c0.b + 0.05){
red = 0.05;
blue = 0.05;
green = 0.7;
}
else if (c0.b > c0.g + 0.05){
red = 0.05;
blue = 0.7;
green = 0.05;
}
}
ocol0 = vec4(red, green, blue, c0.a);
}

View file

@ -1,13 +1,16 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
// Same coefficients as grayscale2 at this point
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
float red=avg;
// Not sure about these coefficients, they just seem to produce the proper yellow
float green=avg*.75;
float blue=avg*.5;
ocol0 = float4(red, green, blue, c0.a);
}
vec4 c0 = texture(samp9, uv0);
// Same coefficients as grayscale2 at this point
float avg = (0.222 * c0.r) + (0.707 * c0.g) + (0.071 * c0.b);
float red=avg;
// Not sure about these coefficients, they just seem to produce the proper yellow
float green=avg*.75;
float blue=avg*.5;
ocol0 = vec4(red, green, blue, c0.a);
}

View file

@ -1,17 +1,22 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float4 c0 = texture(samp9, uv0).rgba;
float4 tmp = float4(0, 0, 0, 0);
tmp += c0 - texRECT(samp0, uv0 + float2(2, 2)).rgba;
tmp += c0 - texRECT(samp0, uv0 - float2(2, 2)).rgba;
tmp += c0 - texRECT(samp0, uv0 + float2(2, -2)).rgba;
tmp += c0 - texRECT(samp0, uv0 - float2(2, -2)).rgba;
tmp += c0 - texture(samp9, uv0 + float2(2, 2)*resolution.zw).rgba;
tmp += c0 - texture(samp9, uv0 - float2(2, 2)*resolution.zw).rgba;
tmp += c0 - texture(samp9, uv0 + float2(2, -2)*resolution.zw).rgba;
tmp += c0 - texture(samp9, uv0 - float2(2, -2)*resolution.zw).rgba;
float grey = ((0.222 * tmp.r) + (0.707 * tmp.g) + (0.071 * tmp.b));
// get rid of the bottom line, as it is incorrect.
if (uv0[1] < 163)
tmp = 1;
c0 = c0+1-grey*7;
if (uv0.y*resolution.y < 163)
tmp = float4(1.0, 1.0, 1.0, 1.0);
c0 = c0+1-grey*7.0;
ocol0 = float4(c0.r, c0.g, c0.b, 1);
}

View file

@ -1,20 +1,23 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float blue = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float blue = 0.0;
if (c0.r < 0.35 || c0.b > 0.5)
{
red = c0.g + c0.b;
}
else
{
red = c0.g + c0.b;
blue = c0.r + c0.b;
}
ocol0 = float4(red, 0.0, blue, 1.0);
}
if (c0.r < 0.35 || c0.b > 0.5)
{
red = c0.g + c0.b;
}
else
{
red = c0.g + c0.b;
blue = c0.r + c0.b;
}
ocol0 = vec4(red, 0.0, blue, 1.0);
}

View file

@ -1,22 +1,25 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r < 0.35 || c0.b > 0.5)
{
red = c0.g + c0.b;
}
else
{
red = c0.g + c0.b;
blue = c0.r + c0.b;
green = c0.r + c0.b;
}
ocol0 = float4(red, green, blue, 1.0);
}
if (c0.r < 0.35 || c0.b > 0.5)
{
red = c0.g + c0.b;
}
else
{
red = c0.g + c0.b;
blue = c0.r + c0.b;
green = c0.r + c0.b;
}
ocol0 = vec4(red, green, blue, 1.0);
}

View file

@ -1,11 +1,16 @@
// Omega's 3D Stereoscopic filtering
// TODO: Need depth info!
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba; // Source Color
float4 c0 = texture(samp9, uv0).rgba; // Source Color
float sep = 5;
float red = c0.r;
float green = c0.g;
@ -13,11 +18,11 @@ void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
// Left Eye (Red)
float4 c1 = texRECT(samp0, uv0 + float2(sep,0)).rgba;
float4 c1 = texture(samp9, uv0 + float2(sep,0)*resolution.zw).rgba;
red = max(c0.r, c1.r);
// Right Eye (Cyan)
float4 c2 = texRECT(samp0, uv0 + float2(-sep,0)).rgba;
float4 c2 = texture(samp9, uv0 + float2(-sep,0)*resolution.zw).rgba;
float cyan = (c2.g + c2.b) / 2;
green = max(c0.g, cyan);
blue = max(c0.b, cyan);

View file

@ -1,24 +1,30 @@
// Omega's 3D Stereoscopic filtering (Amber/Blue)
// TODO: Need depth info!
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
uniform vec4 resolution;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba; // Source Color
float4 c0 = texture(samp9, uv0).rgba; // Source Color
float sep = 5;
float red = c0.r;
float green = c0.g;
float blue = c0.b;
// Left Eye (Amber)
float4 c2 = texRECT(samp0, uv0 + float2(sep,0)).rgba;
float4 c2 = texture(samp9, uv0 + float2(sep,0)*resolution.zw).rgba;
float amber = (c2.r + c2.g) / 2;
red = max(c0.r, amber);
green = max(c0.g, amber);
// Right Eye (Blue)
float4 c1 = texRECT(samp0, uv0 + float2(-sep,0)).rgba;
float4 c1 = texture(samp9, uv0 + float2(-sep,0)*resolution.zw).rgba;
blue = max(c0.b, c1.b);

View file

@ -1,7 +1,10 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.r*1.5, c0.g*1, c0.b*0.5, c0.a);
}
vec4 c0 = texture(samp9, uv0);
ocol0 = vec4(c0.r * 1.5, c0.g * 1, c0.b * 0.5, c0.a);
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.b, c0.g, c0.r, c0.a);
ocol0 = texture(samp9, uv0).bgra;
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.b, c0.r, c0.g, c0.a);
}
ocol0 = texture(samp9, uv0).brga;
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.g, c0.b, c0.r, c0.a);
}
ocol0 = texture(samp9, uv0).gbra;
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.g, c0.r, c0.b, c0.a);
}
ocol0 = texture(samp9, uv0).grba;
}

View file

@ -1,7 +1,9 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
ocol0 = float4(c0.r, c0.b, c0.g, c0.a);
}
ocol0 = texture(samp9, uv0).rbga;
}

View file

@ -1,22 +1,25 @@
uniform samplerRECT samp0 : register(s0);
uniform sampler2D samp9;
void main(out float4 ocol0 : COLOR0, in float2 uv0 : TEXCOORD0)
out vec4 ocol0;
in vec2 uv0;
void main()
{
float4 c0 = texRECT(samp0, uv0).rgba;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
vec4 c0 = texture(samp9, uv0);
float red = 0.0;
float green = 0.0;
float blue = 0.0;
if (c0.r < 0.3 || c0.b > 0.5)
{
blue = c0.r + c0.b;
red = c0.g + c0.b / 2;
}
else
{
red = c0.g + c0.b;
green = c0.r + c0.b;
}
ocol0 = float4(red, green, blue, 1.0);
}
if (c0.r < 0.3 || c0.b > 0.5)
{
blue = c0.r + c0.b;
red = c0.g + c0.b / 2;
}
else
{
red = c0.g + c0.b;
green = c0.r + c0.b;
}
ocol0 = vec4(red, green, blue, 1.0);
}

Binary file not shown.

View file

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="2.1">
<dict>
<key>CFBundleGetInfoString</key>
<string>NVIDIA Cg version 3.0.0007</string>
<key>CFBundleIdentifier</key>
<string>com.nvidia.cg</string>
<key>CFBundleName</key>
<string>NVIDIA Cg</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0007</string>
<key>IFMajorVersion</key>
<integer>3</integer>
<key>IFMinorVersion</key>
<integer>0</integer>
<key>IFPkgFlagAllowBackRev</key>
<false/>
<key>IFPkgFlagAuthorizationAction</key>
<string>RootAuthorization</string>
<key>IFPkgFlagDefaultLocation</key>
<string>/</string>
<key>IFPkgFlagInstallFat</key>
<false/>
<key>IFPkgFlagIsRequired</key>
<false/>
<key>IFPkgFlagOverwritePermissions</key>
<false/>
<key>IFPkgFlagRelocatable</key>
<false/>
<key>IFPkgFlagRestartAction</key>
<string>NoRestart</string>
<key>IFPkgFlagRootVolumeOnly</key>
<true/>
<key>IFPkgFlagUpdateInstalledLanguages</key>
<false/>
<key>IFPkgFlagUseUserMask</key>
<false/>
<key>IFPkgFormatVersion</key>
<real>0.10000000149011612</real>
</dict>
</plist>

BIN
Externals/Cg/cg.dll vendored

Binary file not shown.

1354
Externals/Cg/cg.h vendored

File diff suppressed because it is too large Load diff

BIN
Externals/Cg/cg.lib vendored

Binary file not shown.

BIN
Externals/Cg/cgGL.dll vendored

Binary file not shown.

243
Externals/Cg/cgGL.h vendored
View file

@ -1,243 +0,0 @@
/*
*
* Copyright (c) 2002-2010, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _cggl_h
#define _cggl_h
/*************************************************************************/
/*** CGGL Run-Time Library API ***/
/*************************************************************************/
#include <Cg/cg.h>
#ifdef _WIN32
# ifndef APIENTRY /* From Win32's <windef.h> */
# define CGGL_APIENTRY_DEFINED
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
# ifndef WINGDIAPI /* From Win32's <wingdi.h> and <winnt.h> */
# define CGGL_WINGDIAPI_DEFINED
# define WINGDIAPI __declspec(dllimport)
# endif
#endif /* _WIN32 */
/* Set up CGGL_API for Win32 dllexport or gcc visibility. */
#ifndef CGGL_API
# ifdef CGGL_EXPORTS
# ifdef _WIN32
# define CGGL_API __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__>=4
# define CGGL_API __attribute__ ((visibility("default")))
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# define CGGL_API __global
# else
# define CGGL_API
# endif
# else
# define CGGL_API
# endif
#endif
#ifndef CGGLENTRY
# ifdef _WIN32
# define CGGLENTRY __cdecl
# else
# define CGGLENTRY
# endif
#endif
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
/*************************************************************************/
/*** Data types and enumerants ***/
/*************************************************************************/
typedef enum
{
CG_GL_MATRIX_IDENTITY = 0,
CG_GL_MATRIX_TRANSPOSE = 1,
CG_GL_MATRIX_INVERSE = 2,
CG_GL_MATRIX_INVERSE_TRANSPOSE = 3,
CG_GL_MODELVIEW_MATRIX = 4,
CG_GL_PROJECTION_MATRIX = 5,
CG_GL_TEXTURE_MATRIX = 6,
CG_GL_MODELVIEW_PROJECTION_MATRIX = 7,
CG_GL_VERTEX = 8,
CG_GL_FRAGMENT = 9,
CG_GL_GEOMETRY = 10,
CG_GL_TESSELLATION_CONTROL = 11,
CG_GL_TESSELLATION_EVALUATION = 12
} CGGLenum;
#ifdef __cplusplus
extern "C"
{
#endif
/*************************************************************************/
/*** Functions ***/
/*************************************************************************/
#ifndef CGGL_EXPLICIT
CGGL_API CGbool CGGLENTRY cgGLIsProfileSupported(CGprofile profile);
CGGL_API void CGGLENTRY cgGLEnableProfile(CGprofile profile);
CGGL_API void CGGLENTRY cgGLDisableProfile(CGprofile profile);
CGGL_API CGprofile CGGLENTRY cgGLGetLatestProfile(CGGLenum profile_type);
CGGL_API void CGGLENTRY cgGLSetOptimalOptions(CGprofile profile);
CGGL_API char const ** CGGLENTRY cgGLGetOptimalOptions(CGprofile profile);
CGGL_API void CGGLENTRY cgGLLoadProgram(CGprogram program);
CGGL_API void CGGLENTRY cgGLUnloadProgram(CGprogram program);
CGGL_API CGbool CGGLENTRY cgGLIsProgramLoaded(CGprogram program);
CGGL_API void CGGLENTRY cgGLBindProgram(CGprogram program);
CGGL_API void CGGLENTRY cgGLUnbindProgram(CGprofile profile);
CGGL_API GLuint CGGLENTRY cgGLGetProgramID(CGprogram program);
CGGL_API void CGGLENTRY cgGLSetParameter1f(CGparameter param, float x);
CGGL_API void CGGLENTRY cgGLSetParameter2f(CGparameter param, float x, float y);
CGGL_API void CGGLENTRY cgGLSetParameter3f(CGparameter param, float x, float y, float z);
CGGL_API void CGGLENTRY cgGLSetParameter4f(CGparameter param, float x, float y, float z, float w);
CGGL_API void CGGLENTRY cgGLSetParameter1fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter2fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter3fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter4fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter1d(CGparameter param, double x);
CGGL_API void CGGLENTRY cgGLSetParameter2d(CGparameter param, double x, double y);
CGGL_API void CGGLENTRY cgGLSetParameter3d(CGparameter param, double x, double y, double z);
CGGL_API void CGGLENTRY cgGLSetParameter4d(CGparameter param, double x, double y, double z, double w);
CGGL_API void CGGLENTRY cgGLSetParameter1dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameter2dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameter3dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameter4dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLGetParameter1f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter2f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter3f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter4f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter1d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLGetParameter2d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLGetParameter3d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLGetParameter4d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray1f(CGparameter param, long offset, long nelements, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray2f(CGparameter param, long offset, long nelements, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray3f(CGparameter param, long offset, long nelements, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray4f(CGparameter param, long offset, long nelements, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray1d(CGparameter param, long offset, long nelements, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray2d(CGparameter param, long offset, long nelements, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray3d(CGparameter param, long offset, long nelements, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray4d(CGparameter param, long offset, long nelements, const double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray1f(CGparameter param, long offset, long nelements, float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray2f(CGparameter param, long offset, long nelements, float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray3f(CGparameter param, long offset, long nelements, float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray4f(CGparameter param, long offset, long nelements, float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray1d(CGparameter param, long offset, long nelements, double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray2d(CGparameter param, long offset, long nelements, double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray3d(CGparameter param, long offset, long nelements, double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray4d(CGparameter param, long offset, long nelements, double *v);
CGGL_API void CGGLENTRY cgGLSetParameterPointer(CGparameter param, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
CGGL_API void CGGLENTRY cgGLEnableClientState(CGparameter param);
CGGL_API void CGGLENTRY cgGLDisableClientState(CGparameter param);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterdr(CGparameter param, const double *matrix);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterfr(CGparameter param, const float *matrix);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterdc(CGparameter param, const double *matrix);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterfc(CGparameter param, const float *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterdr(CGparameter param, double *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterfr(CGparameter param, float *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterdc(CGparameter param, double *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterfc(CGparameter param, float *matrix);
CGGL_API void CGGLENTRY cgGLSetStateMatrixParameter(CGparameter param, CGGLenum matrix, CGGLenum transform);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArrayfc(CGparameter param, long offset, long nelements, const float *matrices);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArrayfr(CGparameter param, long offset, long nelements, const float *matrices);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArraydc(CGparameter param, long offset, long nelements, const double *matrices);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArraydr(CGparameter param, long offset, long nelements, const double *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArrayfc(CGparameter param, long offset, long nelements, float *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArrayfr(CGparameter param, long offset, long nelements, float *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArraydc(CGparameter param, long offset, long nelements, double *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArraydr(CGparameter param, long offset, long nelements, double *matrices);
CGGL_API void CGGLENTRY cgGLSetTextureParameter(CGparameter param, GLuint texobj);
CGGL_API GLuint CGGLENTRY cgGLGetTextureParameter(CGparameter param);
CGGL_API void CGGLENTRY cgGLEnableTextureParameter(CGparameter param);
CGGL_API void CGGLENTRY cgGLDisableTextureParameter(CGparameter param);
CGGL_API GLenum CGGLENTRY cgGLGetTextureEnum(CGparameter param);
CGGL_API void CGGLENTRY cgGLSetManageTextureParameters(CGcontext ctx, CGbool flag);
CGGL_API CGbool CGGLENTRY cgGLGetManageTextureParameters(CGcontext ctx);
CGGL_API void CGGLENTRY cgGLSetupSampler(CGparameter param, GLuint texobj);
CGGL_API void CGGLENTRY cgGLRegisterStates(CGcontext ctx);
CGGL_API void CGGLENTRY cgGLEnableProgramProfiles(CGprogram program);
CGGL_API void CGGLENTRY cgGLDisableProgramProfiles(CGprogram program);
CGGL_API void CGGLENTRY cgGLSetDebugMode(CGbool debug);
CGGL_API CGbuffer CGGLENTRY cgGLCreateBuffer(CGcontext context, int size, const void *data, GLenum bufferUsage);
CGGL_API GLuint CGGLENTRY cgGLGetBufferObject(CGbuffer buffer);
#endif
#ifdef __cplusplus
}
#endif
#ifdef CGGL_APIENTRY_DEFINED
# undef CGGL_APIENTRY_DEFINED
# undef APIENTRY
#endif
#ifdef CGGL_WINGDIAPI_DEFINED
# undef CGGL_WINGDIAPI_DEFINED
# undef WINGDIAPI
#endif
#endif

BIN
Externals/Cg/cgGL.lib vendored

Binary file not shown.

BIN
Externals/Cg64/cg.dll vendored

Binary file not shown.

BIN
Externals/Cg64/cg.lib vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Externals/GLew/glew32s.lib vendored Normal file → Executable file

Binary file not shown.

BIN
Externals/GLew/glew64s.lib vendored Normal file → Executable file

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

32173
Externals/GLew/src/glew.c vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -122,14 +122,10 @@ FunctionEnd
Section "Base" SEC01
SetShellVarContext all
; Dolphin exe and dlls
; TODO: cg is only for OGL, SDL is only for nJoy
; TODO: Make a nice subsection-ized display
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "${BASE_DIR}\Dolphin.exe"
File "..\Externals\Cg\cg.dll"
File "..\Externals\Cg\cgGL.dll"
; File "..\Externals\Cg\cgD3D9.dll"
File "..\Externals\WiiUse\Win32\wiiuse.dll"
File "..\Externals\SDL\win32\SDL.dll"
File "..\Externals\OpenAL\win32\OpenAL32.dll"
@ -240,4 +236,4 @@ SectionEnd
Function LaunchDolphin
ExecShell "" "$DESKTOP\Dolphin.lnk"
FunctionEnd
FunctionEnd

View file

@ -132,14 +132,10 @@ FunctionEnd
Section "Complete" SEC01
SetShellVarContext all
; Dolphin exe and dlls
; TODO: cg is only for OGL, SDL is only for nJoy
; TODO: Make a nice subsection-ized display
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "${BASE_DIR}\Dolphin.exe"
File "..\Externals\Cg64\cg.dll"
File "..\Externals\Cg64\cgGL.dll"
; File "..\Externals\Cg64\cgD3D9.dll"
File "..\Externals\WiiUse\X64\wiiuse.dll"
File "..\Externals\SDL\x64\SDL.dll"
File "..\Externals\OpenAL\win64\OpenAL32.dll"
@ -250,4 +246,4 @@ SectionEnd
Function LaunchDolphin
ExecShell "" "$DESKTOP\Dolphin x64.lnk"
FunctionEnd
FunctionEnd

View file

@ -21,11 +21,8 @@
#include "Common.h"
#include <fstream>
// Increment this every time you change shader generation code.
enum
{
LINEAR_DISKCACHE_VER = 6979
};
// defined in Version.cpp
extern const char *scm_rev_git_str;
// On disk format:
//header{
@ -187,13 +184,15 @@ private:
{
Header()
: id(*(u32*)"DCAC")
, ver(LINEAR_DISKCACHE_VER)
, key_t_size(sizeof(K))
, value_t_size(sizeof(V))
{}
{
memcpy(ver, scm_rev_git_str, 40);
}
const u32 id, ver;
const u32 id;
const u16 key_t_size, value_t_size;
char ver[40];
} m_header;

View file

@ -117,6 +117,8 @@ struct Rectangle
Rectangle(T theLeft, T theTop, T theRight, T theBottom)
: left(theLeft), top(theTop), right(theRight), bottom(theBottom)
{ }
bool operator==(const Rectangle& r) { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; }
T GetWidth() const { return abs(right - left); }
T GetHeight() const { return abs(bottom - top); }

View file

@ -50,3 +50,5 @@ const char *netplay_dolphin_ver = SCM_DESC_STR " M" NP_ARCH;
#else
const char *netplay_dolphin_ver = SCM_DESC_STR " L" NP_ARCH;
#endif
const char *scm_rev_git_str = SCM_REV_STR;

View file

@ -103,6 +103,7 @@ public:
virtual void Video_Prepare() = 0;
virtual void Video_EnterLoop() = 0;
virtual void Video_ExitLoop() = 0;
virtual void Video_Cleanup() = 0; // called from gl/d3d thread
virtual void Video_BeginField(u32, FieldType, u32, u32) = 0;
virtual void Video_EndField() = 0;

View file

@ -322,6 +322,9 @@ void CpuThread()
CCPU::Run();
g_bStarted = false;
if (!_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup();
return;
}
@ -350,6 +353,9 @@ void FifoPlayerThread()
}
g_bStarted = false;
if(!_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup();
return;
}
@ -476,6 +482,9 @@ void EmuThread()
g_cpu_thread.join();
INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str());
if(_CoreParameter.bCPUThread)
g_video_backend->Video_Cleanup();
VolumeHandler::EjectVolume();
FileMon::Close();

View file

@ -95,11 +95,7 @@ else()
if(WIN32)
set(SRCS ${SRCS} Src/GLInterface/GLW.cpp)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(USE_WX)
set(SRCS ${SRCS} Src/GLInterface/WX.cpp)
else()
set(SRCS ${SRCS} Src/GLInterface/AGL.cpp)
endif()
set(SRCS ${SRCS} Src/GLInterface/AGL.cpp)
else()
set(SRCS ${SRCS} Src/GLInterface/GLX.cpp
Src/GLInterface/X11_Util.cpp)

View file

@ -136,7 +136,6 @@
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\Data" "$(TargetDir)" /e /s /y /d
echo Copying External .dlls
xcopy "$(SolutionDir)..\Externals\Cg\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\OpenAL\Win32\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /s /y /q /d
</Command>
@ -151,7 +150,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\Data" "$(TargetDir)" /e /s /y /d
echo Copying External .dlls
xcopy "$(SolutionDir)..\Externals\Cg64\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\OpenAL\Win64\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /s /y /q /d
</Command>
@ -168,7 +166,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\Data" "$(TargetDir)" /e /s /y /d
echo Copying External .dlls
xcopy "$(SolutionDir)..\Externals\Cg\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\OpenAL\Win32\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /s /y /q /d
</Command>
@ -183,7 +180,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\Data" "$(TargetDir)" /e /s /y /d
echo Copying External .dlls
xcopy "$(SolutionDir)..\Externals\Cg\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\OpenAL\Win32\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /s /y /q /d
</Command>
@ -200,7 +196,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\Data" "$(TargetDir)" /e /s /y /d
echo Copying External .dlls
xcopy "$(SolutionDir)..\Externals\Cg64\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\OpenAL\Win64\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /s /y /q /d
</Command>
@ -217,7 +212,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\Data" "$(TargetDir)" /e /s /y /d
echo Copying External .dlls
xcopy "$(SolutionDir)..\Externals\Cg64\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\OpenAL\Win64\*.dll" "$(TargetDir)" /e /s /y /q /d
xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /s /y /q /d
</Command>

View file

@ -23,8 +23,6 @@
#include <GLInterface/InterfaceBase.h>
#elif defined(USE_EGL) && USE_EGL
#include "GLInterface/EGL_X11.h"
#elif defined(USE_WX) && USE_WX
#include "GLInterface/WX.h"
#elif defined(__APPLE__)
#include "GLInterface/AGL.h"
#elif defined(_WIN32)
@ -51,12 +49,8 @@ typedef struct {
std::thread xEventThread;
int x, y;
unsigned int width, height;
#elif defined(USE_WX) && USE_WX
wxGLCanvas *glCanvas;
wxGLContext *glCtxt;
wxPanel *panel;
#elif defined(__APPLE__)
NSWindow *cocoaWin;
NSView *cocoaWin;
NSOpenGLContext *cocoaCtx;
#elif defined(HAVE_X11) && HAVE_X11
int screen;

View file

@ -20,6 +20,8 @@
#include "RenderBase.h"
#include "ConfigManager.h"
#include <wx/panel.h>
#include "VertexShaderManager.h"
#include "../GLInterface.h"
#include "AGL.h"
@ -32,7 +34,7 @@ void cInterfaceAGL::Swap()
// Show the current FPS
void cInterfaceAGL::UpdateFPSDisplay(const char *text)
{
[GLWin.cocoaWin setTitle: [NSString stringWithUTF8String: text]];
[[GLWin.cocoaWin window] setTitle: [NSString stringWithUTF8String: text]];
}
// Create rendering window.
@ -48,7 +50,7 @@ bool cInterfaceAGL::Create(void *&window_handle)
NSRect size;
NSUInteger style = NSMiniaturizableWindowMask;
NSOpenGLPixelFormatAttribute attr[2] = { NSOpenGLPFADoubleBuffer, 0 };
NSOpenGLPixelFormatAttribute attr[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFAAccelerated, 0 };
NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc]
initWithAttributes: attr];
if (fmt == nil) {
@ -72,8 +74,7 @@ bool cInterfaceAGL::Create(void *&window_handle)
style |= NSResizableWindowMask | NSTitledWindowMask;
}
GLWin.cocoaWin = [[NSWindow alloc] initWithContentRect: size
styleMask: style backing: NSBackingStoreBuffered defer: NO];
GLWin.cocoaWin = (NSView*)(((wxPanel*)window_handle)->GetHandle());;
if (GLWin.cocoaWin == nil) {
ERROR_LOG(VIDEO, "failed to create window");
return NULL;
@ -84,8 +85,8 @@ bool cInterfaceAGL::Create(void *&window_handle)
[GLWin.cocoaWin setLevel: CGShieldingWindowLevel()];
}
[GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]];
[GLWin.cocoaWin makeKeyAndOrderFront: nil];
[GLWin.cocoaCtx setView: GLWin.cocoaWin];
[[GLWin.cocoaWin window] makeKeyAndOrderFront: nil];
return true;
}
@ -94,12 +95,12 @@ bool cInterfaceAGL::MakeCurrent()
{
int width, height;
width = [[GLWin.cocoaWin contentView] frame].size.width;
height = [[GLWin.cocoaWin contentView] frame].size.height;
if (width == s_backbuffer_width && height == s_backbuffer_height)
return;
width = [GLWin.cocoaWin frame].size.width;
height = [GLWin.cocoaWin frame].size.height;
//if (width == s_backbuffer_width && height == s_backbuffer_height)
// return true;
[GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]];
[GLWin.cocoaCtx setView: GLWin.cocoaWin];
[GLWin.cocoaCtx update];
[GLWin.cocoaCtx makeCurrentContext];
s_backbuffer_width = width;
@ -110,7 +111,6 @@ bool cInterfaceAGL::MakeCurrent()
// Close backend
void cInterfaceAGL::Shutdown()
{
[GLWin.cocoaWin close];
[GLWin.cocoaCtx clearDrawable];
[GLWin.cocoaCtx release];
}

View file

@ -69,8 +69,6 @@ bool cInterfaceGLX::Create(void *&window_handle)
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_SAMPLE_BUFFERS_ARB, g_Config.iMultisampleMode != MULTISAMPLE_OFF?1:0,
GLX_SAMPLES_ARB, g_Config.iMultisampleMode != MULTISAMPLE_OFF?1:0,
None };
int attrListDefault[] = {

View file

@ -1,96 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "VideoConfig.h"
#include "Host.h"
#include "RenderBase.h"
#include "VertexShaderManager.h"
#include "../GLInterface.h"
#include "WX.h"
void cInterfaceWX::SwapInterval(int Interval)
{
// WX interface only used on Apple
#ifdef __APPLE__
#if defined USE_WX && USE_WX
NSOpenGLContext *ctx = GLWin.glCtxt->GetWXGLContext();
#else
NSOpenGLContext *ctx = GLWin.cocoaCtx;
#endif
[ctx setValues: &Interval forParameter: NSOpenGLCPSwapInterval];
#endif
}
void cInterfaceWX::Swap()
{
GLWin.glCanvas->SwapBuffers();
}
void cInterfaceWX::UpdateFPSDisplay(const char *text)
{
// Handled by Host_UpdateTitle()
}
// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceWX::Create(void *&window_handle)
{
int _tx, _ty, _twidth, _theight;
Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight);
// Control window size and picture scaling
s_backbuffer_width = _twidth;
s_backbuffer_height = _theight;
GLWin.panel = (wxPanel *)window_handle;
GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, NULL,
wxPoint(0, 0), wxSize(_twidth, _theight));
GLWin.glCanvas->Show(true);
if (GLWin.glCtxt == NULL) // XXX dirty hack
GLWin.glCtxt = new wxGLContext(GLWin.glCanvas);
return true;
}
bool cInterfaceWX::MakeCurrent()
{
return GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
}
// Update window width, size and etc. Called from Render.cpp
void cInterfaceWX::Update()
{
int width, height;
GLWin.panel->GetSize(&width, &height);
if (width == s_backbuffer_width && height == s_backbuffer_height)
return;
GLWin.glCanvas->SetFocus();
GLWin.glCanvas->SetSize(0, 0, width, height);
GLWin.glCtxt->SetCurrent(*GLWin.glCanvas);
s_backbuffer_width = width;
s_backbuffer_height = height;
}
// Close backend
void cInterfaceWX::Shutdown()
{
GLWin.glCanvas->Hide();
}

View file

@ -1,48 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _INTERFACEWX_H_
#define _INTERFACEWX_H_
#if defined HAVE_X11 && HAVE_X11
#include <GL/glxew.h>
#include <GL/gl.h>
#elif defined __APPLE__
#include <GL/glew.h>
#import <AppKit/AppKit.h>
#endif
#if defined USE_WX && USE_WX
#include "wx/wx.h"
#include "wx/glcanvas.h"
#endif
#include "InterfaceBase.h"
class cInterfaceWX : public cInterfaceBase
{
public:
void SwapInterval(int Interval);
void Swap();
void UpdateFPSDisplay(const char *Text);
bool Create(void *&window_handle);
bool MakeCurrent();
void Shutdown();
void Update();
};
#endif

View file

@ -64,6 +64,10 @@
#endif
#ifdef __APPLE__
#import <AppKit/AppKit.h>
#endif
// Nvidia drivers >= v302 will check if the application exports a global
// variable named NvOptimusEnablement to know if it should run the app in high
// performance graphics mode or using the IGP.
@ -232,6 +236,17 @@ bool DolphinApp::OnInit()
return false;
}
#endif
#ifdef __APPLE__
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_7)
{
PanicAlertT("Hi,\n\nDolphin requires OS X 10.7 or greater.\n"
"Unfortunately you're running an old version of OS X.\n"
"The last Dolphin version to support OS X 10.6 is Dolphin 3.5\n"
"Please upgrade to 10.7 or greater to use the newest Dolphin version.\n\n"
"Sayonara!\n");
return false;
}
#endif
#ifdef _WIN32
if (!wxSetWorkingDirectory(StrToWxStr(File::GetExeDirectory())))

View file

@ -82,6 +82,7 @@ wxString af_desc = wxTRANSLATE("Enable anisotropic filtering.\nEnhances visual q
wxString aa_desc = wxTRANSLATE("Reduces the amount of aliasing caused by rasterizing 3D graphics.\nThis makes the rendered picture look less blocky.\nHeavily decreases emulation speed and sometimes causes issues.\n\nIf unsure, select None.");
wxString scaled_efb_copy_desc = wxTRANSLATE("Greatly increases quality of textures generated using render to texture effects.\nRaising the internal resolution will improve the effect of this setting.\nSlightly decreases performance and possibly causes issues (although unlikely).\n\nIf unsure, leave this checked.");
wxString pixel_lighting_desc = wxTRANSLATE("Calculate lighting of 3D graphics per-pixel rather than per vertex.\nDecreases emulation speed by some percent (depending on your GPU).\nThis usually is a safe enhancement, but might cause issues sometimes.\n\nIf unsure, leave this unchecked.");
wxString hacked_buffer_upload_desc = wxTRANSLATE("Use a hacked upload strategy to stream vertices.\nThis usually speed up, but is forbidden by OpenGL specification and may causes heavy glitches.\n\nIf unsure, leave this unchecked.");
wxString force_filtering_desc = wxTRANSLATE("Force texture filtering even if the emulated game explicitly disabled it.\nImproves texture quality slightly but causes glitches in some games.\n\nIf unsure, leave this unchecked.");
wxString _3d_vision_desc = wxTRANSLATE("Enable 3D effects via stereoscopy using Nvidia 3D Vision technology if it's supported by your GPU.\nPossibly causes issues.\nRequires fullscreen to work.\n\nIf unsure, leave this unchecked.");
wxString internal_res_desc = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality a lot but is also quite heavy on performance and might cause glitches in certain games.\n\"Multiple of 640x528\" is a bit slower than \"Window Size\" but yields less issues. Generally speaking, the lower the internal resolution is, the better your performance will be.\n\nIf unsure, select 640x528.");
@ -486,13 +487,17 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
// - other hacks
{
wxGridSizer* const szr_other = new wxGridSizer(2, 5, 5);
SettingCheckBox* hacked_buffer_upload_cb;
szr_other->Add(CreateCheckBox(page_hacks, _("Cache Display Lists"), wxGetTranslation(dlc_desc), vconfig.bDlistCachingEnable));
szr_other->Add(CreateCheckBox(page_hacks, _("Disable Fog"), wxGetTranslation(disable_fog_desc), vconfig.bDisableFog));
szr_other->Add(CreateCheckBox(page_hacks, _("Skip Dest. Alpha Pass"), wxGetTranslation(disable_alphapass_desc), vconfig.bDstAlphaPass));
szr_other->Add(CreateCheckBox(page_hacks, _("OpenCL Texture Decoder"), wxGetTranslation(opencl_desc), vconfig.bEnableOpenCL));
szr_other->Add(CreateCheckBox(page_hacks, _("OpenMP Texture Decoder"), wxGetTranslation(omp_desc), vconfig.bOMPDecoder));
szr_other->Add(hacked_buffer_upload_cb = CreateCheckBox(page_hacks, _("Hacked Buffer Upload"), wxGetTranslation(hacked_buffer_upload_desc), vconfig.bHackedBufferUpload));
if (Core::GetState() != Core::CORE_UNINITIALIZED)
hacked_buffer_upload_cb->Disable();
wxStaticBoxSizer* const group_other = new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("Other"));
group_other->Add(szr_other, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
szr_hacks->Add(group_other, 0, wxEXPAND | wxALL, 5);
@ -564,7 +569,6 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
szr_misc->Add(cb_prog_scan);
}
wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Misc"));
szr_advanced->Add(group_misc, 0, wxEXPAND | wxALL, 5);
group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);

View file

@ -236,7 +236,7 @@ bool GetConfig(const int &type)
case CONFIG_DISABLEFOG:
return g_ActiveConfig.bDisableFog;
case CONFIG_SHOWEFBREGIONS:
return false;
return g_ActiveConfig.bShowEFBCopyRegions;
default:
PanicAlert("GetConfig Error: Unknown Config Type!");
return false;
@ -248,6 +248,7 @@ u8 *GetPointer(const u32 &address)
return Memory::GetPointer(address);
}
// Never used. All backends call SetSamplerState in VertexManager::Flush
void SetTextureMode(const BPCmd &bp)
{
g_renderer->SetSamplerState(bp.address & 3, (bp.address & 0xE0) == 0xA0);

View file

@ -225,6 +225,8 @@ void BPWritten(const BPCmd& bp)
{
PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
if(bp.changes & 0x100)
SetBlendMode();
break;
}
// This is called when the game is done drawing the new frame (eg: like in DX: Begin(); Draw(); End();)
@ -459,6 +461,8 @@ void BPWritten(const BPCmd& bp)
g_renderer->SetColorMask(); // alpha writing needs to be disabled if the new pixel format doesn't have an alpha channel
g_renderer->SetBlendMode(true);
OnPixelFormatChange();
if(bp.changes & 3)
SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24
break;
case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel
@ -576,8 +580,6 @@ void BPWritten(const BPCmd& bp)
// ------------------------
case BPMEM_TX_SETMODE0: // (0x90 for linear)
case BPMEM_TX_SETMODE0_4:
// Shouldn't need to call this here, we call it for each active texture right before rendering
SetTextureMode(bp);
break;
case BPMEM_TX_SETMODE1:
@ -719,14 +721,6 @@ void BPReload()
SetBlendMode();
SetColorMask();
OnPixelFormatChange();
{
BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0])};
SetTextureMode(bp);
}
{
BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])};
SetTextureMode(bp);
}
{
BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast<int>(((u32*)&bpmem)[BPMEM_FIELDMASK])};
SetInterlacingMode(bp);

View file

@ -163,13 +163,9 @@ void FramebufferManagerBase::CopyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHe
// keep stale XFB data from being used
ReplaceVirtualXFB();
g_renderer->ResetAPIState(); // reset any game specific settings
// Copy EFB data to XFB and restore render target again
vxfb->xfbSource->CopyEFB(Gamma);
g_renderer->RestoreAPIState();
}
FramebufferManagerBase::VirtualXFBListType::iterator FramebufferManagerBase::FindVirtualXFB(u32 xfbAddr, u32 width, u32 height)

View file

@ -47,13 +47,13 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char
// atten disabled
switch (chan.diffusefunc) {
case LIGHTDIF_NONE:
WRITE(p, "lacc.%s += %s.lights[%d].col.%s;\n", swizzle, lightsName, index, swizzle);
WRITE(p, "lacc.%s += %s[%d].%s;\n", swizzle, lightsName, index * 5, swizzle);
break;
case LIGHTDIF_SIGN:
case LIGHTDIF_CLAMP:
WRITE(p, "ldir = normalize(%s.lights[%d].pos.xyz - pos.xyz);\n", lightsName, index);
WRITE(p, "lacc.%s += %sdot(ldir, _norm0)) * %s.lights[%d].col.%s;\n",
swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", lightsName, index, swizzle);
WRITE(p, "ldir = normalize(%s[%d + 3].xyz - pos.xyz);\n", lightsName, index * 5);
WRITE(p, "lacc.%s += %sdot(ldir, _norm0)) * %s[%d].%s;\n",
swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", lightsName, index * 5, swizzle);
break;
default: _assert_(0);
}
@ -62,32 +62,32 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char
if (chan.attnfunc == 3)
{ // spot
WRITE(p, "ldir = %s.lights[%d].pos.xyz - pos.xyz;\n", lightsName, index);
WRITE(p, "ldir = %s[%d + 3].xyz - pos.xyz;\n", lightsName, index * 5);
WRITE(p, "dist2 = dot(ldir, ldir);\n"
"dist = sqrt(dist2);\n"
"ldir = ldir / dist;\n"
"attn = max(0.0f, dot(ldir, %s.lights[%d].dir.xyz));\n", lightsName, index);
WRITE(p, "attn = max(0.0f, dot(%s.lights[%d].cosatt.xyz, float3(1.0f, attn, attn*attn))) / dot(%s.lights[%d].distatt.xyz, float3(1.0f,dist,dist2));\n", lightsName, index, lightsName, index);
"attn = max(0.0f, dot(ldir, %s[%d + 4].xyz));\n", lightsName, index * 5);
WRITE(p, "attn = max(0.0f, dot(%s[%d + 1].xyz, float3(1.0f, attn, attn*attn))) / dot(%s[%d + 2].xyz, float3(1.0f,dist,dist2));\n", lightsName, index * 5, lightsName, index * 5);
}
else if (chan.attnfunc == 1)
{ // specular
WRITE(p, "ldir = normalize(%s.lights[%d].pos.xyz);\n", lightsName, index);
WRITE(p, "attn = (dot(_norm0,ldir) >= 0.0f) ? max(0.0f, dot(_norm0, %s.lights[%d].dir.xyz)) : 0.0f;\n", lightsName, index);
WRITE(p, "attn = max(0.0f, dot(%s.lights[%d].cosatt.xyz, float3(1,attn,attn*attn))) / dot(%s.lights[%d].distatt.xyz, float3(1,attn,attn*attn));\n", lightsName, index, lightsName, index);
WRITE(p, "ldir = normalize(%s[%d + 3].xyz);\n", lightsName, index * 5);
WRITE(p, "attn = (dot(_norm0,ldir) >= 0.0f) ? max(0.0f, dot(_norm0, %s[%d + 4].xyz)) : 0.0f;\n", lightsName, index * 5);
WRITE(p, "attn = max(0.0f, dot(%s[%d + 1].xyz, float3(1,attn,attn*attn))) / dot(%s[%d + 2].xyz, float3(1,attn,attn*attn));\n", lightsName, index * 5, lightsName, index * 5);
}
switch (chan.diffusefunc)
{
case LIGHTDIF_NONE:
WRITE(p, "lacc.%s += attn * %s.lights[%d].col.%s;\n", swizzle, lightsName, index, swizzle);
WRITE(p, "lacc.%s += attn * %s[%d].%s;\n", swizzle, lightsName, index * 5, swizzle);
break;
case LIGHTDIF_SIGN:
case LIGHTDIF_CLAMP:
WRITE(p, "lacc.%s += attn * %sdot(ldir, _norm0)) * %s.lights[%d].col.%s;\n",
WRITE(p, "lacc.%s += attn * %sdot(ldir, _norm0)) * %s[%d].%s;\n",
swizzle,
chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(",
lightsName,
index,
index * 5,
swizzle);
break;
default: _assert_(0);
@ -120,7 +120,7 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
}
else // from color
WRITE(p, "mat = %s.C%d;\n", materialsName, j+2);
WRITE(p, "mat = %s[%d];\n", materialsName, j+2);
if (color.enablelighting) {
if (color.ambsource) { // from vertex
@ -132,7 +132,7 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "lacc = float4(0.0f, 0.0f, 0.0f, 0.0f);\n");
}
else // from color
WRITE(p, "lacc = %s.C%d;\n", materialsName, j);
WRITE(p, "lacc = %s[%d];\n", materialsName, j);
}
else
{
@ -149,7 +149,7 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
else WRITE(p, "mat.w = 1.0f;\n");
}
else // from color
WRITE(p, "mat.w = %s.C%d.w;\n", materialsName, j+2);
WRITE(p, "mat.w = %s[%d].w;\n", materialsName, j+2);
}
if (alpha.enablelighting)
@ -163,7 +163,7 @@ char *GenerateLightingShader(char *p, int components, const char* materialsName,
WRITE(p, "lacc.w = 0.0f;\n");
}
else // from color
WRITE(p, "lacc.w = %s.C%d.w;\n", materialsName, j);
WRITE(p, "lacc.w = %s[%d].w;\n", materialsName, j);
}
else
{

View file

@ -102,7 +102,7 @@ public:
virtual void SetupVertexPointers() = 0;
virtual void EnableComponents(u32 components) {}
int GetVertexStride() const { return vertex_stride; }
u32 GetVertexStride() const { return vertex_stride; }
// TODO: move this under private:
u32 m_components; // VB_HAS_X. Bitmask telling what vertex components are present.

View file

@ -394,7 +394,7 @@ static void Decode()
// Display lists get added directly into the FIFO stream
if (g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL)
FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, g_pVideoData - opcodeStart);
FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, u32(g_pVideoData - opcodeStart));
}
static void DecodeSemiNop()
@ -477,7 +477,7 @@ static void DecodeSemiNop()
}
if (g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL)
FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, g_pVideoData - opcodeStart);
FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, u32(g_pVideoData - opcodeStart));
}
void OpcodeDecoder_Init()

View file

@ -173,7 +173,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
*ptr++ = components;
}
uid->num_values = ptr - uid->values;
uid->num_values = int(ptr - uid->values);
}
void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode, u32 components)
@ -205,7 +205,7 @@ void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode, u
*ptr++ = bpmem.tevindref.hex; // 31
for (unsigned int i = 0; i < bpmem.genMode.numtevstages+1u; ++i) // up to 16 times
for (u32 i = 0; i < bpmem.genMode.numtevstages+1u; ++i) // up to 16 times
{
*ptr++ = bpmem.combiners[i].colorC.hex; // 32+5*i
*ptr++ = bpmem.combiners[i].alphaC.hex; // 33+5*i
@ -440,8 +440,8 @@ static const char *tevRasTable[] =
"ERROR13", //2
"ERROR14", //3
"ERROR15", //4
"alphabump", // use bump alpha
"(alphabump*(255.0f/248.0f))", //normalized
"float4(alphabump,alphabump,alphabump,alphabump)", // use bump alpha
"(float4(alphabump,alphabump,alphabump,alphabump)*(255.0f/248.0f))", //normalized
"float4(0.0f, 0.0f, 0.0f, 0.0f)", // zero
};
@ -485,6 +485,24 @@ static void BuildSwapModeTable()
}
}
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
{
if (ApiType == API_OPENGL)
return ""; // Nothing to do here
static char result[64];
sprintf(result, " : register(%s%d)", prefix, num);
return result;
}
const char *WriteLocation(API_TYPE ApiType)
{
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
return "";
static char result[64];
sprintf(result, "uniform ");
return result;
}
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
{
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
@ -510,138 +528,216 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt;
}
}
// Declare samplers
if(ApiType != API_D3D11)
if (ApiType == API_OPENGL)
{
WRITE(p, "uniform sampler2D ");
}
else
{
WRITE(p, "sampler ");
}
bool bfirst = true;
for (int i = 0; i < 8; ++i)
{
WRITE(p, "%s samp%d : register(s%d)", bfirst?"":",", i, i);
bfirst = false;
}
WRITE(p, ";\n");
if(ApiType == API_D3D11)
{
WRITE(p, "Texture2D ");
bfirst = true;
// A function here
// Fmod implementation gleaned from Nvidia
// At http://http.developer.nvidia.com/Cg/fmod.html
WRITE(p, "float fmod( float x, float y )\n");
WRITE(p, "{\n");
WRITE(p, "\tfloat z = fract( abs( x / y) ) * abs( y );\n");
WRITE(p, "\treturn (x < 0) ? -z : z;\n");
WRITE(p, "}\n");
for (int i = 0; i < 8; ++i)
{
WRITE(p, "%s Tex%d : register(t%d)", bfirst?"":",", i, i);
bfirst = false;
}
WRITE(p, ";\n");
}
WRITE(p, "\n");
WRITE(p, "uniform float4 " I_COLORS"[4] : register(c%d);\n", C_COLORS);
WRITE(p, "uniform float4 " I_KCOLORS"[4] : register(c%d);\n", C_KCOLORS);
WRITE(p, "uniform float4 " I_ALPHA"[1] : register(c%d);\n", C_ALPHA);
WRITE(p, "uniform float4 " I_TEXDIMS"[8] : register(c%d);\n", C_TEXDIMS);
WRITE(p, "uniform float4 " I_ZBIAS"[2] : register(c%d);\n", C_ZBIAS);
WRITE(p, "uniform float4 " I_INDTEXSCALE"[2] : register(c%d);\n", C_INDTEXSCALE);
WRITE(p, "uniform float4 " I_INDTEXMTX"[6] : register(c%d);\n", C_INDTEXMTX);
WRITE(p, "uniform float4 " I_FOG"[3] : register(c%d);\n", C_FOG);
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
WRITE(p,"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n");
WRITE(p,"typedef struct { Light lights[8]; } s_" I_PLIGHTS";\n");
WRITE(p, "uniform s_" I_PLIGHTS" " I_PLIGHTS" : register(c%d);\n", C_PLIGHTS);
WRITE(p, "typedef struct { float4 C0, C1, C2, C3; } s_" I_PMATERIALS";\n");
WRITE(p, "uniform s_" I_PMATERIALS" " I_PMATERIALS" : register(c%d);\n", C_PMATERIALS);
}
WRITE(p, "void main(\n");
if(ApiType != API_D3D11)
{
WRITE(p, " out float4 ocol0 : COLOR0,%s%s\n in float4 rawpos : %s,\n",
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : COLOR1," : "",
per_pixel_depth ? "\n out float depth : DEPTH," : "",
ApiType & API_OPENGL ? "WPOS" : ApiType & API_D3D9_SM20 ? "POSITION" : "VPOS");
WRITE(p, "uniform sampler2D samp%d;\n", i);
}
else
{
WRITE(p, " out float4 ocol0 : SV_Target0,%s%s\n in float4 rawpos : SV_Position,\n",
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : SV_Target1," : "",
per_pixel_depth ? "\n out float depth : SV_Depth," : "");
}
WRITE(p, " in float4 colors_0 : COLOR0,\n");
WRITE(p, " in float4 colors_1 : COLOR1");
// compute window position if needed because binding semantic WPOS is not widely supported
if (numTexgen < 7)
{
for (int i = 0; i < numTexgen; ++i)
WRITE(p, ",\n in float3 uv%d : TEXCOORD%d", i, i);
WRITE(p, ",\n in float4 clipPos : TEXCOORD%d", numTexgen);
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, ",\n in float4 Normal : TEXCOORD%d", numTexgen + 1);
}
else
{
// wpos is in w of first 4 texcoords
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
// Declare samplers
if (ApiType != API_D3D11)
{
for (int i = 0; i < 8; ++i)
WRITE(p, ",\n in float4 uv%d : TEXCOORD%d", i, i);
WRITE(p, "uniform sampler2D ");
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, ",\n in float%d uv%d : TEXCOORD%d", i < 4 ? 4 : 3 , i, i);
WRITE(p, "sampler ");
}
bool bfirst = true;
for (int i = 0; i < 8; ++i)
{
WRITE(p, "%s samp%d %s", bfirst?"":",", i, WriteRegister(ApiType, "s", i));
bfirst = false;
}
WRITE(p, ";\n");
if (ApiType == API_D3D11)
{
WRITE(p, "Texture2D ");
bfirst = true;
for (int i = 0; i < 8; ++i)
{
WRITE(p, "%s Tex%d : register(t%d)", bfirst?"":",", i, i);
bfirst = false;
}
WRITE(p, ";\n");
}
}
WRITE(p, "\n");
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "layout(std140) uniform PSBlock {\n");
WRITE(p, "\t%sfloat4 " I_COLORS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_COLORS));
WRITE(p, "\t%sfloat4 " I_KCOLORS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_KCOLORS));
WRITE(p, "\t%sfloat4 " I_ALPHA"[1] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_ALPHA));
WRITE(p, "\t%sfloat4 " I_TEXDIMS"[8] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TEXDIMS));
WRITE(p, "\t%sfloat4 " I_ZBIAS"[2] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_ZBIAS));
WRITE(p, "\t%sfloat4 " I_INDTEXSCALE"[2] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_INDTEXSCALE));
WRITE(p, "\t%sfloat4 " I_INDTEXMTX"[6] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_INDTEXMTX));
WRITE(p, "\t%sfloat4 " I_FOG"[3] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_FOG));
// For pixel lighting
WRITE(p, "\t%sfloat4 " I_PLIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PLIGHTS));
WRITE(p, "\t%sfloat4 " I_PMATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PMATERIALS));
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "};\n");
if (ApiType == API_OPENGL)
{
WRITE(p, "out float4 ocol0;\n");
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
WRITE(p, "out float4 ocol1;\n");
if (per_pixel_depth)
WRITE(p, "#define depth gl_FragDepth\n");
WRITE(p, "float4 rawpos = gl_FragCoord;\n");
WRITE(p, "VARYIN float4 colors_02;\n");
WRITE(p, "VARYIN float4 colors_12;\n");
WRITE(p, "float4 colors_0 = colors_02;\n");
WRITE(p, "float4 colors_1 = colors_12;\n");
// compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes
if (xfregs.numTexGen.numTexGens < 7)
{
for (int i = 0; i < 8; ++i)
{
WRITE(p, "VARYIN float3 uv%d_2;\n", i);
WRITE(p, "float3 uv%d = uv%d_2;\n", i, i);
}
WRITE(p, "VARYIN float4 clipPos_2;\n");
WRITE(p, "float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
WRITE(p, "VARYIN float4 Normal_2;\n");
WRITE(p, "float4 Normal = Normal_2;\n");
}
}
else
{
// wpos is in w of first 4 texcoords
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
for (int i = 0; i < 8; ++i)
{
WRITE(p, "VARYIN float4 uv%d_2;\n", i);
WRITE(p, "float4 uv%d = uv%d_2;\n", i, i);
}
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{
WRITE(p, "VARYIN float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
WRITE(p, "float%d uv%d = uv%d_2;\n", i < 4 ? 4 : 3 , i, i);
}
}
WRITE(p, "float4 clipPos;\n");
}
WRITE(p, "void main()\n{\n");
}
else
{
WRITE(p, "void main(\n");
if (ApiType != API_D3D11)
{
WRITE(p, " out float4 ocol0 : COLOR0,%s%s\n in float4 rawpos : %s,\n",
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : COLOR1," : "",
per_pixel_depth ? "\n out float depth : DEPTH," : "",
ApiType & API_D3D9_SM20 ? "POSITION" : "VPOS");
}
else
{
WRITE(p, " out float4 ocol0 : SV_Target0,%s%s\n in float4 rawpos : SV_Position,\n",
dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : SV_Target1," : "",
per_pixel_depth ? "\n out float depth : SV_Depth," : "");
}
WRITE(p, " in float4 colors_0 : COLOR0,\n");
WRITE(p, " in float4 colors_1 : COLOR1");
// compute window position if needed because binding semantic WPOS is not widely supported
if (numTexgen < 7)
{
for (int i = 0; i < numTexgen; ++i)
WRITE(p, ",\n in float3 uv%d : TEXCOORD%d", i, i);
WRITE(p, ",\n in float4 clipPos : TEXCOORD%d", numTexgen);
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, ",\n in float4 Normal : TEXCOORD%d", numTexgen + 1);
WRITE(p, " ) {\n");
}
else
{
// wpos is in w of first 4 texcoords
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
for (int i = 0; i < 8; ++i)
WRITE(p, ",\n in float4 uv%d : TEXCOORD%d", i, i);
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, ",\n in float%d uv%d : TEXCOORD%d", i < 4 ? 4 : 3 , i, i);
}
WRITE(p, " ) {\n");
WRITE(p, "\tfloat4 clipPos = float4(0.0f, 0.0f, 0.0f, 0.0f);");
}
}
WRITE(p, " ) {\n");
WRITE(p, " float4 c0 = " I_COLORS"[1], c1 = " I_COLORS"[2], c2 = " I_COLORS"[3], prev = float4(0.0f, 0.0f, 0.0f, 0.0f), textemp = float4(0.0f, 0.0f, 0.0f, 0.0f), rastemp = float4(0.0f, 0.0f, 0.0f, 0.0f), konsttemp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n"
" float3 comp16 = float3(1.0f, 255.0f, 0.0f), comp24 = float3(1.0f, 255.0f, 255.0f*255.0f);\n"
" float4 alphabump=float4(0.0f,0.0f,0.0f,0.0f);\n"
" float alphabump=0.0f;\n"
" float3 tevcoord=float3(0.0f, 0.0f, 0.0f);\n"
" float2 wrappedcoord=float2(0.0f,0.0f), tempcoord=float2(0.0f,0.0f);\n"
" float4 cc0=float4(0.0f,0.0f,0.0f,0.0f), cc1=float4(0.0f,0.0f,0.0f,0.0f);\n"
" float4 cc2=float4(0.0f,0.0f,0.0f,0.0f), cprev=float4(0.0f,0.0f,0.0f,0.0f);\n"
" float4 crastemp=float4(0.0f,0.0f,0.0f,0.0f),ckonsttemp=float4(0.0f,0.0f,0.0f,0.0f);\n\n");
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
if (xfregs.numTexGen.numTexGens < 7)
{
WRITE(p,"float3 _norm0 = normalize(Normal.xyz);\n\n");
WRITE(p,"float3 pos = float3(clipPos.x,clipPos.y,Normal.w);\n");
WRITE(p,"\tfloat3 _norm0 = normalize(Normal.xyz);\n\n");
WRITE(p,"\tfloat3 pos = float3(clipPos.x,clipPos.y,Normal.w);\n");
}
else
{
WRITE(p," float3 _norm0 = normalize(float3(uv4.w,uv5.w,uv6.w));\n\n");
WRITE(p,"float3 pos = float3(uv0.w,uv1.w,uv7.w);\n");
WRITE(p,"\tfloat3 _norm0 = normalize(float3(uv4.w,uv5.w,uv6.w));\n\n");
WRITE(p,"\tfloat3 pos = float3(uv0.w,uv1.w,uv7.w);\n");
}
WRITE(p, "float4 mat, lacc;\n"
"float3 ldir, h;\n"
"float dist, dist2, attn;\n");
WRITE(p, "\tfloat4 mat, lacc;\n"
"\tfloat3 ldir, h;\n"
"\tfloat dist, dist2, attn;\n");
p = GenerateLightingShader(p, components, I_PMATERIALS, I_PLIGHTS, "colors_", "colors_");
}
if (numTexgen < 7)
WRITE(p, "clipPos = float4(rawpos.x, rawpos.y, clipPos.z, clipPos.w);\n");
WRITE(p, "\tclipPos = float4(rawpos.x, rawpos.y, clipPos.z, clipPos.w);\n");
else
WRITE(p, "float4 clipPos = float4(rawpos.x, rawpos.y, uv2.w, uv3.w);\n");
WRITE(p, "\tclipPos = float4(rawpos.x, rawpos.y, uv2.w, uv3.w);\n");
// HACK to handle cases where the tex gen is not enabled
if (numTexgen == 0)
{
WRITE(p, "float3 uv0 = float3(0.0f, 0.0f, 0.0f);\n");
WRITE(p, "\tfloat3 uv0 = float3(0.0f, 0.0f, 0.0f);\n");
}
else
{
@ -650,8 +746,8 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
// optional perspective divides
if (xfregs.texMtxInfo[i].projection == XF_TEXPROJ_STQ)
{
WRITE(p, "if (uv%d.z)", i);
WRITE(p, " uv%d.xy = uv%d.xy / uv%d.z;\n", i, i, i);
WRITE(p, "\tif (uv%d.z != 0.0f)", i);
WRITE(p, "\t\tuv%d.xy = uv%d.xy / uv%d.z;\n", i, i, i);
}
WRITE(p, "uv%d.xy = uv%d.xy * " I_TEXDIMS"[%d].zw;\n", i, i, i);
@ -659,16 +755,16 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
}
// indirect texture map lookup
for(u32 i = 0; i < bpmem.genMode.numindstages; ++i)
for (u32 i = 0; i < bpmem.genMode.numindstages; ++i)
{
if (nIndirectStagesUsed & (1<<i))
{
int texcoord = bpmem.tevindref.getTexCoord(i);
if (texcoord < numTexgen)
WRITE(p, "tempcoord = uv%d.xy * " I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
WRITE(p, "\ttempcoord = uv%d.xy * " I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
else
WRITE(p, "tempcoord = float2(0.0f, 0.0f);\n");
WRITE(p, "\ttempcoord = float2(0.0f, 0.0f);\n");
char buffer[32];
sprintf(buffer, "float3 indtex%d", i);
@ -689,26 +785,26 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
for (int i = 0; i < numStages; i++)
WriteStage(p, i, ApiType); //build the equation for this stage
if(numStages)
if (numStages)
{
// The results of the last texenv stage are put onto the screen,
// regardless of the used destination register
if(bpmem.combiners[numStages - 1].colorC.dest != 0)
{
bool retrieveFromAuxRegister = !RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].ColorNeedOverflowControl && RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].AuxStored;
WRITE(p, "prev.rgb = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevCOutputTable[bpmem.combiners[numStages - 1].colorC.dest]);
WRITE(p, "\tprev.rgb = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevCOutputTable[bpmem.combiners[numStages - 1].colorC.dest]);
RegisterStates[0].ColorNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].ColorNeedOverflowControl;
}
if(bpmem.combiners[numStages - 1].alphaC.dest != 0)
{
bool retrieveFromAuxRegister = !RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl && RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AuxStored;
WRITE(p, "prev.a = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevAOutputTable[bpmem.combiners[numStages - 1].alphaC.dest]);
WRITE(p, "\tprev.a = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevAOutputTable[bpmem.combiners[numStages - 1].alphaC.dest]);
RegisterStates[0].AlphaNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl;
}
}
// emulation of unsigned 8 overflow when casting if needed
if(RegisterStates[0].AlphaNeedOverflowControl || RegisterStates[0].ColorNeedOverflowControl)
WRITE(p, "prev = frac(prev * (255.0f/256.0f)) * (256.0f/255.0f);\n");
WRITE(p, "\tprev = frac(prev * (255.0f/256.0f)) * (256.0f/255.0f);\n");
AlphaTest::TEST_RESULT Pretest = bpmem.alpha_test.TestResult();
if (Pretest == AlphaTest::UNDETERMINED)
@ -741,11 +837,11 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
}
if (dstAlphaMode == DSTALPHA_ALPHA_PASS)
WRITE(p, " ocol0 = float4(prev.rgb, " I_ALPHA"[0].a);\n");
WRITE(p, "\tocol0 = float4(prev.rgb, " I_ALPHA"[0].a);\n");
else
{
WriteFog(p);
WRITE(p, " ocol0 = prev;\n");
WRITE(p, "\tocol0 = prev;\n");
}
// On D3D11, use dual-source color blending to perform dst alpha in a
@ -753,9 +849,9 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
{
// Colors will be blended against the alpha from ocol1...
WRITE(p, " ocol1 = ocol0;\n");
WRITE(p, "\tocol1 = prev;\n");
// ...and the alpha from ocol0 will be written to the framebuffer.
WRITE(p, " ocol0.a = " I_ALPHA"[0].a;\n");
WRITE(p, "\tocol0.a = " I_ALPHA"[0].a;\n");
}
WRITE(p, "}\n");
@ -864,10 +960,10 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
WRITE(p, "float2 indtevtrans%d = " I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
}
else
WRITE(p, "float2 indtevtrans%d = 0;\n", n);
WRITE(p, "float2 indtevtrans%d = float2(0.0f);\n", n);
}
else
WRITE(p, "float2 indtevtrans%d = 0;\n", n);
WRITE(p, "float2 indtevtrans%d = float2(0.0f);\n", n);
// ---------
// Wrapping
@ -913,10 +1009,10 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
if (bpmem.tevorders[n/2].getEnable(n&1))
{
if(!bHasIndStage)
if (!bHasIndStage)
{
// calc tevcord
if(bHasTexCoord)
if (bHasTexCoord)
WRITE(p, "tevcoord.xy = uv%d.xy;\n", texcoord);
else
WRITE(p, "tevcoord.xy = float2(0.0f, 0.0f);\n");
@ -936,7 +1032,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
int kc = bpmem.tevksel[n / 2].getKC(n & 1);
int ka = bpmem.tevksel[n / 2].getKA(n & 1);
WRITE(p, "konsttemp = float4(%s, %s);\n", tevKSelTableC[kc], tevKSelTableA[ka]);
if(kc > 7 || ka > 7)
if (kc > 7 || ka > 7)
{
WRITE(p, "ckonsttemp = frac(konsttemp * (255.0f/256.0f)) * (256.0f/255.0f);\n");
}
@ -1035,7 +1131,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
if (cc.shift > TEVSCALE_1)
WRITE(p, "%s*(", tevScaleTable[cc.shift]);
if(!(cc.d == TEVCOLORARG_ZERO && cc.op == TEVOP_ADD))
if (!(cc.d == TEVCOLORARG_ZERO && cc.op == TEVOP_ADD))
WRITE(p, "%s%s", tevCInputTable[cc.d], tevOpTable[cc.op]);
if (cc.a == cc.b)
@ -1085,7 +1181,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
if (ac.shift > TEVSCALE_1)
WRITE(p, "%s*(", tevScaleTable[ac.shift]);
if(!(ac.d == TEVALPHAARG_ZERO && ac.op == TEVOP_ADD))
if (!(ac.d == TEVALPHAARG_ZERO && ac.op == TEVOP_ADD))
WRITE(p, "%s.a%s", tevAInputTable[ac.d], tevOpTable[ac.op]);
if (ac.a == ac.b)
@ -1101,7 +1197,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
WRITE(p, "%s",tevBiasTable[ac.bias]);
if (ac.shift>0)
if (ac.shift > 0)
WRITE(p, ")");
}
@ -1126,7 +1222,7 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con
if (ApiType == API_D3D11)
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap);
else
WRITE(p, "%s=tex2D(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap);
WRITE(p, "%s=%s(samp%d,%s.xy * " I_TEXDIMS"[%d].xy).%s;\n", destination, ApiType == API_OPENGL ? "texture" : "tex2D", texmap, texcoords, texmap, texswap);
}
static const char *tevAlphaFuncsTable[] =
@ -1157,8 +1253,9 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
I_ALPHA"[0].g"
};
// using discard then return works the same in cg and dx9 but not in dx11
WRITE(p, "if(!( ");
WRITE(p, "\tif(!( ");
int compindex = bpmem.alpha_test.comp0;
WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[0]);//lookup the first component from the alpha function table
@ -1169,9 +1266,9 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[1]);//lookup the second component from the alpha function table
WRITE(p, ")) {\n");
WRITE(p, "ocol0 = 0;\n");
WRITE(p, "\t\tocol0 = float4(0.0f, 0.0f, 0.0f, 0.0f);\n");
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
WRITE(p, "ocol1 = 0;\n");
WRITE(p, "\t\tocol1 = float4(0.0f, 0.0f, 0.0f, 0.0f);\n");
if(per_pixel_depth)
WRITE(p, "depth = 1.f;\n");
@ -1187,9 +1284,9 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
// we don't have a choice.
if (!(bpmem.zcontrol.early_ztest && bpmem.zmode.updateenable))
{
WRITE(p, "discard;\n");
WRITE(p, "\t\tdiscard;\n");
if (ApiType != API_D3D11)
WRITE(p, "return;\n");
WRITE(p, "\t\treturn;\n");
}
WRITE(p, "}\n");
@ -1201,52 +1298,51 @@ static const char *tevFogFuncsTable[] =
"", //?
"", //Linear
"", //?
" fog = 1.0f - pow(2.0f, -8.0f * fog);\n", //exp
" fog = 1.0f - pow(2.0f, -8.0f * fog * fog);\n", //exp2
" fog = pow(2.0f, -8.0f * (1.0f - fog));\n", //backward exp
" fog = 1.0f - fog;\n fog = pow(2.0f, -8.0f * fog * fog);\n" //backward exp2
"\tfog = 1.0f - pow(2.0f, -8.0f * fog);\n", //exp
"\tfog = 1.0f - pow(2.0f, -8.0f * fog * fog);\n", //exp2
"\tfog = pow(2.0f, -8.0f * (1.0f - fog));\n", //backward exp
"\tfog = 1.0f - fog;\n fog = pow(2.0f, -8.0f * fog * fog);\n" //backward exp2
};
static void WriteFog(char *&p)
{
if(bpmem.fog.c_proj_fsel.fsel == 0)return;//no Fog
if (bpmem.fog.c_proj_fsel.fsel == 0)
return; // no Fog
if (bpmem.fog.c_proj_fsel.proj == 0)
{
// perspective
// ze = A/(B - (Zs >> B_SHF)
WRITE (p, " float ze = " I_FOG"[1].x / (" I_FOG"[1].y - (zCoord / " I_FOG"[1].w));\n");
WRITE (p, "\tfloat ze = " I_FOG"[1].x / (" I_FOG"[1].y - (zCoord / " I_FOG"[1].w));\n");
}
else
{
// orthographic
// ze = a*Zs (here, no B_SHF)
WRITE (p, " float ze = " I_FOG"[1].x * zCoord;\n");
WRITE (p, "\tfloat ze = " I_FOG"[1].x * zCoord;\n");
}
// x_adjust = sqrt((x-center)^2 + k^2)/k
// ze *= x_adjust
//this is complitly teorical as the real hard seems to use a table intead of calculate the values.
if(bpmem.fogRange.Base.Enabled)
if (bpmem.fogRange.Base.Enabled)
{
WRITE (p, " float x_adjust = (2.0f * (clipPos.x / " I_FOG"[2].y)) - 1.0f - " I_FOG"[2].x;\n");
WRITE (p, " x_adjust = sqrt(x_adjust * x_adjust + " I_FOG"[2].z * " I_FOG"[2].z) / " I_FOG"[2].z;\n");
WRITE (p, " ze *= x_adjust;\n");
WRITE (p, "\tfloat x_adjust = (2.0f * (clipPos.x / " I_FOG"[2].y)) - 1.0f - " I_FOG"[2].x;\n");
WRITE (p, "\tx_adjust = sqrt(x_adjust * x_adjust + " I_FOG"[2].z * " I_FOG"[2].z) / " I_FOG"[2].z;\n");
WRITE (p, "\tze *= x_adjust;\n");
}
WRITE (p, " float fog = saturate(ze - " I_FOG"[1].z);\n");
WRITE (p, "\tfloat fog = saturate(ze - " I_FOG"[1].z);\n");
if(bpmem.fog.c_proj_fsel.fsel > 3)
if (bpmem.fog.c_proj_fsel.fsel > 3)
{
WRITE(p, "%s", tevFogFuncsTable[bpmem.fog.c_proj_fsel.fsel]);
}
else
{
if(bpmem.fog.c_proj_fsel.fsel != 2)
if (bpmem.fog.c_proj_fsel.fsel != 2)
WARN_LOG(VIDEO, "Unknown Fog Type! %08x", bpmem.fog.c_proj_fsel.fsel);
}
WRITE(p, " prev.rgb = lerp(prev.rgb," I_FOG"[0].rgb,fog);\n");
WRITE(p, "\tprev.rgb = lerp(prev.rgb, " I_FOG"[0].rgb, fog);\n");
}

View file

@ -28,8 +28,8 @@
#define I_INDTEXSCALE "cindscale"
#define I_INDTEXMTX "cindmtx"
#define I_FOG "cfog"
#define I_PLIGHTS "cLights"
#define I_PMATERIALS "cmtrl"
#define I_PLIGHTS "cPLights"
#define I_PMATERIALS "cPmtrl"
#define C_COLORMATRIX 0 // 0
#define C_COLORS 0 // 0
@ -47,6 +47,19 @@
#define PIXELSHADERUID_MAX_VALUES 70
#define PIXELSHADERUID_MAX_VALUES_SAFE 115
// Annoying sure, can be removed once we get up to GLSL ~1.3
const s_svar PSVar_Loc[] = { {I_COLORS, C_COLORS, 4 },
{I_KCOLORS, C_KCOLORS, 4 },
{I_ALPHA, C_ALPHA, 1 },
{I_TEXDIMS, C_TEXDIMS, 8 },
{I_ZBIAS , C_ZBIAS, 2 },
{I_INDTEXSCALE , C_INDTEXSCALE, 2 },
{I_INDTEXMTX, C_INDTEXMTX, 6 },
{I_FOG, C_FOG, 3 },
{I_PLIGHTS, C_PLIGHTS, 40 },
{I_PMATERIALS, C_PMATERIALS, 4 },
};
// DO NOT make anything in this class virtual.
template<bool safe>
class _PIXELSHADERUID

View file

@ -85,6 +85,8 @@ void PixelShaderManager::Shutdown()
void PixelShaderManager::SetConstants()
{
if (g_ActiveConfig.backend_info.APIType == API_OPENGL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO)
Dirty();
for (int i = 0; i < 2; ++i)
{
if (s_nColorsChanged[i])

View file

@ -831,9 +831,5 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
entry->frameCount = frameCount;
g_renderer->ResetAPIState(); // reset any game specific settings
entry->FromRenderTarget(dstAddr, dstFormat, srcFormat, srcRect, isIntensity, scaleByHalf, cbufid, colmat);
g_renderer->RestoreAPIState();
}

View file

@ -26,6 +26,7 @@
#include "PixelShaderGen.h"
#include "BPMemory.h"
#include "RenderBase.h"
#include "VideoConfig.h"
#define WRITE p+=sprintf
@ -66,19 +67,31 @@ u16 GetEncodedSampleCount(u32 format)
}
}
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
{
if (ApiType == API_OPENGL)
return ""; // Once we switch to GLSL 1.3 we can do something here
static char result[64];
sprintf(result, " : register(%s%d)", prefix, num);
return result;
}
// block dimensions : widthStride, heightStride
// texture dims : width, height, x offset, y offset
void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
{
WRITE(p, "uniform float4 blkDims : register(c%d);\n", C_COLORMATRIX);
WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1);
// [0] left, top, right, bottom of source rectangle within source texture
// [1] width and height of destination texture in pixels
// Two were merged for GLSL
WRITE(p, "uniform float4 " I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS));
float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
float blkH = (float)TexDecoder_GetBlockHeightInTexels(format);
float samples = (float)GetEncodedSampleCount(format);
if(ApiType == API_OPENGL)
if (ApiType == API_OPENGL)
{
WRITE(p,"uniform samplerRECT samp0 : register(s0);\n");
WRITE(p, "#define samp0 samp9\n");
WRITE(p, "uniform sampler2DRect samp0;\n");
}
else if (ApiType & API_D3D9)
{
@ -91,18 +104,27 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
}
WRITE(p,"void main(\n");
if(ApiType != API_D3D11)
if (ApiType == API_OPENGL)
{
WRITE(p," out float4 ocol0 : COLOR0,\n");
WRITE(p, " out float4 ocol0;\n");
WRITE(p, " in float2 uv0;\n");
WRITE(p, "void main()\n");
}
else
{
WRITE(p," out float4 ocol0 : SV_Target,\n");
WRITE(p,"void main(\n");
if (ApiType != API_D3D11)
{
WRITE(p," out float4 ocol0 : COLOR0,\n");
}
else
{
WRITE(p," out float4 ocol0 : SV_Target,\n");
}
WRITE(p," in float2 uv0 : TEXCOORD0)\n");
}
WRITE(p," in float2 uv0 : TEXCOORD0)\n"
"{\n"
WRITE(p, "{\n"
" float2 sampleUv;\n"
" float2 uv1 = floor(uv0);\n");
@ -113,7 +135,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
WRITE(p, " float yl = floor(uv1.y / %f);\n", blkH);
WRITE(p, " float yb = yl * %f;\n", blkH);
WRITE(p, " float yoff = uv1.y - yb;\n");
WRITE(p, " float xp = uv1.x + (yoff * textureDims.x);\n");
WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n");
WRITE(p, " float xel = floor(xp / %f);\n", blkW);
WRITE(p, " float xb = floor(xel / %f);\n", blkH);
WRITE(p, " float xoff = xel - (xb * %f);\n", blkH);
@ -121,34 +143,37 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
WRITE(p, " sampleUv.x = xib + (xb * %f);\n", blkW);
WRITE(p, " sampleUv.y = yb + xoff;\n");
WRITE(p, " sampleUv = sampleUv * blkDims.xy;\n");
WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n");
if(ApiType == API_OPENGL)
WRITE(p," sampleUv.y = textureDims.y - sampleUv.y;\n");
if (ApiType == API_OPENGL)
WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n");
WRITE(p, " sampleUv = sampleUv + textureDims.zw;\n");
WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n");
if(ApiType != API_OPENGL)
if (ApiType != API_OPENGL)
{
WRITE(p, " sampleUv = sampleUv + float2(0.0f,1.0f);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv / blkDims.zw;\n");
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
}
// block dimensions : widthStride, heightStride
// texture dims : width, height, x offset, y offset
void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
{
WRITE(p, "uniform float4 blkDims : register(c%d);\n", C_COLORMATRIX);
WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1);
{
// [0] left, top, right, bottom of source rectangle within source texture
// [1] width and height of destination texture in pixels
// Two were merged for GLSL
WRITE(p, "uniform float4 " I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS));
float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
float blkH = (float)TexDecoder_GetBlockHeightInTexels(format);
// 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments
if(ApiType == API_OPENGL)
if (ApiType == API_OPENGL)
{
WRITE(p,"uniform samplerRECT samp0 : register(s0);\n");
WRITE(p, "#define samp0 samp9\n");
WRITE(p, "uniform sampler2DRect samp0;\n");
}
else if (ApiType & API_D3D9)
{
@ -160,26 +185,35 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
WRITE(p, "Texture2D Tex0 : register(t0);\n");
}
WRITE(p,"void main(\n");
if(ApiType != API_D3D11)
if (ApiType == API_OPENGL)
{
WRITE(p," out float4 ocol0 : COLOR0,\n");
WRITE(p, " out float4 ocol0;\n");
WRITE(p, " in float2 uv0;\n");
WRITE(p, "void main()\n");
}
else
{
WRITE(p," out float4 ocol0 : SV_Target,\n");
WRITE(p,"void main(\n");
if(ApiType != API_D3D11)
{
WRITE(p," out float4 ocol0 : COLOR0,\n");
}
else
{
WRITE(p," out float4 ocol0 : SV_Target,\n");
}
WRITE(p," in float2 uv0 : TEXCOORD0)\n");
}
WRITE(p," in float2 uv0 : TEXCOORD0)\n"
"{\n"
WRITE(p, "{\n"
" float2 sampleUv;\n"
" float2 uv1 = floor(uv0);\n");
WRITE(p, " float yl = floor(uv1.y / %f);\n", blkH);
WRITE(p, " float yb = yl * %f;\n", blkH);
WRITE(p, " float yoff = uv1.y - yb;\n");
WRITE(p, " float xp = uv1.x + (yoff * textureDims.x);\n");
WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n");
WRITE(p, " float xel = floor(xp / 2);\n");
WRITE(p, " float xb = floor(xel / %f);\n", blkH);
WRITE(p, " float xoff = xel - (xb * %f);\n", blkH);
@ -188,21 +222,20 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
WRITE(p, " float xl = floor(x2 / %f);\n", blkW);
WRITE(p, " float xib = x2 - (xl * %f);\n", blkW);
WRITE(p, " float halfxb = floor(xb / 2);\n");
WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW);
WRITE(p, " sampleUv.y = yb + xoff;\n");
WRITE(p, " sampleUv = sampleUv * blkDims.xy;\n");
WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n");
if(ApiType == API_OPENGL)
WRITE(p," sampleUv.y = textureDims.y - sampleUv.y;\n");
if (ApiType == API_OPENGL)
WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n");
WRITE(p, " sampleUv = sampleUv + textureDims.zw;\n");
WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n");
if(ApiType != API_OPENGL)
if (ApiType != API_OPENGL)
{
WRITE(p, " sampleUv = sampleUv + float2(0.0f,1.0f);\n");// still to determine the reason for this
WRITE(p, " sampleUv = sampleUv / blkDims.zw;\n");
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
}
@ -214,14 +247,14 @@ void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYP
else if (ApiType == API_D3D11)
texSampleOpName = "tex0.Sample";
else
texSampleOpName = "texRECT";
texSampleOpName = "texture2DRect";
// the increment of sampleUv.x is delayed, so we perform it here. see WriteIncrementSampleX.
const char* texSampleIncrementUnit;
if(ApiType != API_OPENGL)
texSampleIncrementUnit = "blkDims.x / blkDims.z";
if (ApiType != API_OPENGL)
texSampleIncrementUnit = I_COLORS"[0].x / " I_COLORS"[0].z";
else
texSampleIncrementUnit = "blkDims.x";
texSampleIncrementUnit = I_COLORS"[0].x";
WRITE(p, " %s = %s(samp0, sampleUv + float2(%d * (%s), 0)).%s;\n",
dest, texSampleOpName, s_incrementSampleXCount, texSampleIncrementUnit, colorComp);
@ -229,7 +262,7 @@ void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYP
void WriteColorToIntensity(char*& p, const char* src, const char* dest)
{
if(!IntensityConstantAdded)
if (!IntensityConstantAdded)
{
WRITE(p, " float4 IntensityConst = float4(0.257f,0.504f,0.098f,0.0625f);\n");
IntensityConstantAdded = true;
@ -263,7 +296,7 @@ void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* dest)
WRITE(p, " %s = floor(%s * %ff);\n", dest, src, result);
}
void WriteEncoderEnd(char* p)
void WriteEncoderEnd(char* p, API_TYPE ApiType)
{
WRITE(p, "}\n");
IntensityConstantAdded = false;
@ -272,65 +305,65 @@ void WriteEncoderEnd(char* p)
void WriteI8Encoder(char* p, API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_I8,ApiType);
WriteSwizzler(p, GX_TF_I8, ApiType);
WRITE(p, " float3 texSample;\n");
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "ocol0.b");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "ocol0.g");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "ocol0.r");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "ocol0.a");
WRITE(p, " ocol0.rgba += IntensityConst.aaaa;\n"); // see WriteColorToIntensity
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteI4Encoder(char* p, API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_I4,ApiType);
WriteSwizzler(p, GX_TF_I4, ApiType);
WRITE(p, " float3 texSample;\n");
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color0.b");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color1.b");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color0.g");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color1.g");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color0.r");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color1.r");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color0.a");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "texSample",ApiType);
WriteSampleColor(p, "rgb", "texSample", ApiType);
WriteColorToIntensity(p, "texSample", "color1.a");
WRITE(p, " color0.rgba += IntensityConst.aaaa;\n");
@ -340,51 +373,51 @@ void WriteI4Encoder(char* p, API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteIA8Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_IA8,ApiType);
WriteSwizzler(p, GX_TF_IA8, ApiType);
WRITE(p, " float4 texSample;\n");
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " ocol0.b = texSample.a;\n");
WriteColorToIntensity(p, "texSample", "ocol0.g");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " ocol0.r = texSample.a;\n");
WriteColorToIntensity(p, "texSample", "ocol0.a");
WRITE(p, " ocol0.ga += IntensityConst.aa;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteIA4Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_IA4,ApiType);
WriteSwizzler(p, GX_TF_IA4, ApiType);
WRITE(p, " float4 texSample;\n");
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " color0.b = texSample.a;\n");
WriteColorToIntensity(p, "texSample", "color1.b");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " color0.g = texSample.a;\n");
WriteColorToIntensity(p, "texSample", "color1.g");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " color0.r = texSample.a;\n");
WriteColorToIntensity(p, "texSample", "color1.r");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " color0.a = texSample.a;\n");
WriteColorToIntensity(p, "texSample", "color1.a");
@ -394,20 +427,19 @@ void WriteIA4Encoder(char* p,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteRGB565Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_RGB565,ApiType);
WriteSwizzler(p, GX_TF_RGB565, ApiType);
WriteSampleColor(p, "rgb", "float3 texSample0",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, "rgb", "float3 texSample1",ApiType);
WRITE(p, " float2 texRs = {texSample0.r, texSample1.r};\n");
WRITE(p, " float2 texGs = {texSample0.g, texSample1.g};\n");
WRITE(p, " float2 texBs = {texSample0.b, texSample1.b};\n");
WriteSampleColor(p, "rgb", "float3 texSample0", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgb", "float3 texSample1", ApiType);
WRITE(p, " float2 texRs = float2(texSample0.r, texSample1.r);\n");
WRITE(p, " float2 texGs = float2(texSample0.g, texSample1.g);\n");
WRITE(p, " float2 texBs = float2(texSample0.b, texSample1.b);\n");
WriteToBitDepth(p, 6, "texGs", "float2 gInt");
WRITE(p, " float2 gUpper = floor(gInt / 8.0f);\n");
@ -419,19 +451,19 @@ void WriteRGB565Encoder(char* p,API_TYPE ApiType)
WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0f;\n");
WRITE(p, " ocol0 = ocol0 / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_RGB5A3,ApiType);
WriteSwizzler(p, GX_TF_RGB5A3, ApiType);
WRITE(p, " float4 texSample;\n");
WRITE(p, " float color0;\n");
WRITE(p, " float gUpper;\n");
WRITE(p, " float gLower;\n");
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
// 0.8784 = 224 / 255 which is the maximum alpha value that can be represented in 3 bits
WRITE(p, "if(texSample.a > 0.878f) {\n");
@ -458,9 +490,9 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WRITE(p, "}\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, "if(texSample.a > 0.878f) {\n");
@ -486,38 +518,38 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType)
WRITE(p, "}\n");
WRITE(p, " ocol0 = ocol0 / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteRGBA4443Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_RGB5A3,ApiType);
WriteSwizzler(p, GX_TF_RGB5A3, ApiType);
WRITE(p, " float4 texSample;\n");
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WriteToBitDepth(p, 3, "texSample.a", "color0.b");
WriteToBitDepth(p, 4, "texSample.r", "color1.b");
WriteToBitDepth(p, 4, "texSample.g", "color0.g");
WriteToBitDepth(p, 4, "texSample.b", "color1.g");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WriteToBitDepth(p, 3, "texSample.a", "color0.r");
WriteToBitDepth(p, 4, "texSample.r", "color1.r");
WriteToBitDepth(p, 4, "texSample.g", "color0.a");
WriteToBitDepth(p, 4, "texSample.b", "color1.a");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
{
Write32BitSwizzler(p, GX_TF_RGBA8,ApiType);
Write32BitSwizzler(p, GX_TF_RGBA8, ApiType);
WRITE(p, " float cl1 = xb - (halfxb * 2);\n");
WRITE(p, " float cl0 = 1.0f - cl1;\n");
@ -526,15 +558,15 @@ void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " color0.b = texSample.a;\n");
WRITE(p, " color0.g = texSample.r;\n");
WRITE(p, " color1.b = texSample.g;\n");
WRITE(p, " color1.g = texSample.b;\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "rgba", "texSample",ApiType);
WriteSampleColor(p, "rgba", "texSample", ApiType);
WRITE(p, " color0.r = texSample.a;\n");
WRITE(p, " color0.a = texSample.r;\n");
WRITE(p, " color1.r = texSample.g;\n");
@ -542,86 +574,86 @@ void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
WRITE(p, " ocol0 = (cl0 * color0) + (cl1 * color1);\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteC4Encoder(char* p, const char* comp,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_R4,ApiType);
WriteSwizzler(p, GX_CTF_R4, ApiType);
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
WriteSampleColor(p, comp, "color0.b",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color0.b", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color1.b",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color1.b", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color0.g",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color0.g", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color1.g",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color1.g", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color0.r",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color0.r", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color1.r",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color1.r", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color0.a",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "color0.a", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "color1.a",ApiType);
WriteSampleColor(p, comp, "color1.a", ApiType);
WriteToBitDepth(p, 4, "color0", "color0");
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteC8Encoder(char* p, const char* comp,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_R8,ApiType);
WriteSwizzler(p, GX_CTF_R8, ApiType);
WriteSampleColor(p, comp, "ocol0.b",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "ocol0.b", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "ocol0.g",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "ocol0.g", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "ocol0.r",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "ocol0.r", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "ocol0.a",ApiType);
WriteSampleColor(p, comp, "ocol0.a", ApiType);
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteCC4Encoder(char* p, const char* comp,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_RA4,ApiType);
WriteSwizzler(p, GX_CTF_RA4, ApiType);
WRITE(p, " float2 texSample;\n");
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
WriteSampleColor(p, comp, "texSample",ApiType);
WriteSampleColor(p, comp, "texSample", ApiType);
WRITE(p, " color0.b = texSample.x;\n");
WRITE(p, " color1.b = texSample.y;\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "texSample",ApiType);
WriteSampleColor(p, comp, "texSample", ApiType);
WRITE(p, " color0.g = texSample.x;\n");
WRITE(p, " color1.g = texSample.y;\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "texSample",ApiType);
WriteSampleColor(p, comp, "texSample", ApiType);
WRITE(p, " color0.r = texSample.x;\n");
WRITE(p, " color1.r = texSample.y;\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "texSample",ApiType);
WriteSampleColor(p, comp, "texSample", ApiType);
WRITE(p, " color0.a = texSample.x;\n");
WRITE(p, " color1.a = texSample.y;\n");
@ -629,55 +661,55 @@ void WriteCC4Encoder(char* p, const char* comp,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteCC8Encoder(char* p, const char* comp, API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_RA8,ApiType);
WriteSwizzler(p, GX_CTF_RA8, ApiType);
WriteSampleColor(p, comp, "ocol0.bg",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, comp, "ocol0.bg", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, comp, "ocol0.ra",ApiType);
WriteSampleColor(p, comp, "ocol0.ra", ApiType);
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteZ8Encoder(char* p, const char* multiplier,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_Z8M,ApiType);
WriteSwizzler(p, GX_CTF_Z8M, ApiType);
WRITE(p, " float depth;\n");
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier);
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier);
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier);
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier);
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteZ16Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_Z16,ApiType);
WriteSwizzler(p, GX_TF_Z16, ApiType);
WRITE(p, " float depth;\n");
WRITE(p, " float3 expanded;\n");
// byte order is reversed
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
@ -687,9 +719,9 @@ void WriteZ16Encoder(char* p,API_TYPE ApiType)
WRITE(p, " ocol0.b = expanded.g / 255;\n");
WRITE(p, " ocol0.g = expanded.r / 255;\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
@ -699,19 +731,19 @@ void WriteZ16Encoder(char* p,API_TYPE ApiType)
WRITE(p, " ocol0.r = expanded.g / 255;\n");
WRITE(p, " ocol0.a = expanded.r / 255;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteZ16LEncoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_CTF_Z16L,ApiType);
WriteSwizzler(p, GX_CTF_Z16L, ApiType);
WRITE(p, " float depth;\n");
WRITE(p, " float3 expanded;\n");
// byte order is reversed
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
@ -723,9 +755,9 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType)
WRITE(p, " ocol0.b = expanded.b / 255;\n");
WRITE(p, " ocol0.g = expanded.g / 255;\n");
WriteIncrementSampleX(p,ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth",ApiType);
WriteSampleColor(p, "b", "depth", ApiType);
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256 * 256));\n");
@ -737,12 +769,12 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType)
WRITE(p, " ocol0.r = expanded.b;\n");
WRITE(p, " ocol0.a = expanded.g;\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
void WriteZ24Encoder(char* p, API_TYPE ApiType)
{
Write32BitSwizzler(p, GX_TF_Z24X8,ApiType);
Write32BitSwizzler(p, GX_TF_Z24X8, ApiType);
WRITE(p, " float cl = xb - (halfxb * 2);\n");
@ -751,19 +783,19 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
WRITE(p, " float3 expanded0;\n");
WRITE(p, " float3 expanded1;\n");
WriteSampleColor(p, "b", "depth0",ApiType);
WriteIncrementSampleX(p,ApiType);
WriteSampleColor(p, "b", "depth1",ApiType);
WriteSampleColor(p, "b", "depth0", ApiType);
WriteIncrementSampleX(p, ApiType);
WriteSampleColor(p, "b", "depth1", ApiType);
for (int i = 0; i < 2; i++)
{
WRITE(p, " depth%i *= 16777215.0f;\n", i);
WRITE(p, " depth%i *= 16777215.0f;\n", i);
WRITE(p, " expanded%i.r = floor(depth%i / (256 * 256));\n", i, i);
WRITE(p, " depth%i -= expanded%i.r * 256 * 256;\n", i, i);
WRITE(p, " expanded%i.g = floor(depth%i / 256);\n", i, i);
WRITE(p, " depth%i -= expanded%i.g * 256;\n", i, i);
WRITE(p, " expanded%i.b = depth%i;\n", i, i);
WRITE(p, " expanded%i.r = floor(depth%i / (256 * 256));\n", i, i);
WRITE(p, " depth%i -= expanded%i.r * 256 * 256;\n", i, i);
WRITE(p, " expanded%i.g = floor(depth%i / 256);\n", i, i);
WRITE(p, " depth%i -= expanded%i.g * 256;\n", i, i);
WRITE(p, " expanded%i.b = depth%i;\n", i, i);
}
WRITE(p, " if(cl > 0.5f) {\n");
@ -780,7 +812,7 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
WRITE(p, " ocol0.a = expanded1.r / 255;\n");
WRITE(p, " }\n");
WriteEncoderEnd(p);
WriteEncoderEnd(p, ApiType);
}
const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
@ -790,76 +822,76 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
char *p = text;
switch(format)
switch (format)
{
case GX_TF_I4:
WriteI4Encoder(p,ApiType);
WriteI4Encoder(p, ApiType);
break;
case GX_TF_I8:
WriteI8Encoder(p,ApiType);
WriteI8Encoder(p, ApiType);
break;
case GX_TF_IA4:
WriteIA4Encoder(p,ApiType);
WriteIA4Encoder(p, ApiType);
break;
case GX_TF_IA8:
WriteIA8Encoder(p,ApiType);
WriteIA8Encoder(p, ApiType);
break;
case GX_TF_RGB565:
WriteRGB565Encoder(p,ApiType);
WriteRGB565Encoder(p, ApiType);
break;
case GX_TF_RGB5A3:
WriteRGB5A3Encoder(p,ApiType);
WriteRGB5A3Encoder(p, ApiType);
break;
case GX_TF_RGBA8:
WriteRGBA8Encoder(p,ApiType);
WriteRGBA8Encoder(p, ApiType);
break;
case GX_CTF_R4:
WriteC4Encoder(p, "r",ApiType);
WriteC4Encoder(p, "r", ApiType);
break;
case GX_CTF_RA4:
WriteCC4Encoder(p, "ar",ApiType);
WriteCC4Encoder(p, "ar", ApiType);
break;
case GX_CTF_RA8:
WriteCC8Encoder(p, "ar",ApiType);
WriteCC8Encoder(p, "ar", ApiType);
break;
case GX_CTF_A8:
WriteC8Encoder(p, "a",ApiType);
WriteC8Encoder(p, "a", ApiType);
break;
case GX_CTF_R8:
WriteC8Encoder(p, "r",ApiType);
WriteC8Encoder(p, "r", ApiType);
break;
case GX_CTF_G8:
WriteC8Encoder(p, "g",ApiType);
WriteC8Encoder(p, "g", ApiType);
break;
case GX_CTF_B8:
WriteC8Encoder(p, "b",ApiType);
WriteC8Encoder(p, "b", ApiType);
break;
case GX_CTF_RG8:
WriteCC8Encoder(p, "rg",ApiType);
WriteCC8Encoder(p, "rg", ApiType);
break;
case GX_CTF_GB8:
WriteCC8Encoder(p, "gb",ApiType);
WriteCC8Encoder(p, "gb", ApiType);
break;
case GX_TF_Z8:
WriteC8Encoder(p, "b",ApiType);
WriteC8Encoder(p, "b", ApiType);
break;
case GX_TF_Z16:
WriteZ16Encoder(p,ApiType);
WriteZ16Encoder(p, ApiType);
break;
case GX_TF_Z24X8:
WriteZ24Encoder(p,ApiType);
WriteZ24Encoder(p, ApiType);
break;
case GX_CTF_Z4:
WriteC4Encoder(p, "b",ApiType);
WriteC4Encoder(p, "b", ApiType);
break;
case GX_CTF_Z8M:
WriteZ8Encoder(p, "256.0f",ApiType);
WriteZ8Encoder(p, "256.0f", ApiType);
break;
case GX_CTF_Z8L:
WriteZ8Encoder(p, "65536.0f" ,ApiType);
WriteZ8Encoder(p, "65536.0f" , ApiType);
break;
case GX_CTF_Z16L:
WriteZ16LEncoder(p,ApiType);
WriteZ16LEncoder(p, ApiType);
break;
default:
PanicAlert("Unknown texture copy format: 0x%x\n", format);

View file

@ -44,8 +44,10 @@
#include "XFMemory.h"
extern float GC_ALIGNED16(g_fProjectionMatrix[16]);
#ifndef _M_GENERIC
#ifndef __APPLE__
#define USE_JIT
#endif
#endif
#define COMPILED_CODE_SIZE 4096

View file

@ -131,38 +131,43 @@ static char text[16384];
#define WRITE p+=sprintf
char* GenerateVSOutputStruct(char* p, u32 components, API_TYPE api_type)
char* GenerateVSOutputStruct(char* p, u32 components, API_TYPE ApiType)
{
// GLSL makes this ugly
// TODO: Make pretty
WRITE(p, "struct VS_OUTPUT {\n");
WRITE(p, " float4 pos : POSITION;\n");
WRITE(p, " float4 colors_0 : COLOR0;\n");
WRITE(p, " float4 colors_1 : COLOR1;\n");
WRITE(p, " float4 pos %s POSITION;\n", ApiType == API_OPENGL ? ";//" : ":");
WRITE(p, " float4 colors_0 %s COLOR0;\n", ApiType == API_OPENGL ? ";//" : ":");
WRITE(p, " float4 colors_1 %s COLOR1;\n", ApiType == API_OPENGL ? ";//" : ":");
if (xfregs.numTexGen.numTexGens < 7) {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " float3 tex%d : TEXCOORD%d;\n", i, i);
WRITE(p, " float4 clipPos : TEXCOORD%d;\n", xfregs.numTexGen.numTexGens);
WRITE(p, " float3 tex%d %s TEXCOORD%d;\n", i, ApiType == API_OPENGL ? ";//" : ":", i);
WRITE(p, " float4 clipPos %s TEXCOORD%d;\n", ApiType == API_OPENGL ? ";//" : ":", xfregs.numTexGen.numTexGens);
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, " float4 Normal : TEXCOORD%d;\n", xfregs.numTexGen.numTexGens + 1);
WRITE(p, " float4 Normal %s TEXCOORD%d;\n", ApiType == API_OPENGL ? ";//" : ":", xfregs.numTexGen.numTexGens + 1);
} else {
// clip position is in w of first 4 texcoords
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
for (int i = 0; i < 8; ++i)
WRITE(p, " float4 tex%d : TEXCOORD%d;\n", i, i);
WRITE(p, " float4 tex%d %s TEXCOORD%d;\n", i, ApiType == API_OPENGL? ";//" : ":", i);
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " float%d tex%d : TEXCOORD%d;\n", i < 4 ? 4 : 3 , i, i);
WRITE(p, " float%d tex%d %s TEXCOORD%d;\n", i < 4 ? 4 : 3 , i, ApiType == API_OPENGL ? ";//" : ":", i);
}
}
}
WRITE(p, "};\n");
return p;
}
const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
extern const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num);
extern const char *WriteLocation(API_TYPE ApiType);
const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
{
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
text[sizeof(text) - 1] = 0x7C; // canary
@ -170,7 +175,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens);
_assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans);
bool is_d3d = (api_type & API_D3D9 || api_type == API_D3D11);
bool is_d3d = (ApiType & API_D3D9 || ApiType == API_D3D11);
u32 lightMask = 0;
if (xfregs.numChan.numColorChans > 0)
lightMask |= xfregs.color[0].GetFullLightMask() | xfregs.alpha[0].GetFullLightMask();
@ -179,91 +184,134 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
char *p = text;
WRITE(p, "//Vertex Shader: comp:%x, \n", components);
WRITE(p, "typedef struct { float4 T0, T1, T2; float4 N0, N1, N2; } s_" I_POSNORMALMATRIX";\n"
"typedef struct { float4 t; } FLT4;\n"
"typedef struct { FLT4 T[24]; } s_" I_TEXMATRICES";\n"
"typedef struct { FLT4 T[64]; } s_" I_TRANSFORMMATRICES";\n"
"typedef struct { FLT4 T[32]; } s_" I_NORMALMATRICES";\n"
"typedef struct { FLT4 T[64]; } s_" I_POSTTRANSFORMMATRICES";\n"
"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n"
"typedef struct { Light lights[8]; } s_" I_LIGHTS";\n"
"typedef struct { float4 C0, C1, C2, C3; } s_" I_MATERIALS";\n"
"typedef struct { float4 T0, T1, T2, T3; } s_" I_PROJECTION";\n"
);
p = GenerateVSOutputStruct(p, components, api_type);
// uniforms
WRITE(p, "uniform s_" I_TRANSFORMMATRICES" " I_TRANSFORMMATRICES" : register(c%d);\n", C_TRANSFORMMATRICES);
WRITE(p, "uniform s_" I_TEXMATRICES" " I_TEXMATRICES" : register(c%d);\n", C_TEXMATRICES); // also using tex matrices
WRITE(p, "uniform s_" I_NORMALMATRICES" " I_NORMALMATRICES" : register(c%d);\n", C_NORMALMATRICES);
WRITE(p, "uniform s_" I_POSNORMALMATRIX" " I_POSNORMALMATRIX" : register(c%d);\n", C_POSNORMALMATRIX);
WRITE(p, "uniform s_" I_POSTTRANSFORMMATRICES" " I_POSTTRANSFORMMATRICES" : register(c%d);\n", C_POSTTRANSFORMMATRICES);
WRITE(p, "uniform s_" I_LIGHTS" " I_LIGHTS" : register(c%d);\n", C_LIGHTS);
WRITE(p, "uniform s_" I_MATERIALS" " I_MATERIALS" : register(c%d);\n", C_MATERIALS);
WRITE(p, "uniform s_" I_PROJECTION" " I_PROJECTION" : register(c%d);\n", C_PROJECTION);
WRITE(p, "uniform float4 " I_DEPTHPARAMS" : register(c%d);\n", C_DEPTHPARAMS);
WRITE(p, "VS_OUTPUT main(\n");
// inputs
if (components & VB_HAS_NRM0)
WRITE(p, " float3 rawnorm0 : NORMAL0,\n");
if (components & VB_HAS_NRM1) {
if (is_d3d)
WRITE(p, " float3 rawnorm1 : NORMAL1,\n");
else
WRITE(p, " float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB);
}
if (components & VB_HAS_NRM2) {
if (is_d3d)
WRITE(p, " float3 rawnorm2 : NORMAL2,\n");
else
WRITE(p, " float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB);
}
if (components & VB_HAS_COL0)
WRITE(p, " float4 color0 : COLOR0,\n");
if (components & VB_HAS_COL1)
WRITE(p, " float4 color1 : COLOR1,\n");
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
WRITE(p, " float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i);
}
if (components & VB_HAS_POSMTXIDX) {
if (is_d3d)
// uniforms
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "layout(std140) uniform VSBlock {\n");
WRITE(p, "%sfloat4 " I_POSNORMALMATRIX"[6] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX));
WRITE(p, "%sfloat4 " I_PROJECTION"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PROJECTION));
WRITE(p, "%sfloat4 " I_MATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_MATERIALS));
WRITE(p, "%sfloat4 " I_LIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_LIGHTS));
WRITE(p, "%sfloat4 " I_TEXMATRICES"[24] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices
WRITE(p, "%sfloat4 " I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType),WriteRegister(ApiType, "c", C_TRANSFORMMATRICES));
WRITE(p, "%sfloat4 " I_NORMALMATRICES"[32] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES));
WRITE(p, "%sfloat4 " I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES));
WRITE(p, "%sfloat4 " I_DEPTHPARAMS" %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS));
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "};\n");
p = GenerateVSOutputStruct(p, components, ApiType);
if(ApiType == API_OPENGL)
{
WRITE(p, "ATTRIN float4 rawpos; // ATTR%d,\n", SHADER_POSITION_ATTRIB);
if (components & VB_HAS_POSMTXIDX)
WRITE(p, "ATTRIN int posmtx; // ATTR%d,\n", SHADER_POSMTX_ATTRIB);
if (components & VB_HAS_NRM0)
WRITE(p, "ATTRIN float3 rawnorm0; // ATTR%d,\n", SHADER_NORM0_ATTRIB);
if (components & VB_HAS_NRM1)
WRITE(p, "ATTRIN float3 rawnorm1; // ATTR%d,\n", SHADER_NORM1_ATTRIB);
if (components & VB_HAS_NRM2)
WRITE(p, "ATTRIN float3 rawnorm2; // ATTR%d,\n", SHADER_NORM2_ATTRIB);
if (components & VB_HAS_COL0)
WRITE(p, "ATTRIN float4 color0; // ATTR%d,\n", SHADER_COLOR0_ATTRIB);
if (components & VB_HAS_COL1)
WRITE(p, "ATTRIN float4 color1; // ATTR%d,\n", SHADER_COLOR1_ATTRIB);
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
WRITE(p, "ATTRIN float%d tex%d; // ATTR%d,\n", hastexmtx ? 3 : 2, i, SHADER_TEXTURE0_ATTRIB + i);
}
// Let's set up attributes
if (xfregs.numTexGen.numTexGens < 7)
{
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
for (int i = 0; i < 8; ++i)
WRITE(p, "VARYOUT float3 uv%d_2;\n", i);
WRITE(p, "VARYOUT float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, "VARYOUT float4 Normal_2;\n");
}
else
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
{
// wpos is in w of first 4 texcoords
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
for (int i = 0; i < 8; ++i)
WRITE(p, "VARYOUT float4 uv%d_2;\n", i);
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, "VARYOUT float%d uv%d_2;\n", i < 4 ? 4 : 3 , i);
}
}
WRITE(p, "VARYOUT float4 colors_02;\n");
WRITE(p, "VARYOUT float4 colors_12;\n");
WRITE(p, "void main()\n{\n");
}
else
{
WRITE(p, "VS_OUTPUT main(\n");
// inputs
if (components & VB_HAS_NRM0)
WRITE(p, " float3 rawnorm0 : NORMAL0,\n");
if (components & VB_HAS_NRM1) {
if (is_d3d)
WRITE(p, " float3 rawnorm1 : NORMAL1,\n");
else
WRITE(p, " float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB);
}
if (components & VB_HAS_NRM2) {
if (is_d3d)
WRITE(p, " float3 rawnorm2 : NORMAL2,\n");
else
WRITE(p, " float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB);
}
if (components & VB_HAS_COL0)
WRITE(p, " float4 color0 : COLOR0,\n");
if (components & VB_HAS_COL1)
WRITE(p, " float4 color1 : COLOR1,\n");
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
WRITE(p, " float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i);
}
if (components & VB_HAS_POSMTXIDX) {
if (is_d3d)
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
else
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
}
WRITE(p, " float4 rawpos : POSITION) {\n");
}
WRITE(p, " float4 rawpos : POSITION) {\n");
WRITE(p, "VS_OUTPUT o;\n");
// transforms
if (components & VB_HAS_POSMTXIDX)
{
if (api_type & API_D3D9)
if (ApiType & API_D3D9)
{
WRITE(p, "int4 indices = D3DCOLORtoUBYTE4(blend_indices);\n");
WRITE(p, "int posmtx = indices.x;\n");
}
else if (api_type == API_D3D11)
else if (ApiType == API_D3D11)
{
WRITE(p, "int posmtx = blend_indices.x * 255.0f;\n");
}
else
{
WRITE(p, "int posmtx = fposmtx;\n");
}
WRITE(p, "float4 pos = float4(dot(" I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot(" I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot(" I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos), 1);\n");
WRITE(p, "float4 pos = float4(dot(" I_TRANSFORMMATRICES"[posmtx], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+1], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+2], rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
WRITE(p, "float3 N0 = " I_NORMALMATRICES".T[normidx].t.xyz, N1 = " I_NORMALMATRICES".T[normidx+1].t.xyz, N2 = " I_NORMALMATRICES".T[normidx+2].t.xyz;\n");
WRITE(p, "float3 N0 = " I_NORMALMATRICES"[normidx].xyz, N1 = " I_NORMALMATRICES"[normidx+1].xyz, N2 = " I_NORMALMATRICES"[normidx+2].xyz;\n");
}
if (components & VB_HAS_NRM0)
@ -275,13 +323,13 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
}
else
{
WRITE(p, "float4 pos = float4(dot(" I_POSNORMALMATRIX".T0, rawpos), dot(" I_POSNORMALMATRIX".T1, rawpos), dot(" I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n");
WRITE(p, "float4 pos = float4(dot(" I_POSNORMALMATRIX"[0], rawpos), dot(" I_POSNORMALMATRIX"[1], rawpos), dot(" I_POSNORMALMATRIX"[2], rawpos), 1.0f);\n");
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot(" I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot(" I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot(" I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n");
WRITE(p, "float3 _norm0 = normalize(float3(dot(" I_POSNORMALMATRIX"[3].xyz, rawnorm0), dot(" I_POSNORMALMATRIX"[4].xyz, rawnorm0), dot(" I_POSNORMALMATRIX"[5].xyz, rawnorm0)));\n");
if (components & VB_HAS_NRM1)
WRITE(p, "float3 _norm1 = float3(dot(" I_POSNORMALMATRIX".N0.xyz, rawnorm1), dot(" I_POSNORMALMATRIX".N1.xyz, rawnorm1), dot(" I_POSNORMALMATRIX".N2.xyz, rawnorm1));\n");
WRITE(p, "float3 _norm1 = float3(dot(" I_POSNORMALMATRIX"[3].xyz, rawnorm1), dot(" I_POSNORMALMATRIX"[4].xyz, rawnorm1), dot(" I_POSNORMALMATRIX"[5].xyz, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot(" I_POSNORMALMATRIX".N0.xyz, rawnorm2), dot(" I_POSNORMALMATRIX".N1.xyz, rawnorm2), dot(" I_POSNORMALMATRIX".N2.xyz, rawnorm2));\n");
WRITE(p, "float3 _norm2 = float3(dot(" I_POSNORMALMATRIX"[3].xyz, rawnorm2), dot(" I_POSNORMALMATRIX"[4].xyz, rawnorm2), dot(" I_POSNORMALMATRIX"[5].xyz, rawnorm2));\n");
}
if (!(components & VB_HAS_NRM0))
@ -289,13 +337,13 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "o.pos = float4(dot(" I_PROJECTION".T0, pos), dot(" I_PROJECTION".T1, pos), dot(" I_PROJECTION".T2, pos), dot(" I_PROJECTION".T3, pos));\n");
WRITE(p, "o.pos = float4(dot(" I_PROJECTION"[0], pos), dot(" I_PROJECTION"[1], pos), dot(" I_PROJECTION"[2], pos), dot(" I_PROJECTION"[3], pos));\n");
WRITE(p, "float4 mat, lacc;\n"
"float3 ldir, h;\n"
"float dist, dist2, attn;\n");
if(xfregs.numChan.numColorChans == 0)
if (xfregs.numChan.numColorChans == 0)
{
if (components & VB_HAS_COL0)
WRITE(p, "o.colors_0 = color0;\n");
@ -306,7 +354,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
// TODO: This probably isn't necessary if pixel lighting is enabled.
p = GenerateLightingShader(p, components, I_MATERIALS, I_LIGHTS, "color", "o.colors_");
if(xfregs.numChan.numColorChans < 2)
if (xfregs.numChan.numColorChans < 2)
{
if (components & VB_HAS_COL1)
WRITE(p, "o.colors_1 = color1;\n");
@ -368,7 +416,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
if (components & (VB_HAS_NRM1|VB_HAS_NRM2)) {
// transform the light dir into tangent space
WRITE(p, "ldir = normalize(" I_LIGHTS".lights[%d].pos.xyz - pos.xyz);\n", texinfo.embosslightshift);
WRITE(p, "ldir = normalize(" I_LIGHTS"[%d + 3].xyz - pos.xyz);\n", texinfo.embosslightshift);
WRITE(p, "o.tex%d.xyz = o.tex%d.xyz + float3(dot(ldir, _norm1), dot(ldir, _norm2), 0.0f);\n", i, texinfo.embosssourceshift);
}
else
@ -388,18 +436,20 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
break;
case XF_TEXGEN_REGULAR:
default:
if (components & (VB_HAS_TEXMTXIDX0<<i)) {
if (components & (VB_HAS_TEXMTXIDX0<<i))
{
WRITE(p, "int tmp = int(tex%d.z);\n", i);
if (texinfo.projection == XF_TEXPROJ_STQ)
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, " I_TRANSFORMMATRICES".T[tex%d.z+1].t), dot(coord, " I_TRANSFORMMATRICES".T[tex%d.z+2].t));\n", i, i, i, i);
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TRANSFORMMATRICES"[tmp]), dot(coord, " I_TRANSFORMMATRICES"[tmp+1]), dot(coord, " I_TRANSFORMMATRICES"[tmp+2]));\n", i);
else {
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, " I_TRANSFORMMATRICES".T[tex%d.z+1].t), 1);\n", i, i, i);
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TRANSFORMMATRICES"[tmp]), dot(coord, " I_TRANSFORMMATRICES"[tmp+1]), 1);\n", i);
}
}
else {
if (texinfo.projection == XF_TEXPROJ_STQ)
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TEXMATRICES".T[%d].t), dot(coord, " I_TEXMATRICES".T[%d].t), dot(coord, " I_TEXMATRICES".T[%d].t));\n", i, 3*i, 3*i+1, 3*i+2);
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TEXMATRICES"[%d]), dot(coord, " I_TEXMATRICES"[%d]), dot(coord, " I_TEXMATRICES"[%d]));\n", i, 3*i, 3*i+1, 3*i+2);
else
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TEXMATRICES".T[%d].t), dot(coord, " I_TEXMATRICES".T[%d].t), 1);\n", i, 3*i, 3*i+1);
WRITE(p, "o.tex%d.xyz = float3(dot(coord, " I_TEXMATRICES"[%d]), dot(coord, " I_TEXMATRICES"[%d]), 1);\n", i, 3*i, 3*i+1);
}
break;
}
@ -408,9 +458,9 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
const PostMtxInfo& postInfo = xfregs.postMtxInfo[i];
int postidx = postInfo.index;
WRITE(p, "float4 P0 = " I_POSTTRANSFORMMATRICES".T[%d].t;\n"
"float4 P1 = " I_POSTTRANSFORMMATRICES".T[%d].t;\n"
"float4 P2 = " I_POSTTRANSFORMMATRICES".T[%d].t;\n",
WRITE(p, "float4 P0 = " I_POSTTRANSFORMMATRICES"[%d];\n"
"float4 P1 = " I_POSTTRANSFORMMATRICES"[%d];\n"
"float4 P2 = " I_POSTTRANSFORMMATRICES"[%d];\n",
postidx&0x3f, (postidx+1)&0x3f, (postidx+2)&0x3f);
if (texGenSpecialCase) {
@ -494,15 +544,49 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
//seems to get rather complicated
}
if (api_type & API_D3D9)
if (ApiType & API_D3D9)
{
// D3D9 is addressing pixel centers instead of pixel boundaries in clip space.
// Thus we need to offset the final position by half a pixel
WRITE(p, "o.pos = o.pos + float4(" I_DEPTHPARAMS".z, " I_DEPTHPARAMS".w, 0.f, 0.f);\n");
}
WRITE(p, "return o;\n}\n");
if(ApiType == API_OPENGL)
{
// Bit ugly here
// TODO: Make pretty
// Will look better when we bind uniforms in GLSL 1.3
// clipPos/w needs to be done in pixel shader, not here
if (xfregs.numTexGen.numTexGens < 7) {
for (unsigned int i = 0; i < 8; ++i)
if(i < xfregs.numTexGen.numTexGens)
WRITE(p, " uv%d_2.xyz = o.tex%d;\n", i, i);
else
WRITE(p, " uv%d_2.xyz = float3(0.0f, 0.0f, 0.0f);\n", i);
WRITE(p, " clipPos_2 = o.clipPos;\n");
if(g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
WRITE(p, " Normal_2 = o.Normal;\n");
} else {
// clip position is in w of first 4 texcoords
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
for (int i = 0; i < 8; ++i)
WRITE(p, " uv%d_2 = o.tex%d;\n", i, i);
}
else
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
WRITE(p, " uv%d_2%s = o.tex%d;\n", i, i < 4 ? ".xyzw" : ".xyz" , i);
}
}
WRITE(p, "colors_02 = o.colors_0;\n");
WRITE(p, "colors_12 = o.colors_1;\n");
WRITE(p, "gl_Position = o.pos;\n");
WRITE(p, "}\n");
}
else
WRITE(p, "return o;\n}\n");
if (text[sizeof(text) - 1] != 0x7C)
PanicAlert("VertexShader generator - buffer too small, canary has been eaten!");

View file

@ -21,9 +21,24 @@
#include "XFMemory.h"
#include "VideoCommon.h"
#define SHADER_POSMTX_ATTRIB 1
#define SHADER_NORM1_ATTRIB 6
#define SHADER_NORM2_ATTRIB 7
// TODO should be reordered
#define SHADER_POSITION_ATTRIB 0
#define SHADER_POSMTX_ATTRIB 1
#define SHADER_NORM0_ATTRIB 2
#define SHADER_NORM1_ATTRIB 3
#define SHADER_NORM2_ATTRIB 4
#define SHADER_COLOR0_ATTRIB 5
#define SHADER_COLOR1_ATTRIB 6
#define SHADER_TEXTURE0_ATTRIB 8
#define SHADER_TEXTURE1_ATTRIB 9
#define SHADER_TEXTURE2_ATTRIB 10
#define SHADER_TEXTURE3_ATTRIB 11
#define SHADER_TEXTURE4_ATTRIB 12
#define SHADER_TEXTURE5_ATTRIB 13
#define SHADER_TEXTURE6_ATTRIB 14
#define SHADER_TEXTURE7_ATTRIB 15
// shader variables
@ -46,8 +61,17 @@
#define C_NORMALMATRICES (C_TRANSFORMMATRICES + 64)
#define C_POSTTRANSFORMMATRICES (C_NORMALMATRICES + 32)
#define C_DEPTHPARAMS (C_POSTTRANSFORMMATRICES + 64)
#define C_VENVCONST_END (C_DEPTHPARAMS + 4)
#define C_VENVCONST_END (C_DEPTHPARAMS + 1)
const s_svar VSVar_Loc[] = { {I_POSNORMALMATRIX, C_POSNORMALMATRIX, 6 },
{I_PROJECTION , C_PROJECTION, 4 },
{I_MATERIALS, C_MATERIALS, 4 },
{I_LIGHTS, C_LIGHTS, 40 },
{I_TEXMATRICES, C_TEXMATRICES, 24 },
{I_TRANSFORMMATRICES , C_TRANSFORMMATRICES, 64 },
{I_NORMALMATRICES , C_NORMALMATRICES, 32 },
{I_POSTTRANSFORMMATRICES, C_POSTTRANSFORMMATRICES, 64 },
{I_DEPTHPARAMS, C_DEPTHPARAMS, 1 },
};
template<bool safe>
class _VERTEXSHADERUID
{

View file

@ -194,6 +194,8 @@ void VertexShaderManager::Dirty()
// TODO: A cleaner way to control the matricies without making a mess in the parameters field
void VertexShaderManager::SetConstants()
{
if (g_ActiveConfig.backend_info.APIType == API_OPENGL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO)
Dirty();
if (nTransformMatricesChanged[0] >= 0)
{
int startn = nTransformMatricesChanged[0] / 4;

View file

@ -102,8 +102,7 @@ typedef enum
API_D3D9_SM20 = 4,
API_D3D9 = 6,
API_D3D11 = 8,
API_GLSL = 16,
API_NONE = 32
API_NONE = 16
} API_TYPE;
inline u32 RGBA8ToRGBA6ToRGBA8(u32 src)
@ -149,5 +148,11 @@ inline unsigned int GetPow2(unsigned int val)
++ret;
return ret;
}
struct s_svar
{
const char *name;
const unsigned int reg;
const unsigned int size;
};
#endif // _VIDEOCOMMON_H

View file

@ -76,6 +76,7 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Settings", "AnaglyphStereoSeparation", &iAnaglyphStereoSeparation, 200);
iniFile.Get("Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle, 0);
iniFile.Get("Settings", "EnablePixelLighting", &bEnablePixelLighting, 0);
iniFile.Get("Settings", "HackedBufferUpload", &bHackedBufferUpload, 0);
iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native
@ -134,6 +135,7 @@ void VideoConfig::GameIniLoad(const char *ini_file)
iniFile.GetIfExists("Video_Settings", "AnaglyphStereoSeparation", &iAnaglyphStereoSeparation);
iniFile.GetIfExists("Video_Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle);
iniFile.GetIfExists("Video_Settings", "EnablePixelLighting", &bEnablePixelLighting);
iniFile.GetIfExists("Video_Settings", "HackedBufferUpload", &bHackedBufferUpload);
iniFile.GetIfExists("Video_Settings", "MSAA", &iMultisampleMode);
iniFile.GetIfExists("Video_Settings", "EFBScale", &iEFBScale); // integral
iniFile.GetIfExists("Video_Settings", "DstAlphaPass", &bDstAlphaPass);
@ -172,6 +174,7 @@ void VideoConfig::VerifyValidity()
if (!backend_info.bSupports3DVision) b3DVision = false;
if (!backend_info.bSupportsFormatReinterpretation) bEFBEmulateFormatChanges = false;
if (!backend_info.bSupportsPixelLighting) bEnablePixelLighting = false;
if (backend_info.APIType != API_OPENGL) backend_info.bSupportsGLSLUBO = false;
}
void VideoConfig::Save(const char *ini_file)
@ -202,7 +205,7 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Settings", "AnaglyphStereoSeparation", iAnaglyphStereoSeparation);
iniFile.Set("Settings", "AnaglyphFocalAngle", iAnaglyphFocalAngle);
iniFile.Set("Settings", "EnablePixelLighting", bEnablePixelLighting);
iniFile.Set("Settings", "HackedBufferUpload", bHackedBufferUpload);
iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions);
iniFile.Set("Settings", "MSAA", iMultisampleMode);

View file

@ -133,6 +133,7 @@ struct VideoConfig
bool bZTPSpeedHack; // The Legend of Zelda: Twilight Princess
bool bUseBBox;
bool bEnablePixelLighting;
bool bHackedBufferUpload;
int iLog; // CONF_ bits
int iSaveTargetId; // TODO: Should be dropped
@ -162,6 +163,12 @@ struct VideoConfig
bool bSupportsDualSourceBlend; // only supported by D3D11 and OpenGL
bool bSupportsFormatReinterpretation;
bool bSupportsPixelLighting;
bool bSupportsGLSLUBO;
bool bSupportsGLSLCache;
bool bSupportsGLPinnedMemory;
bool bSupportsGLSync;
bool bSupportsGLBaseVertex;
} backend_info;
// Utility

View file

@ -208,6 +208,8 @@ void XFBSource::DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
void XFBSource::CopyEFB(float Gamma)
{
g_renderer->ResetAPIState(); // reset any game specific settings
// Copy EFB data to XFB and restore render target again
const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)texWidth, (float)texHeight);
@ -222,6 +224,8 @@ void XFBSource::CopyEFB(float Gamma)
D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(),
FramebufferManager::GetEFBDepthTexture()->GetDSV());
g_renderer->RestoreAPIState();
}
} // namespace DX11

Some files were not shown because too many files have changed in this diff Show more