Share scale_x and scale_y between GL and GL4 renderers. Don't use

ShaderUniforms in OSD.
This commit is contained in:
Flyinghead 2018-10-04 12:03:00 +02:00
parent ef5e8593fa
commit 1dfc9902b7
4 changed files with 23 additions and 27 deletions

View File

@ -2,8 +2,6 @@
#include "rend/gles/gles.h"
#include <map>
extern float gl4_scale_x, gl4_scale_y;
void gl4DrawStrips(GLuint output_fbo);
struct gl4PipelineShader

View File

@ -114,10 +114,10 @@ static s32 SetTileClip(u32 val, bool set)
{
if (!pvrrc.isRTT)
{
csx /= gl4_scale_x;
csy /= gl4_scale_y;
cex /= gl4_scale_x;
cey /= gl4_scale_y;
csx /= scale_x;
csy /= scale_y;
cex /= scale_x;
cey /= scale_y;
float t = cey;
cey = 480 - csy;
csy = 480 - t;

View File

@ -8,8 +8,6 @@
#include "rend/rend.h"
#include "hw/pvr/Renderer_if.h"
float gl4_scale_x, gl4_scale_y;
//Fragment and vertex shaders code
static const char* VertexShaderSource =
@ -827,15 +825,15 @@ static bool RenderFrame()
dc_height = pvrrc.fb_Y_CLIP.max - pvrrc.fb_Y_CLIP.min + 1;
}
gl4_scale_x = 1;
gl4_scale_y = 1;
scale_x = 1;
scale_y = 1;
float scissoring_scale_x = 1;
if (!is_rtt && !pvrrc.isRenderFramebuffer)
{
gl4_scale_x=fb_scale_x;
gl4_scale_y=fb_scale_y;
scale_x=fb_scale_x;
scale_y=fb_scale_y;
//work out scaling parameters !
//Pixel doubling is on VO, so it does not affect any pixel operations
@ -843,18 +841,18 @@ static bool RenderFrame()
if (VO_CONTROL.pixel_double)
{
scissoring_scale_x = 0.5f;
gl4_scale_x *= 0.5f;
scale_x *= 0.5f;
}
if (SCALER_CTL.hscale)
{
scissoring_scale_x /= 2;
gl4_scale_x*=2;
scale_x*=2;
}
}
dc_width *= gl4_scale_x;
dc_height *= gl4_scale_y;
dc_width *= scale_x;
dc_height *= scale_y;
/*
Handle Dc to screen scaling
@ -863,7 +861,7 @@ static bool RenderFrame()
float ds2s_offs_x = is_rtt ? 0 : ((screen_width - dc2s_scale_h * 640.0) / 2);
//-1 -> too much to left
gl4ShaderUniforms.scale_coefs[0]=2.0f/(screen_width/dc2s_scale_h*gl4_scale_x);
gl4ShaderUniforms.scale_coefs[0]=2.0f/(screen_width/dc2s_scale_h*scale_x);
gl4ShaderUniforms.scale_coefs[1]=(is_rtt ? 2 : -2) / dc_height; // FIXME CT2 needs 480 here instead of dc_height=512
gl4ShaderUniforms.scale_coefs[2]=1-2*ds2s_offs_x/(screen_width);
gl4ShaderUniforms.scale_coefs[3]=(is_rtt?1:-1);
@ -976,9 +974,9 @@ static bool RenderFrame()
bool wide_screen_on = !is_rtt && settings.rend.WideScreen
&& pvrrc.fb_X_CLIP.min == 0
&& (pvrrc.fb_X_CLIP.max + 1) / gl4_scale_x == 640
&& (pvrrc.fb_X_CLIP.max + 1) / scale_x == 640
&& pvrrc.fb_Y_CLIP.min == 0
&& (pvrrc.fb_Y_CLIP.max + 1) / gl4_scale_y == 480;
&& (pvrrc.fb_Y_CLIP.max + 1) / scale_y == 480;
//Color is cleared by the background plane
@ -1012,21 +1010,21 @@ static bool RenderFrame()
//this needs to be scaled
//not all scaling affects pixel operations, scale to adjust for that
gl4_scale_x *= scissoring_scale_x;
scale_x *= scissoring_scale_x;
#if 0
//handy to debug really stupid render-not-working issues ...
printf("SS: %dx%d\n", screen_width, screen_height);
printf("SCI: %d, %f\n", pvrrc.fb_X_CLIP.max, dc2s_scale_h);
printf("SCI: %f, %f, %f, %f\n", offs_x+pvrrc.fb_X_CLIP.min/gl4_scale_x,(pvrrc.fb_Y_CLIP.min/gl4_scale_y)*dc2s_scale_h,(pvrrc.fb_X_CLIP.max-pvrrc.fb_X_CLIP.min+1)/gl4_scale_x*dc2s_scale_h,(pvrrc.fb_Y_CLIP.max-pvrrc.fb_Y_CLIP.min+1)/gl4_scale_y*dc2s_scale_h);
printf("SCI: %f, %f, %f, %f\n", offs_x+pvrrc.fb_X_CLIP.min/scale_x,(pvrrc.fb_Y_CLIP.min/scale_y)*dc2s_scale_h,(pvrrc.fb_X_CLIP.max-pvrrc.fb_X_CLIP.min+1)/scale_x*dc2s_scale_h,(pvrrc.fb_Y_CLIP.max-pvrrc.fb_Y_CLIP.min+1)/scale_y*dc2s_scale_h);
#endif
if (!wide_screen_on)
{
float width = (pvrrc.fb_X_CLIP.max - pvrrc.fb_X_CLIP.min + 1) / gl4_scale_x;
float height = (pvrrc.fb_Y_CLIP.max - pvrrc.fb_Y_CLIP.min + 1) / gl4_scale_y;
float min_x = pvrrc.fb_X_CLIP.min / gl4_scale_x;
float min_y = pvrrc.fb_Y_CLIP.min / gl4_scale_y;
float width = (pvrrc.fb_X_CLIP.max - pvrrc.fb_X_CLIP.min + 1) / scale_x;
float height = (pvrrc.fb_Y_CLIP.max - pvrrc.fb_Y_CLIP.min + 1) / scale_y;
float min_x = pvrrc.fb_X_CLIP.min / scale_x;
float min_y = pvrrc.fb_Y_CLIP.min / scale_y;
if (!is_rtt)
{
// Add x offset for aspect ratio > 4/3
@ -1059,7 +1057,7 @@ static bool RenderFrame()
}
//restore scale_x
gl4_scale_x /= scissoring_scale_x;
scale_x /= scissoring_scale_x;
gl4DrawStrips(output_fbo);
}
else

View File

@ -1317,7 +1317,7 @@ static void DrawRightedText(float yy, float scale, int transparency, const char*
float w = float(strlen(text) * 14) * scale * scale_x;
float x = (ShaderUniforms.scale_coefs[2] + 1) / ShaderUniforms.scale_coefs[0] - w;
float x = scale_x / 2 * (640 + screen_width * 480 / screen_height) - w;
float y = yy * scale_y;
float h = 16.0f * scale * scale_y;
w = 14.0f * scale * scale_x;