gsdx: add a nice enum to replace the hardcoded convert shader

This commit is contained in:
Gregory Hainaut 2015-09-08 16:36:23 +02:00
parent 1ae0fed83b
commit ddc03cbccf
5 changed files with 33 additions and 12 deletions

View File

@ -112,7 +112,9 @@ void GSDevice::Present(const GSVector4i& r, int shader)
if(m_current)
{
static int s_shader[5] = {0, 5, 6, 8, 9}; // FIXME
static int s_shader[5] = {ShaderConvert_COPY, ShaderConvert_SCANLINE,
ShaderConvert_DIAGONAL_FILTER, ShaderConvert_TRIANGULAR_FILTER,
ShaderConvert_COMPLEX_FILTER}; // FIXME
Present(m_current, m_backbuffer, GSVector4(r), s_shader[shader]);
}

View File

@ -26,6 +26,27 @@
#include "GSVertex.h"
#include "GSAlignedClass.h"
enum ShaderConvert {
ShaderConvert_COPY = 0,
ShaderConvert_RGBA8_TO_16_BITS,
ShaderConvert_DATM_1,
ShaderConvert_DATM_0,
ShaderConvert_MOD_256,
ShaderConvert_SCANLINE = 5,
ShaderConvert_DIAGONAL_FILTER,
ShaderConvert_TRANSPARENCY_FILTER,
ShaderConvert_TRIANGULAR_FILTER,
ShaderConvert_COMPLEX_FILTER,
ShaderConvert_FLOAT32_TO_32_BITS = 10,
ShaderConvert_FLOAT32_TO_RGBA8,
ShaderConvert_FLOAT16_TO_RGB5A1,
ShaderConvert_RGBA8_TO_FLOAT32 = 13,
ShaderConvert_RGBA8_TO_FLOAT24,
ShaderConvert_RGBA8_TO_FLOAT16,
ShaderConvert_RGB5A1_TO_FLOAT16,
ShaderConvert_RGBA_TO_8I = 17
};
#pragma pack(push, 1)
class ConvertConstantBuffer

View File

@ -950,8 +950,8 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture
return;
}
bool draw_in_depth = (ps == m_convert.ps[13] || ps == m_convert.ps[14] ||
ps == m_convert.ps[15] || ps == m_convert.ps[16]);
bool draw_in_depth = (ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT32] || ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT24] ||
ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT16] || ps == m_convert.ps[ShaderConvert_RGB5A1_TO_FLOAT16]);
// Performance optimization. It might be faster to use a framebuffer blit for standard case
// instead to emulate it with shader
@ -1209,7 +1209,7 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver
m_shader->VS(m_convert.vs);
m_shader->GS(0);
m_shader->PS(m_convert.ps[datm ? 2 : 3]);
m_shader->PS(m_convert.ps[datm ? ShaderConvert_DATM_1 : ShaderConvert_DATM_0]);
// om

View File

@ -1013,7 +1013,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
if (hdr_rt) {
GSVector4 dRect(ComputeBoundingBox(rtscale, rtsize));
GSVector4 sRect = dRect / GSVector4(rtsize.x, rtsize.y).xyxy();
dev->StretchRect(hdr_rt, sRect, rt, dRect, 4, false);
dev->StretchRect(hdr_rt, sRect, rt, dRect, ShaderConvert_MOD_256, false);
dev->Recycle(hdr_rt);
}

View File

@ -291,11 +291,11 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
if (type == DepthStencil) {
GL_CACHE("TC: Lookup Target(Depth) %dx%d, hit Color (0x%x, F:0x%x)", w, h, bp, TEX0.PSM);
int shader = 13 + GSLocalMemory::m_psm[TEX0.PSM].fmt;
int shader = ShaderConvert_RGBA8_TO_FLOAT32 + GSLocalMemory::m_psm[TEX0.PSM].fmt;
m_renderer->m_dev->StretchRect(t->m_texture, sRect, dst->m_texture, dRect, shader, false);
} else {
GL_CACHE("TC: Lookup Target(Color) %dx%d, hit Depth (0x%x, F:0x%x)", w, h, bp, TEX0.PSM);
m_renderer->m_dev->StretchRect(t->m_texture, sRect, dst->m_texture, dRect, 11, false);
m_renderer->m_dev->StretchRect(t->m_texture, sRect, dst->m_texture, dRect, ShaderConvert_FLOAT32_TO_RGBA8, false);
}
break;
@ -862,14 +862,12 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
// TODO: clean up this mess
// Shader 11 convert depth to color
// Shader 14 convert 32 bits color to 8 bits color
int shader = dst->m_type != RenderTarget ? 11 : 0;
int shader = dst->m_type != RenderTarget ? ShaderConvert_FLOAT32_TO_RGBA8 : ShaderConvert_COPY;
bool is_8bits = TEX0.PSM == PSM_PSMT8 && IsOpenGL();
if (is_8bits) {
GL_INS("Reading RT as a packed-indexed 8 bits format");
shader = 17; // ask a conversion to 8 bits format
shader = ShaderConvert_RGBA_TO_8I;
}
#ifdef ENABLE_OGL_DEBUG
@ -1555,7 +1553,7 @@ void GSTextureCache::Target::Update()
GL_INS("ERROR: Update DepthStencil");
// FIXME linear or not?
m_renderer->m_dev->StretchRect(t, m_texture, GSVector4(r) * GSVector4(m_texture->GetScale()).xyxy(), 13);
m_renderer->m_dev->StretchRect(t, m_texture, GSVector4(r) * GSVector4(m_texture->GetScale()).xyxy(), ShaderConvert_RGBA8_TO_FLOAT32);
}
m_renderer->m_dev->Recycle(t);