dx11: wrong shadow scale factor. vk: object leak. Code duplication
dx11: shadow scale factor inverted in per-pixel vulkan: clear deleted overlay images when terminating Use color struct for FOG_COL_VERT, FOG_COL_RAM, FOG_CLAMP_MIN, FOG_CLAMP_MAX and VO_BORDER_COL. Avoid code duplication in renderers.
This commit is contained in:
parent
dc5acd24b2
commit
e02afb34d1
|
@ -361,8 +361,8 @@ void rend_start_render()
|
|||
ctx->rend.fb_Y_CLIP.min = 0;
|
||||
ctx->rend.fb_Y_CLIP.max = 479;
|
||||
|
||||
ctx->rend.fog_clamp_min = 0;
|
||||
ctx->rend.fog_clamp_max = 0xffffffff;
|
||||
ctx->rend.fog_clamp_min.full = 0;
|
||||
ctx->rend.fog_clamp_max.full = 0xffffffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -113,19 +113,71 @@ union FB_R_SIZE_type
|
|||
};
|
||||
u32 full;
|
||||
};
|
||||
union VO_BORDER_COL_type
|
||||
|
||||
template<typename T>
|
||||
struct RGBAColorTemplate
|
||||
{
|
||||
struct
|
||||
float red() const { return ((T *)this)->_red / 255.f; }
|
||||
float green() const { return ((T *)this)->_green / 255.f; }
|
||||
float blue() const { return ((T *)this)->_blue / 255.f; }
|
||||
float alpha() const { return ((T *)this)->_alpha / 255.f; }
|
||||
|
||||
void getRGBColor(float rgb[3])
|
||||
{
|
||||
u32 Blue : 8; //0
|
||||
u32 Green : 8; //8
|
||||
u32 Red : 8; //16
|
||||
u32 Chroma : 1; //24
|
||||
u32 res : 7; //25
|
||||
};
|
||||
u32 full;
|
||||
rgb[0] = red();
|
||||
rgb[1] = green();
|
||||
rgb[2] = blue();
|
||||
}
|
||||
|
||||
void getRGBAColor(float rgba[4])
|
||||
{
|
||||
getRGBColor(rgba);
|
||||
rgba[3] = alpha();
|
||||
}
|
||||
};
|
||||
|
||||
struct VO_BORDER_COL_type : RGBAColorTemplate<VO_BORDER_COL_type>
|
||||
{
|
||||
union {
|
||||
struct
|
||||
{
|
||||
u32 _blue : 8;
|
||||
u32 _green : 8;
|
||||
u32 _red : 8;
|
||||
u32 _chroma : 1;
|
||||
u32 _res : 7;
|
||||
};
|
||||
u32 full;
|
||||
};
|
||||
};
|
||||
|
||||
struct RGBColor : RGBAColorTemplate<RGBColor>
|
||||
{
|
||||
union {
|
||||
struct
|
||||
{
|
||||
u32 _blue : 8;
|
||||
u32 _green : 8;
|
||||
u32 _red : 8;
|
||||
u32 _res : 8;
|
||||
};
|
||||
u32 full;
|
||||
};
|
||||
};
|
||||
|
||||
struct RGBAColor : RGBAColorTemplate<RGBAColor>
|
||||
{
|
||||
union {
|
||||
struct
|
||||
{
|
||||
u32 _blue : 8;
|
||||
u32 _green : 8;
|
||||
u32 _red : 8;
|
||||
u32 _alpha : 8;
|
||||
};
|
||||
u32 full;
|
||||
};
|
||||
};
|
||||
|
||||
union SPG_STATUS_type
|
||||
{
|
||||
|
@ -474,11 +526,11 @@ union FOG_DENSITY_type
|
|||
#define SDRAM_ARB_CFG PvrReg(SDRAM_ARB_CFG_addr,u32) // RW Texture memory arbiter control
|
||||
#define SDRAM_CFG PvrReg(SDRAM_CFG_addr,u32) // RW Texture memory control
|
||||
|
||||
#define FOG_COL_RAM PvrReg(FOG_COL_RAM_addr,u32) // RW Color for Look Up table Fog
|
||||
#define FOG_COL_VERT PvrReg(FOG_COL_VERT_addr,u32) // RW Color for vertex Fog
|
||||
#define FOG_COL_RAM PvrReg(FOG_COL_RAM_addr, RGBColor) // RW Color for Look Up table Fog
|
||||
#define FOG_COL_VERT PvrReg(FOG_COL_VERT_addr, RGBColor) // RW Color for vertex Fog
|
||||
#define FOG_DENSITY PvrReg(FOG_DENSITY_addr, FOG_DENSITY_type) // RW Fog scale value
|
||||
#define FOG_CLAMP_MAX PvrReg(FOG_CLAMP_MAX_addr,u32) // RW Color clamping maximum value
|
||||
#define FOG_CLAMP_MIN PvrReg(FOG_CLAMP_MIN_addr,u32) // RW Color clamping minimum value
|
||||
#define FOG_CLAMP_MAX PvrReg(FOG_CLAMP_MAX_addr, RGBAColor) // RW Color clamping maximum value
|
||||
#define FOG_CLAMP_MIN PvrReg(FOG_CLAMP_MIN_addr, RGBAColor) // RW Color clamping minimum value
|
||||
#define SPG_TRIGGER_POS PvrReg(SPG_TRIGGER_POS_addr,u32) // RW External trigger signal HV counter value
|
||||
#define SPG_HBLANK_INT PvrReg(SPG_HBLANK_INT_addr,SPG_HBLANK_INT_type) // RW H-blank interrupt control
|
||||
#define SPG_VBLANK_INT PvrReg(SPG_VBLANK_INT_addr,SPG_VBLANK_INT_type) // RW V-blank interrupt control
|
||||
|
|
|
@ -129,8 +129,8 @@ struct rend_context
|
|||
FB_X_CLIP_type fb_X_CLIP;
|
||||
FB_Y_CLIP_type fb_Y_CLIP;
|
||||
|
||||
u32 fog_clamp_min;
|
||||
u32 fog_clamp_max;
|
||||
RGBAColor fog_clamp_min;
|
||||
RGBAColor fog_clamp_max;
|
||||
|
||||
List<Vertex> verts;
|
||||
List<u32> idx;
|
||||
|
|
|
@ -319,7 +319,7 @@ bool DX11Renderer::Process(TA_context* ctx)
|
|||
|
||||
//
|
||||
// Efficient Triangle and Quadrilateral Clipping within Shaders. M. McGuire
|
||||
// Journal of Graphics GPU and Game Tools · November 2011
|
||||
// Journal of Graphics GPU and Game Tools <EFBFBD> November 2011
|
||||
//
|
||||
static glm::vec3 intersect(const glm::vec3& A, float Adist , const glm::vec3& B, float Bdist)
|
||||
{
|
||||
|
@ -556,30 +556,17 @@ void DX11Renderer::setupPixelShaderConstants()
|
|||
{
|
||||
PixelConstants pixelConstants;
|
||||
// VERT and RAM fog color constants
|
||||
u8* fog_colvert_bgra = (u8*)&FOG_COL_VERT;
|
||||
u8* fog_colram_bgra = (u8*)&FOG_COL_RAM;
|
||||
pixelConstants.fog_col_vert[0] = fog_colvert_bgra[2] / 255.0f;
|
||||
pixelConstants.fog_col_vert[1] = fog_colvert_bgra[1] / 255.0f;
|
||||
pixelConstants.fog_col_vert[2] = fog_colvert_bgra[0] / 255.0f;
|
||||
pixelConstants.fog_col_ram[0] = fog_colram_bgra[2] / 255.0f;
|
||||
pixelConstants.fog_col_ram[1] = fog_colram_bgra[1] / 255.0f;
|
||||
pixelConstants.fog_col_ram[2] = fog_colram_bgra[0] / 255.0f;
|
||||
FOG_COL_VERT.getRGBColor(pixelConstants.fog_col_vert);
|
||||
FOG_COL_RAM.getRGBColor(pixelConstants.fog_col_ram);
|
||||
|
||||
// Fog density
|
||||
pixelConstants.fogDensity = FOG_DENSITY.get() * config::ExtraDepthScale;
|
||||
// Shadow scale
|
||||
pixelConstants.shadowScale = 1.f - FPU_SHAD_SCALE.scale_factor / 256.f;
|
||||
pixelConstants.shadowScale = FPU_SHAD_SCALE.scale_factor / 256.f;
|
||||
|
||||
// Color clamping
|
||||
pixelConstants.colorClampMin[0] = ((pvrrc.fog_clamp_min >> 16) & 0xFF) / 255.0f;
|
||||
pixelConstants.colorClampMin[1] = ((pvrrc.fog_clamp_min >> 8) & 0xFF) / 255.0f;
|
||||
pixelConstants.colorClampMin[2] = ((pvrrc.fog_clamp_min >> 0) & 0xFF) / 255.0f;
|
||||
pixelConstants.colorClampMin[3] = ((pvrrc.fog_clamp_min >> 24) & 0xFF) / 255.0f;
|
||||
|
||||
pixelConstants.colorClampMax[0] = ((pvrrc.fog_clamp_max >> 16) & 0xFF) / 255.0f;
|
||||
pixelConstants.colorClampMax[1] = ((pvrrc.fog_clamp_max >> 8) & 0xFF) / 255.0f;
|
||||
pixelConstants.colorClampMax[2] = ((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f;
|
||||
pixelConstants.colorClampMax[3] = ((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f;
|
||||
pvrrc.fog_clamp_min.getRGBAColor(pixelConstants.colorClampMin);
|
||||
pvrrc.fog_clamp_max.getRGBAColor(pixelConstants.colorClampMax);
|
||||
|
||||
// Punch-through alpha ref
|
||||
pixelConstants.alphaTestValue = (PT_ALPHA_REF & 0xFF) / 255.0f;
|
||||
|
@ -650,7 +637,9 @@ bool DX11Renderer::Render()
|
|||
|
||||
void DX11Renderer::renderDCFramebuffer()
|
||||
{
|
||||
FLOAT colors[4] = { VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f };
|
||||
float colors[4];
|
||||
VO_BORDER_COL.getRGBColor(colors);
|
||||
colors[3] = 1.f;
|
||||
deviceContext->ClearRenderTargetView(fbRenderTarget, colors);
|
||||
D3D11_VIEWPORT vp{};
|
||||
vp.Width = (FLOAT)width;
|
||||
|
@ -676,7 +665,9 @@ void DX11Renderer::renderFramebuffer()
|
|||
|
||||
const D3D11_RECT r = { 0, 0, settings.display.width, settings.display.height };
|
||||
deviceContext->RSSetScissorRects(1, &r);
|
||||
FLOAT colors[4] = { VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f };
|
||||
float colors[4];
|
||||
VO_BORDER_COL.getRGBColor(colors);
|
||||
colors[3] = 1.f;
|
||||
deviceContext->ClearRenderTargetView(theDX11Context.getRenderTarget(), colors);
|
||||
int outwidth = settings.display.width;
|
||||
int outheight = settings.display.height;
|
||||
|
@ -746,7 +737,7 @@ void DX11Renderer::setRenderState(const PolyParam *gp)
|
|||
else
|
||||
constants.trilinearAlpha = 1.f;
|
||||
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
int fog_ctrl = config::Fog ? gp->tsp.FogCtrl : 2;
|
||||
|
||||
int clip_rect[4] = {};
|
||||
|
@ -1147,7 +1138,9 @@ void DX11Renderer::setBaseScissor()
|
|||
{
|
||||
float scaled_offs_x = matrices.GetSidebarWidth();
|
||||
|
||||
float borderColor[] { VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f };
|
||||
float borderColor[4];
|
||||
VO_BORDER_COL.getRGBColor(borderColor);
|
||||
borderColor[3] = 1.f;
|
||||
D3D11_VIEWPORT vp{};
|
||||
vp.MaxDepth = 1.f;
|
||||
vp.Width = scaled_offs_x;
|
||||
|
|
|
@ -296,7 +296,7 @@ PSO modifierVolume(in MVPixel inpix)
|
|||
PSO pso;
|
||||
float w = inpix.uv.w * 100000.0f;
|
||||
pso.z = log2(1.0f + w) / 34.0f;
|
||||
pso.col = float4(0, 0, 0, shadowScale);
|
||||
pso.col = float4(0, 0, 0, 1.f - shadowScale);
|
||||
|
||||
return pso;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ struct DX11OITRenderer : public DX11Renderer
|
|||
}
|
||||
else
|
||||
{
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
|
||||
int fog_ctrl = config::Fog ? gp->tsp.FogCtrl : 2;
|
||||
gpuPalette = gp->texture != nullptr ? gp->texture->gpuPalette : false;
|
||||
|
|
|
@ -267,7 +267,7 @@ void D3DRenderer::readDCFramebuffer()
|
|||
|
||||
void D3DRenderer::renderDCFramebuffer()
|
||||
{
|
||||
device->ColorFill(framebufferSurface, 0, D3DCOLOR_ARGB(255, VO_BORDER_COL.Red, VO_BORDER_COL.Green, VO_BORDER_COL.Blue));
|
||||
device->ColorFill(framebufferSurface, 0, D3DCOLOR_ARGB(255, VO_BORDER_COL._red, VO_BORDER_COL._green, VO_BORDER_COL._blue));
|
||||
u32 bar = (width - height * 640 / 480) / 2;
|
||||
RECT rd{ (LONG)bar, 0, (LONG)(width - bar), (LONG)height };
|
||||
device->StretchRect(dcfbSurface, nullptr, framebufferSurface, &rd, D3DTEXF_LINEAR);
|
||||
|
@ -322,7 +322,7 @@ void D3DRenderer::setGPState(const PolyParam *gp)
|
|||
else
|
||||
trilinear_alpha = 1.f;
|
||||
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
int fog_ctrl = config::Fog ? gp->tsp.FogCtrl : 2;
|
||||
|
||||
int clip_rect[4] = {};
|
||||
|
@ -817,7 +817,7 @@ void D3DRenderer::setBaseScissor()
|
|||
{
|
||||
float scaled_offs_x = matrices.GetSidebarWidth();
|
||||
|
||||
D3DCOLOR borderColor = D3DCOLOR_ARGB(255, VO_BORDER_COL.Red, VO_BORDER_COL.Green, VO_BORDER_COL.Blue);
|
||||
D3DCOLOR borderColor = D3DCOLOR_ARGB(255, VO_BORDER_COL._red, VO_BORDER_COL._green, VO_BORDER_COL._blue);
|
||||
devCache.SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
D3DRECT rects[] {
|
||||
{ 0, 0, lroundf(scaled_offs_x), (long)height },
|
||||
|
@ -1046,10 +1046,10 @@ bool D3DRenderer::Render()
|
|||
devCache.SetVertexShader(shaders.getVertexShader(true));
|
||||
|
||||
// VERT and RAM fog color constants
|
||||
u8* fog_colvert_bgra = (u8*)&FOG_COL_VERT;
|
||||
u8* fog_colram_bgra = (u8*)&FOG_COL_RAM;
|
||||
float ps_FOG_COL_VERT[4] = { fog_colvert_bgra[2] / 255.0f, fog_colvert_bgra[1] / 255.0f, fog_colvert_bgra[0] / 255.0f, 1 };
|
||||
float ps_FOG_COL_RAM[4] = { fog_colram_bgra[2] / 255.0f, fog_colram_bgra[1] / 255.0f, fog_colram_bgra[0] / 255.0f, 1 };
|
||||
float ps_FOG_COL_VERT[4];
|
||||
float ps_FOG_COL_RAM[4];
|
||||
FOG_COL_VERT.getRGBColor(ps_FOG_COL_VERT);
|
||||
FOG_COL_RAM.getRGBColor(ps_FOG_COL_RAM);
|
||||
device->SetPixelShaderConstantF(1, ps_FOG_COL_VERT, 1);
|
||||
device->SetPixelShaderConstantF(2, ps_FOG_COL_RAM, 1);
|
||||
|
||||
|
@ -1059,20 +1059,11 @@ bool D3DRenderer::Render()
|
|||
device->SetPixelShaderConstantF(3, fogDensityAndScale, 1);
|
||||
|
||||
// Color clamping
|
||||
float fog_clamp_min[] {
|
||||
((pvrrc.fog_clamp_min >> 16) & 0xFF) / 255.0f,
|
||||
((pvrrc.fog_clamp_min >> 8) & 0xFF) / 255.0f,
|
||||
((pvrrc.fog_clamp_min >> 0) & 0xFF) / 255.0f,
|
||||
((pvrrc.fog_clamp_min >> 24) & 0xFF) / 255.0f
|
||||
};
|
||||
device->SetPixelShaderConstantF(6, fog_clamp_min, 1);
|
||||
float fog_clamp_max[] {
|
||||
((pvrrc.fog_clamp_max >> 16) & 0xFF) / 255.0f,
|
||||
((pvrrc.fog_clamp_max >> 8) & 0xFF) / 255.0f,
|
||||
((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f,
|
||||
((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f
|
||||
};
|
||||
device->SetPixelShaderConstantF(7, fog_clamp_max, 1);
|
||||
float color_clamp[4];
|
||||
pvrrc.fog_clamp_min.getRGBAColor(color_clamp);
|
||||
device->SetPixelShaderConstantF(6, color_clamp, 1);
|
||||
pvrrc.fog_clamp_max.getRGBAColor(color_clamp);
|
||||
device->SetPixelShaderConstantF(7, color_clamp, 1);
|
||||
|
||||
devCache.SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
|
||||
|
@ -1141,7 +1132,7 @@ void D3DRenderer::Resize(int w, int h)
|
|||
void D3DRenderer::renderFramebuffer()
|
||||
{
|
||||
devCache.SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
device->ColorFill(backbuffer, 0, D3DCOLOR_ARGB(255, VO_BORDER_COL.Red, VO_BORDER_COL.Green, VO_BORDER_COL.Blue));
|
||||
device->ColorFill(backbuffer, 0, D3DCOLOR_ARGB(255, VO_BORDER_COL._red, VO_BORDER_COL._green, VO_BORDER_COL._blue));
|
||||
int fx = 0;
|
||||
int sx = 0;
|
||||
float screenAR = (float)settings.display.width / settings.display.height;
|
||||
|
|
|
@ -134,7 +134,7 @@ static void SetGPState(const PolyParam* gp)
|
|||
{
|
||||
// Two volumes mode only supported for OP and PT
|
||||
bool two_volumes_mode = (gp->tsp1.full != (u32)-1) && Type != ListType_Translucent;
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
|
||||
int fog_ctrl = config::Fog ? gp->tsp.FogCtrl : 2;
|
||||
gpuPalette = gp->texture != nullptr ? gp->texture->gpuPalette : false;
|
||||
|
|
|
@ -725,28 +725,14 @@ static bool RenderFrame(int width, int height)
|
|||
resize(rendering_width, rendering_height);
|
||||
|
||||
//VERT and RAM fog color constants
|
||||
u8* fog_colvert_bgra=(u8*)&FOG_COL_VERT;
|
||||
u8* fog_colram_bgra=(u8*)&FOG_COL_RAM;
|
||||
gl4ShaderUniforms.ps_FOG_COL_VERT[0]=fog_colvert_bgra[2]/255.0f;
|
||||
gl4ShaderUniforms.ps_FOG_COL_VERT[1]=fog_colvert_bgra[1]/255.0f;
|
||||
gl4ShaderUniforms.ps_FOG_COL_VERT[2]=fog_colvert_bgra[0]/255.0f;
|
||||
|
||||
gl4ShaderUniforms.ps_FOG_COL_RAM[0]=fog_colram_bgra [2]/255.0f;
|
||||
gl4ShaderUniforms.ps_FOG_COL_RAM[1]=fog_colram_bgra [1]/255.0f;
|
||||
gl4ShaderUniforms.ps_FOG_COL_RAM[2]=fog_colram_bgra [0]/255.0f;
|
||||
FOG_COL_VERT.getRGBColor(gl4ShaderUniforms.ps_FOG_COL_VERT);
|
||||
FOG_COL_RAM.getRGBColor(gl4ShaderUniforms.ps_FOG_COL_RAM);
|
||||
|
||||
//Fog density constant
|
||||
gl4ShaderUniforms.fog_den_float = FOG_DENSITY.get() * config::ExtraDepthScale;
|
||||
|
||||
gl4ShaderUniforms.fog_clamp_min[0] = ((pvrrc.fog_clamp_min >> 16) & 0xFF) / 255.0f;
|
||||
gl4ShaderUniforms.fog_clamp_min[1] = ((pvrrc.fog_clamp_min >> 8) & 0xFF) / 255.0f;
|
||||
gl4ShaderUniforms.fog_clamp_min[2] = ((pvrrc.fog_clamp_min >> 0) & 0xFF) / 255.0f;
|
||||
gl4ShaderUniforms.fog_clamp_min[3] = ((pvrrc.fog_clamp_min >> 24) & 0xFF) / 255.0f;
|
||||
|
||||
gl4ShaderUniforms.fog_clamp_max[0] = ((pvrrc.fog_clamp_max >> 16) & 0xFF) / 255.0f;
|
||||
gl4ShaderUniforms.fog_clamp_max[1] = ((pvrrc.fog_clamp_max >> 8) & 0xFF) / 255.0f;
|
||||
gl4ShaderUniforms.fog_clamp_max[2] = ((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f;
|
||||
gl4ShaderUniforms.fog_clamp_max[3] = ((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f;
|
||||
pvrrc.fog_clamp_min.getRGBAColor(gl4ShaderUniforms.fog_clamp_min);
|
||||
pvrrc.fog_clamp_max.getRGBAColor(gl4ShaderUniforms.fog_clamp_max);
|
||||
|
||||
glcache.UseProgram(gl4.modvol_shader.program);
|
||||
|
||||
|
@ -778,7 +764,7 @@ static bool RenderFrame(int width, int height)
|
|||
|
||||
glcache.Disable(GL_SCISSOR_TEST);
|
||||
if (!is_rtt)
|
||||
glcache.ClearColor(VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f);
|
||||
glcache.ClearColor(VO_BORDER_COL.red(), VO_BORDER_COL.green(), VO_BORDER_COL.blue(), 1.f);
|
||||
|
||||
if (!is_rtt && (FB_R_CTRL.fb_enable == 0 || VO_CONTROL.blank_video == 1))
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ __forceinline
|
|||
else
|
||||
ShaderUniforms.trilinear_alpha = 1.f;
|
||||
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
bool color_clamp = gp->tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
int fog_ctrl = config::Fog ? gp->tsp.FogCtrl : 2;
|
||||
|
||||
int clip_rect[4] = {};
|
||||
|
@ -703,7 +703,7 @@ bool render_output_framebuffer()
|
|||
else
|
||||
glViewport(-fx, 0, settings.display.width + fx * 2, settings.display.height);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, gl.ofbo.origFbo);
|
||||
glcache.ClearColor(VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f);
|
||||
glcache.ClearColor(VO_BORDER_COL.red(), VO_BORDER_COL.green(), VO_BORDER_COL.blue(), 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
drawQuad(gl.ofbo.tex, config::Rotate90);
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ bool render_output_framebuffer()
|
|||
return false;
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, gl.ofbo.fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gl.ofbo.origFbo);
|
||||
glcache.ClearColor(VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f);
|
||||
glcache.ClearColor(VO_BORDER_COL.red(), VO_BORDER_COL.green(), VO_BORDER_COL.blue(), 1.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBlitFramebuffer(fx, 0, gl.ofbo.width - fx, gl.ofbo.height,
|
||||
sx, 0, settings.display.width - sx, settings.display.height,
|
||||
|
|
|
@ -1180,28 +1180,14 @@ bool RenderFrame(int width, int height)
|
|||
ShaderUniforms.depth_coefs[3] = 0;
|
||||
|
||||
//VERT and RAM fog color constants
|
||||
u8* fog_colvert_bgra = (u8*)&FOG_COL_VERT;
|
||||
u8* fog_colram_bgra = (u8*)&FOG_COL_RAM;
|
||||
ShaderUniforms.ps_FOG_COL_VERT[0] = fog_colvert_bgra[2] / 255.0f;
|
||||
ShaderUniforms.ps_FOG_COL_VERT[1] = fog_colvert_bgra[1] / 255.0f;
|
||||
ShaderUniforms.ps_FOG_COL_VERT[2] = fog_colvert_bgra[0] / 255.0f;
|
||||
|
||||
ShaderUniforms.ps_FOG_COL_RAM[0] = fog_colram_bgra[2] / 255.0f;
|
||||
ShaderUniforms.ps_FOG_COL_RAM[1] = fog_colram_bgra[1] / 255.0f;
|
||||
ShaderUniforms.ps_FOG_COL_RAM[2] = fog_colram_bgra[0] / 255.0f;
|
||||
FOG_COL_VERT.getRGBColor(ShaderUniforms.ps_FOG_COL_VERT);
|
||||
FOG_COL_RAM.getRGBColor(ShaderUniforms.ps_FOG_COL_RAM);
|
||||
|
||||
//Fog density constant
|
||||
ShaderUniforms.fog_den_float = FOG_DENSITY.get() * config::ExtraDepthScale;
|
||||
|
||||
ShaderUniforms.fog_clamp_min[0] = ((pvrrc.fog_clamp_min >> 16) & 0xFF) / 255.0f;
|
||||
ShaderUniforms.fog_clamp_min[1] = ((pvrrc.fog_clamp_min >> 8) & 0xFF) / 255.0f;
|
||||
ShaderUniforms.fog_clamp_min[2] = ((pvrrc.fog_clamp_min >> 0) & 0xFF) / 255.0f;
|
||||
ShaderUniforms.fog_clamp_min[3] = ((pvrrc.fog_clamp_min >> 24) & 0xFF) / 255.0f;
|
||||
|
||||
ShaderUniforms.fog_clamp_max[0] = ((pvrrc.fog_clamp_max >> 16) & 0xFF) / 255.0f;
|
||||
ShaderUniforms.fog_clamp_max[1] = ((pvrrc.fog_clamp_max >> 8) & 0xFF) / 255.0f;
|
||||
ShaderUniforms.fog_clamp_max[2] = ((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f;
|
||||
ShaderUniforms.fog_clamp_max[3] = ((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f;
|
||||
pvrrc.fog_clamp_min.getRGBAColor(ShaderUniforms.fog_clamp_min);
|
||||
pvrrc.fog_clamp_max.getRGBAColor(ShaderUniforms.fog_clamp_max);
|
||||
|
||||
glcache.UseProgram(gl.modvol_shader.program);
|
||||
|
||||
|
@ -1257,7 +1243,7 @@ bool RenderFrame(int width, int height)
|
|||
glClearStencil(0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glCheck();
|
||||
if (!is_rtt)
|
||||
glcache.ClearColor(VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f);
|
||||
glcache.ClearColor(VO_BORDER_COL.red(), VO_BORDER_COL.green(), VO_BORDER_COL.blue(), 1.f);
|
||||
|
||||
if (!is_rtt && (FB_R_CTRL.fb_enable == 0 || VO_CONTROL.blank_video == 1))
|
||||
{
|
||||
|
|
|
@ -62,28 +62,14 @@ protected:
|
|||
T fragUniforms;
|
||||
|
||||
//VERT and RAM fog color constants
|
||||
u8* fog_colvert_bgra = (u8*)&FOG_COL_VERT;
|
||||
u8* fog_colram_bgra = (u8*)&FOG_COL_RAM;
|
||||
fragUniforms.sp_FOG_COL_VERT[0] = fog_colvert_bgra[2] / 255.0f;
|
||||
fragUniforms.sp_FOG_COL_VERT[1] = fog_colvert_bgra[1] / 255.0f;
|
||||
fragUniforms.sp_FOG_COL_VERT[2] = fog_colvert_bgra[0] / 255.0f;
|
||||
|
||||
fragUniforms.sp_FOG_COL_RAM[0] = fog_colram_bgra[2] / 255.0f;
|
||||
fragUniforms.sp_FOG_COL_RAM[1] = fog_colram_bgra[1] / 255.0f;
|
||||
fragUniforms.sp_FOG_COL_RAM[2] = fog_colram_bgra[0] / 255.0f;
|
||||
FOG_COL_VERT.getRGBColor(fragUniforms.sp_FOG_COL_VERT);
|
||||
FOG_COL_RAM.getRGBColor(fragUniforms.sp_FOG_COL_RAM);
|
||||
|
||||
//Fog density constant
|
||||
fragUniforms.sp_FOG_DENSITY = FOG_DENSITY.get() * config::ExtraDepthScale;
|
||||
|
||||
fragUniforms.colorClampMin[0] = ((pvrrc.fog_clamp_min >> 16) & 0xFF) / 255.0f;
|
||||
fragUniforms.colorClampMin[1] = ((pvrrc.fog_clamp_min >> 8) & 0xFF) / 255.0f;
|
||||
fragUniforms.colorClampMin[2] = ((pvrrc.fog_clamp_min >> 0) & 0xFF) / 255.0f;
|
||||
fragUniforms.colorClampMin[3] = ((pvrrc.fog_clamp_min >> 24) & 0xFF) / 255.0f;
|
||||
|
||||
fragUniforms.colorClampMax[0] = ((pvrrc.fog_clamp_max >> 16) & 0xFF) / 255.0f;
|
||||
fragUniforms.colorClampMax[1] = ((pvrrc.fog_clamp_max >> 8) & 0xFF) / 255.0f;
|
||||
fragUniforms.colorClampMax[2] = ((pvrrc.fog_clamp_max >> 0) & 0xFF) / 255.0f;
|
||||
fragUniforms.colorClampMax[3] = ((pvrrc.fog_clamp_max >> 24) & 0xFF) / 255.0f;
|
||||
pvrrc.fog_clamp_min.getRGBAColor(fragUniforms.colorClampMin);
|
||||
pvrrc.fog_clamp_max.getRGBAColor(fragUniforms.colorClampMax);
|
||||
|
||||
fragUniforms.cp_AlphaTestValue = (PT_ALPHA_REF & 0xFF) / 255.0f;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void OITPipelineManager::CreatePipeline(u32 listType, bool autosort, const PolyP
|
|||
OITShaderManager::FragmentShaderParams params = {};
|
||||
params.alphaTest = listType == ListType_Punch_Through;
|
||||
params.bumpmap = pp.tcw.PixelFmt == PixelBumpMap;
|
||||
params.clamping = pp.tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
params.clamping = pp.tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
params.insideClipTest = (pp.tileclip >> 28) == 3;
|
||||
params.fog = config::Fog ? pp.tsp.FogCtrl : 2;
|
||||
params.gouraud = pp.pcw.Gouraud;
|
||||
|
|
|
@ -29,6 +29,29 @@
|
|||
|
||||
VulkanOverlay::~VulkanOverlay() = default;
|
||||
|
||||
void VulkanOverlay::Init(QuadPipeline *pipeline)
|
||||
{
|
||||
this->pipeline = pipeline;
|
||||
for (auto& drawer : drawers)
|
||||
{
|
||||
drawer = std::unique_ptr<QuadDrawer>(new QuadDrawer());
|
||||
drawer->Init(pipeline);
|
||||
}
|
||||
xhairDrawer = std::unique_ptr<QuadDrawer>(new QuadDrawer());
|
||||
xhairDrawer->Init(pipeline);
|
||||
}
|
||||
|
||||
void VulkanOverlay::Term()
|
||||
{
|
||||
commandBuffers.clear();
|
||||
for (auto& drawer : drawers)
|
||||
drawer.reset();
|
||||
xhairDrawer.reset();
|
||||
for (auto& tex : vmuTextures)
|
||||
tex.reset();
|
||||
xhairTexture.reset();
|
||||
}
|
||||
|
||||
std::unique_ptr<Texture> VulkanOverlay::createTexture(vk::CommandBuffer commandBuffer, int width, int height, u8 *data)
|
||||
{
|
||||
VulkanContext *context = VulkanContext::Instance();
|
||||
|
|
|
@ -33,25 +33,8 @@ class VulkanOverlay
|
|||
public:
|
||||
~VulkanOverlay();
|
||||
|
||||
void Init(QuadPipeline *pipeline)
|
||||
{
|
||||
this->pipeline = pipeline;
|
||||
for (auto& drawer : drawers)
|
||||
{
|
||||
drawer = std::unique_ptr<QuadDrawer>(new QuadDrawer());
|
||||
drawer->Init(pipeline);
|
||||
}
|
||||
xhairDrawer = std::unique_ptr<QuadDrawer>(new QuadDrawer());
|
||||
xhairDrawer->Init(pipeline);
|
||||
}
|
||||
|
||||
void Term()
|
||||
{
|
||||
commandBuffers.clear();
|
||||
for (auto& drawer : drawers)
|
||||
drawer.reset();
|
||||
xhairDrawer.reset();
|
||||
}
|
||||
void Init(QuadPipeline *pipeline);
|
||||
void Term();
|
||||
|
||||
vk::CommandBuffer Prepare(vk::CommandPool commandPool, bool vmu, bool crosshair, TextureCache& textureCache);
|
||||
void Prepare(vk::CommandBuffer commandBuffer, bool vmu, bool crosshair, TextureCache& textureCache);
|
||||
|
|
|
@ -396,7 +396,7 @@ void PipelineManager::CreatePipeline(u32 listType, bool sortTriangles, const Pol
|
|||
FragmentShaderParams params = {};
|
||||
params.alphaTest = listType == ListType_Punch_Through;
|
||||
params.bumpmap = pp.tcw.PixelFmt == PixelBumpMap;
|
||||
params.clamping = pp.tsp.ColorClamp && (pvrrc.fog_clamp_min != 0 || pvrrc.fog_clamp_max != 0xffffffff);
|
||||
params.clamping = pp.tsp.ColorClamp && (pvrrc.fog_clamp_min.full != 0 || pvrrc.fog_clamp_max.full != 0xffffffff);
|
||||
params.insideClipTest = (pp.tileclip >> 28) == 3;
|
||||
params.fog = config::Fog ? pp.tsp.FogCtrl : 2;
|
||||
params.gouraud = pp.pcw.Gouraud;
|
||||
|
|
|
@ -94,5 +94,5 @@ public:
|
|||
|
||||
|
||||
static inline vk::ClearColorValue getBorderColor() {
|
||||
return vk::ClearColorValue(std::array<float, 4>{ VO_BORDER_COL.Red / 255.f, VO_BORDER_COL.Green / 255.f, VO_BORDER_COL.Blue / 255.f, 1.f });
|
||||
return vk::ClearColorValue(std::array<float, 4>{ VO_BORDER_COL.red(), VO_BORDER_COL.green(), VO_BORDER_COL.blue(), 1.f });
|
||||
}
|
||||
|
|
|
@ -952,6 +952,7 @@ void VulkanContext::term()
|
|||
}
|
||||
}
|
||||
overlay.reset();
|
||||
textureCache.reset();
|
||||
ShaderCompiler::Term();
|
||||
swapChain.reset();
|
||||
imageViews.clear();
|
||||
|
|
Loading…
Reference in New Issue