mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix the raster depth blit again, which I recently broke.
This commit is contained in:
parent
a7e388168d
commit
bd6f79e473
4 changed files with 29 additions and 20 deletions
|
@ -665,7 +665,7 @@ D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, ID
|
|||
caps_.tesselationShaderSupported = false;
|
||||
caps_.framebufferBlitSupported = true;
|
||||
caps_.framebufferCopySupported = false;
|
||||
caps_.framebufferDepthBlitSupported = true;
|
||||
caps_.framebufferDepthBlitSupported = false;
|
||||
caps_.framebufferStencilBlitSupported = false;
|
||||
caps_.framebufferDepthCopySupported = false;
|
||||
caps_.framebufferSeparateDepthCopySupported = false;
|
||||
|
|
|
@ -39,19 +39,23 @@ static const SamplerDef samplers[1] = {
|
|||
{ "tex" },
|
||||
};
|
||||
|
||||
void GenerateDraw2DFs(ShaderWriter &writer) {
|
||||
RasterChannel GenerateDraw2DFs(ShaderWriter &writer) {
|
||||
writer.DeclareSamplers(samplers);
|
||||
writer.BeginFSMain(Slice<UniformDef>::empty(), varyings, FSFLAG_NONE);
|
||||
writer.C(" vec4 outColor = ").SampleTexture2D("tex", "v_texcoord.xy").C(";\n");
|
||||
writer.EndFSMain("outColor", FSFLAG_NONE);
|
||||
|
||||
return RASTER_COLOR;
|
||||
}
|
||||
|
||||
void GenerateDraw2DDepthFs(ShaderWriter &writer) {
|
||||
RasterChannel GenerateDraw2DDepthFs(ShaderWriter &writer) {
|
||||
writer.DeclareSamplers(samplers);
|
||||
writer.BeginFSMain(Slice<UniformDef>::empty(), varyings, FSFLAG_WRITEDEPTH);
|
||||
writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n");
|
||||
writer.C(" gl_FragDepth = ").SampleTexture2D("tex", "v_texcoord.xy").C(".x;\n");
|
||||
writer.EndFSMain("outColor", FSFLAG_WRITEDEPTH);
|
||||
|
||||
return RASTER_DEPTH;
|
||||
}
|
||||
|
||||
void GenerateDraw2DVS(ShaderWriter &writer) {
|
||||
|
@ -98,13 +102,13 @@ void FramebufferManagerCommon::Ensure2DResources() {
|
|||
}
|
||||
}
|
||||
|
||||
Draw::Pipeline *FramebufferManagerCommon::Create2DPipeline(void (*generate)(ShaderWriter &)) {
|
||||
Draw::Pipeline *FramebufferManagerCommon::Create2DPipeline(RasterChannel (*generate)(ShaderWriter &)) {
|
||||
using namespace Draw;
|
||||
const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc();
|
||||
|
||||
char *fsCode = new char[4000];
|
||||
ShaderWriter writer(fsCode, shaderLanguageDesc, ShaderStage::Fragment);
|
||||
generate(writer);
|
||||
RasterChannel channel = generate(writer);
|
||||
|
||||
ShaderModule *fs = draw_->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)fsCode, strlen(fsCode), "draw2d_fs");
|
||||
delete[] fsCode;
|
||||
|
@ -123,22 +127,24 @@ Draw::Pipeline *FramebufferManagerCommon::Create2DPipeline(void (*generate)(Shad
|
|||
};
|
||||
InputLayout *inputLayout = draw_->CreateInputLayout(desc);
|
||||
|
||||
BlendState *blendOff = draw_->CreateBlendState({ false, 0xF });
|
||||
BlendState *blendDiscard = draw_->CreateBlendState({ false, 0x0 });
|
||||
BlendState *blend = draw_->CreateBlendState({ false, channel == RASTER_COLOR ? 0xF : 0 });
|
||||
|
||||
DepthStencilState *noDepthStencil = draw_->CreateDepthStencilState(DepthStencilStateDesc{});
|
||||
DepthStencilStateDesc dsDesc{};
|
||||
if (channel == RASTER_DEPTH) {
|
||||
dsDesc.depthTestEnabled = true;
|
||||
dsDesc.depthWriteEnabled = true;
|
||||
dsDesc.depthCompare = Draw::Comparison::ALWAYS;
|
||||
}
|
||||
|
||||
DepthStencilState *depthStencil = draw_->CreateDepthStencilState(dsDesc);
|
||||
RasterState *rasterNoCull = draw_->CreateRasterState({});
|
||||
|
||||
DepthStencilStateDesc dsWriteDesc{};
|
||||
dsWriteDesc.depthTestEnabled = true;
|
||||
dsWriteDesc.depthWriteEnabled = true;
|
||||
dsWriteDesc.depthCompare = Draw::Comparison::ALWAYS;
|
||||
DepthStencilState *depthWriteAlways = draw_->CreateDepthStencilState(dsWriteDesc);
|
||||
|
||||
PipelineDesc pipelineDesc{
|
||||
Primitive::TRIANGLE_STRIP,
|
||||
{ draw2DVs_, fs },
|
||||
inputLayout, noDepthStencil, blendOff, rasterNoCull, nullptr,
|
||||
inputLayout,
|
||||
depthStencil,
|
||||
blend, rasterNoCull, nullptr,
|
||||
};
|
||||
|
||||
Draw::Pipeline *pipeline = draw_->CreateGraphicsPipeline(pipelineDesc);
|
||||
|
@ -146,10 +152,8 @@ Draw::Pipeline *FramebufferManagerCommon::Create2DPipeline(void (*generate)(Shad
|
|||
fs->Release();
|
||||
|
||||
rasterNoCull->Release();
|
||||
blendOff->Release();
|
||||
blendDiscard->Release();
|
||||
noDepthStencil->Release();
|
||||
depthWriteAlways->Release();
|
||||
blend->Release();
|
||||
depthStencil->Release();
|
||||
inputLayout->Release();
|
||||
|
||||
return pipeline;
|
||||
|
|
|
@ -348,6 +348,9 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(const Frame
|
|||
break;
|
||||
}
|
||||
} else if (params.fb_address > v->fb_address && params.fb_address < v_fb_end_ptr && PSP_CoreParameter().compat.flags().AllowLargeFBTextureOffsets) {
|
||||
// Fixes Juiced 2, though causes a lot of copying due to self-texturing. A better solution
|
||||
// would be to copy from the overlapping framebuffer on bind.
|
||||
|
||||
if (params.fb_address % params.fb_stride == v->fb_address % params.fb_stride) {
|
||||
// Framebuffers are overlapping on the Y axis.
|
||||
const int y_offset = (params.fb_address - v->fb_address) / (bpp * params.fb_stride);
|
||||
|
@ -2432,6 +2435,7 @@ void FramebufferManagerCommon::BlitFramebuffer(VirtualFramebuffer *dst, int dstX
|
|||
float srcYFactor = src->renderScaleFactor;
|
||||
const int srcBpp = src->format == GE_FORMAT_8888 ? 4 : 2;
|
||||
if (srcBpp != bpp && bpp != 0) {
|
||||
// If we do this, we're kinda in nonsense territory since the actual formats won't match (unless intentionally blitting black or white).
|
||||
srcXFactor = (srcXFactor * bpp) / srcBpp;
|
||||
}
|
||||
int srcX1 = srcX * srcXFactor;
|
||||
|
@ -2443,6 +2447,7 @@ void FramebufferManagerCommon::BlitFramebuffer(VirtualFramebuffer *dst, int dstX
|
|||
float dstYFactor = dst->renderScaleFactor;
|
||||
const int dstBpp = dst->format == GE_FORMAT_8888 ? 4 : 2;
|
||||
if (dstBpp != bpp && bpp != 0) {
|
||||
// If we do this, we're kinda in nonsense territory since the actual formats won't match (unless intentionally blitting black or white).
|
||||
dstXFactor = (dstXFactor * bpp) / dstBpp;
|
||||
}
|
||||
int dstX1 = dstX * dstXFactor;
|
||||
|
|
|
@ -382,7 +382,7 @@ protected:
|
|||
|
||||
void DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, RasterChannel channel);
|
||||
void Ensure2DResources();
|
||||
Draw::Pipeline *Create2DPipeline(void (*generate)(ShaderWriter &));
|
||||
Draw::Pipeline *Create2DPipeline(RasterChannel (*generate)(ShaderWriter &));
|
||||
|
||||
bool UpdateSize();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue