gl4: get rid of scaling params and use normalized coords in abuffer
add Eternal Arcadia and Yu Suzuki Game Works to render rtt to vram game list
This commit is contained in:
parent
a14bf29f5f
commit
838cbe59e3
|
@ -158,10 +158,14 @@ void LoadSpecialSettings()
|
|||
|| !strncmp("T40204D", reios_product_number, 7)
|
||||
// Skies of Arcadia
|
||||
|| !strncmp("MK-51052", reios_product_number, 8)
|
||||
// Eternal Arcadia (JP)
|
||||
|| !strncmp("HDR-0076", reios_product_number, 8)
|
||||
// Flag to Flag (US)
|
||||
|| !strncmp("MK-51007", reios_product_number, 8)
|
||||
// Super Speed Racing (JP)
|
||||
|| !strncmp("HDR-0013", reios_product_number, 8))
|
||||
|| !strncmp("HDR-0013", reios_product_number, 8)
|
||||
// Yu Suzuki Game Works Vol. 1
|
||||
|| !strncmp("6108099", reios_product_number, 7))
|
||||
{
|
||||
settings.rend.RenderToTextureBuffer = 1;
|
||||
rtt_to_buffer_game = true;
|
||||
|
|
|
@ -275,6 +275,16 @@ void main(void) \n\
|
|||
} \n\
|
||||
";
|
||||
|
||||
static const char* VertexShaderSource =
|
||||
"#version 430 \n"
|
||||
"\
|
||||
in highp vec3 in_pos; \n\
|
||||
\n\
|
||||
void main() \n\
|
||||
{ \n\
|
||||
gl_Position = vec4(in_pos, 1.0); \n\
|
||||
}";
|
||||
|
||||
void initABuffer()
|
||||
{
|
||||
if (max_image_width > 0 && max_image_height > 0)
|
||||
|
@ -325,23 +335,23 @@ void initABuffer()
|
|||
{
|
||||
char source[16384];
|
||||
sprintf(source, final_shader_source, 1);
|
||||
gl4CompilePipelineShader(&g_abuffer_final_shader, false, source);
|
||||
gl4CompilePipelineShader(&g_abuffer_final_shader, false, source, VertexShaderSource);
|
||||
}
|
||||
if (g_abuffer_final_nosort_shader.program == 0)
|
||||
{
|
||||
char source[16384];
|
||||
sprintf(source, final_shader_source, 0);
|
||||
gl4CompilePipelineShader(&g_abuffer_final_nosort_shader, false, source);
|
||||
gl4CompilePipelineShader(&g_abuffer_final_nosort_shader, false, source, VertexShaderSource);
|
||||
}
|
||||
if (g_abuffer_clear_shader.program == 0)
|
||||
gl4CompilePipelineShader(&g_abuffer_clear_shader, false, clear_shader_source);
|
||||
gl4CompilePipelineShader(&g_abuffer_clear_shader, false, clear_shader_source, VertexShaderSource);
|
||||
if (g_abuffer_tr_modvol_shaders[0].program == 0)
|
||||
{
|
||||
char source[16384];
|
||||
for (int mode = 0; mode < ModeCount; mode++)
|
||||
{
|
||||
sprintf(source, tr_modvol_shader_source, mode);
|
||||
gl4CompilePipelineShader(&g_abuffer_tr_modvol_shaders[mode], false, source);
|
||||
gl4CompilePipelineShader(&g_abuffer_tr_modvol_shaders[mode], false, source, VertexShaderSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,21 +363,8 @@ void initABuffer()
|
|||
glGenBuffers(1, &g_quadBuffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_quadBuffer); glCheck();
|
||||
|
||||
glEnableVertexAttribArray(VERTEX_POS_ARRAY); glCheck();
|
||||
glVertexAttribPointer(VERTEX_POS_ARRAY, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,x)); glCheck();
|
||||
|
||||
glEnableVertexAttribArray(VERTEX_COL_BASE_ARRAY); glCheck();
|
||||
glVertexAttribPointer(VERTEX_COL_BASE_ARRAY, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex,col)); glCheck();
|
||||
|
||||
glEnableVertexAttribArray(VERTEX_COL_OFFS_ARRAY); glCheck();
|
||||
glVertexAttribPointer(VERTEX_COL_OFFS_ARRAY, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (void*)offsetof(Vertex,spc)); glCheck();
|
||||
|
||||
glEnableVertexAttribArray(VERTEX_UV_ARRAY); glCheck();
|
||||
glVertexAttribPointer(VERTEX_UV_ARRAY, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,u)); glCheck();
|
||||
|
||||
glDisableVertexAttribArray(VERTEX_UV1_ARRAY);
|
||||
glDisableVertexAttribArray(VERTEX_COL_OFFS1_ARRAY);
|
||||
glDisableVertexAttribArray(VERTEX_COL_BASE1_ARRAY);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 3, (void*)0);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glCheck();
|
||||
glBindVertexArray(0);
|
||||
|
@ -378,7 +375,7 @@ void initABuffer()
|
|||
glcache.UseProgram(g_abuffer_clear_shader.program);
|
||||
gl4ShaderUniforms.Set(&g_abuffer_clear_shader);
|
||||
|
||||
abufferDrawQuad(max_image_width, max_image_height);
|
||||
abufferDrawQuad();
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
|
||||
glCheck();
|
||||
|
@ -434,28 +431,15 @@ void reshapeABuffer(int w, int h)
|
|||
initABuffer();
|
||||
}
|
||||
|
||||
void abufferDrawQuad(float w, float h)
|
||||
void abufferDrawQuad()
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
if (gl4ShaderUniforms.scale_coefs[3] < 0)
|
||||
{
|
||||
// rendering to screen
|
||||
float scl = 480.f / h;
|
||||
float tx = (w * scl - 640.f) / 2;
|
||||
|
||||
x = -tx;
|
||||
y = 0.f;
|
||||
w = 640.f + tx * 2;
|
||||
h = 480.f;
|
||||
}
|
||||
glBindVertexArray(g_quadVertexArray);
|
||||
|
||||
struct Vertex vertices[] = {
|
||||
{ x, y + h, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 0, 1.f },
|
||||
{ x, y, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 0, 0.f },
|
||||
{ x + w, y + h, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 1, 1.f },
|
||||
{ x + w, y, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 1, 0.f },
|
||||
float vertices[] = {
|
||||
-1, 1, 1,
|
||||
-1, -1, 1,
|
||||
1, 1, 1,
|
||||
1, -1, 1,
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 1, 3 };
|
||||
|
||||
|
@ -565,25 +549,8 @@ void checkOverflowAndReset()
|
|||
glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0 , sizeof(GLuint), &max_pixel_index);
|
||||
}
|
||||
|
||||
void renderABuffer(bool sortFragments, int width, int height)
|
||||
void renderABuffer(bool sortFragments)
|
||||
{
|
||||
// Reset scale params
|
||||
if (gl4ShaderUniforms.scale_coefs[3] < 0)
|
||||
{
|
||||
// screen
|
||||
float scale_h = height / 480.f;
|
||||
float offs_x = (width - scale_h * 640.f) / 2.f;
|
||||
gl4ShaderUniforms.scale_coefs[0] = 2.f / (width / scale_h);
|
||||
gl4ShaderUniforms.scale_coefs[1] = -2.f / 480.f;
|
||||
gl4ShaderUniforms.scale_coefs[2] = 1.f - 2.f * offs_x / width;
|
||||
}
|
||||
else
|
||||
{
|
||||
// RTT
|
||||
gl4ShaderUniforms.scale_coefs[0] = 2.0f / width;
|
||||
gl4ShaderUniforms.scale_coefs[1] = 2.0f / height;
|
||||
gl4ShaderUniforms.scale_coefs[2] = 1;
|
||||
}
|
||||
// Render to output FBO
|
||||
glcache.UseProgram(sortFragments ? g_abuffer_final_shader.program : g_abuffer_final_nosort_shader.program);
|
||||
gl4ShaderUniforms.Set(&g_abuffer_final_shader);
|
||||
|
@ -592,7 +559,7 @@ void renderABuffer(bool sortFragments, int width, int height)
|
|||
glcache.Disable(GL_CULL_FACE);
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
|
||||
abufferDrawQuad(width, height);
|
||||
abufferDrawQuad();
|
||||
|
||||
glCheck();
|
||||
|
||||
|
@ -601,7 +568,7 @@ void renderABuffer(bool sortFragments, int width, int height)
|
|||
gl4ShaderUniforms.Set(&g_abuffer_clear_shader);
|
||||
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
abufferDrawQuad(width, height);
|
||||
abufferDrawQuad();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
|
|
|
@ -66,10 +66,10 @@ extern int max_image_height;
|
|||
GLuint gl4BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt);
|
||||
void gl4DrawFramebuffer(float w, float h);
|
||||
bool gl4_render_output_framebuffer();
|
||||
void abufferDrawQuad(float w, float h);
|
||||
void abufferDrawQuad();
|
||||
|
||||
extern const char *gl4PixelPipelineShader;
|
||||
bool gl4CompilePipelineShader(gl4PipelineShader* s, bool rotate_90, const char *source = gl4PixelPipelineShader);
|
||||
bool gl4CompilePipelineShader(gl4PipelineShader* s, bool rotate_90, const char *pixel_source = gl4PixelPipelineShader, const char *vertex_source = NULL);
|
||||
void gl4_delete_shaders();
|
||||
|
||||
extern GLuint stencilTexId;
|
||||
|
|
|
@ -386,7 +386,7 @@ static void DrawModVols(int first, int count)
|
|||
glcache.DepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void renderABuffer(bool sortFragments, int width, int height);
|
||||
void renderABuffer(bool sortFragments);
|
||||
void DrawTranslucentModVols(int first, int count);
|
||||
void checkOverflowAndReset();
|
||||
|
||||
|
@ -620,7 +620,7 @@ void gl4DrawStrips(GLuint output_fbo, int width, int height)
|
|||
glBindSampler(0, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, opaqueTexId);
|
||||
|
||||
renderABuffer(current_pass.autosort, width, height);
|
||||
renderABuffer(current_pass.autosort);
|
||||
|
||||
glcache.DeleteTextures(1, &opaqueTexId);
|
||||
opaqueTexId = texId;
|
||||
|
@ -648,7 +648,7 @@ void gl4DrawStrips(GLuint output_fbo, int width, int height)
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindSampler(0, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, opaqueTexId);
|
||||
renderABuffer(previous_pass.autosort, width, height);
|
||||
renderABuffer(previous_pass.autosort);
|
||||
}
|
||||
|
||||
static void gl4_draw_quad_texture(GLuint texture, float w, float h)
|
||||
|
@ -681,7 +681,19 @@ static void gl4_draw_quad_texture(GLuint texture, float w, float h)
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
abufferDrawQuad(w, h);
|
||||
struct Vertex vertices[] = {
|
||||
{ 0, 0 + h, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 0, 1 },
|
||||
{ 0, 0, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 0, 0 },
|
||||
{ 0 + w, 0 + h, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 1, 1 },
|
||||
{ 0 + w, 0, 1, { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, 1, 0 },
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 1, 3 };
|
||||
|
||||
gl4SetupMainVBO();
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STREAM_DRAW);
|
||||
|
||||
glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, (void *)0);
|
||||
}
|
||||
|
||||
void gl4DrawFramebuffer(float w, float h)
|
||||
|
|
|
@ -399,15 +399,15 @@ struct gl4ShaderUniforms_t gl4ShaderUniforms;
|
|||
int max_image_width;
|
||||
int max_image_height;
|
||||
|
||||
bool gl4CompilePipelineShader( gl4PipelineShader* s, bool rotate_90, const char *source /* = PixelPipelineShader */)
|
||||
bool gl4CompilePipelineShader( gl4PipelineShader* s, bool rotate_90, const char *pixel_source /* = PixelPipelineShader */, const char *vertex_source /* = NULL */)
|
||||
{
|
||||
char vshader[16384];
|
||||
|
||||
sprintf(vshader, VertexShaderSource, s->pp_Gouraud, rotate_90);
|
||||
sprintf(vshader, vertex_source == NULL ? VertexShaderSource : vertex_source, s->pp_Gouraud, rotate_90);
|
||||
|
||||
char pshader[16384];
|
||||
|
||||
sprintf(pshader, source,
|
||||
sprintf(pshader, pixel_source,
|
||||
s->cp_AlphaTest,s->pp_ClipTestMode,s->pp_UseAlpha,
|
||||
s->pp_Texture,s->pp_IgnoreTexA,s->pp_ShadInstr,s->pp_Offset,s->pp_FogCtrl, s->pp_TwoVolumes, s->pp_DepthFunc, s->pp_Gouraud, s->pp_BumpMap, s->fog_clamping, s->pass);
|
||||
|
||||
|
@ -618,8 +618,10 @@ static void resize(int w, int h)
|
|||
{
|
||||
if (w > max_image_width || h > max_image_height || stencilTexId == 0)
|
||||
{
|
||||
max_image_width = w;
|
||||
max_image_height = h;
|
||||
if (w > max_image_width)
|
||||
max_image_width = w;
|
||||
if (h > max_image_height)
|
||||
max_image_height = h;
|
||||
|
||||
if (stencilTexId != 0)
|
||||
{
|
||||
|
@ -641,8 +643,8 @@ static void resize(int w, int h)
|
|||
glcache.DeleteTextures(1, &depthSaveTexId);
|
||||
depthSaveTexId = 0;
|
||||
}
|
||||
gl4CreateTextures(w, h);
|
||||
reshapeABuffer(w, h);
|
||||
gl4CreateTextures(max_image_width, max_image_height);
|
||||
reshapeABuffer(max_image_width, max_image_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -845,7 +847,7 @@ static bool RenderFrame()
|
|||
{
|
||||
if (settings.rend.ScreenScaling != 100 || gl.swap_buffer_not_preserved)
|
||||
{
|
||||
output_fbo = init_output_framebuffer(rendering_width, rendering_width);
|
||||
output_fbo = init_output_framebuffer(rendering_width, rendering_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1565,6 +1565,10 @@ void gui_display_ui()
|
|||
{
|
||||
gui_state = ClosedNoResume;
|
||||
gui_start_game(game_file);
|
||||
#ifdef TEST_AUTOMATION
|
||||
if (gui_state == Main)
|
||||
die("Game load failed");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
gui_display_content();
|
||||
|
|
Loading…
Reference in New Issue