mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Extract function GetReinterpretPipeline
This commit is contained in:
parent
dab38f7261
commit
39890f7d6f
@ -777,30 +777,17 @@ void FramebufferManagerCommon::CopyToColorFromOverlappingFramebuffers(VirtualFra
|
|||||||
WARN_LOG_ONCE(bta, G3D, "WARNING: Reinterpret encountered with BlueToAlpha on");
|
WARN_LOG_ONCE(bta, G3D, "WARNING: Reinterpret encountered with BlueToAlpha on");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBufferFormat16Bit(src->fb_format) && !IsBufferFormat16Bit(dst->fb_format)) {
|
|
||||||
// We halve the X coordinates in the destination framebuffer.
|
|
||||||
// The shader will collect two pixels worth of input data and merge into one.
|
|
||||||
dstX1 *= 0.5f;
|
|
||||||
dstX2 *= 0.5f;
|
|
||||||
} else if (!IsBufferFormat16Bit(src->fb_format) && IsBufferFormat16Bit(dst->fb_format)) {
|
|
||||||
// We double the X coordinates in the destination framebuffer.
|
|
||||||
// The shader will sample and depending on the X coordinate & 1, use the upper or lower bits.
|
|
||||||
dstX1 *= 2.0f;
|
|
||||||
dstX2 *= 2.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reinterpret!
|
// Reinterpret!
|
||||||
WARN_LOG_N_TIMES(reint, 5, G3D, "Reinterpret detected from %08x_%s to %08x_%s",
|
WARN_LOG_N_TIMES(reint, 5, G3D, "Reinterpret detected from %08x_%s to %08x_%s",
|
||||||
src->fb_address, GeBufferFormatToString(src->fb_format),
|
src->fb_address, GeBufferFormatToString(src->fb_format),
|
||||||
dst->fb_address, GeBufferFormatToString(dst->fb_format));
|
dst->fb_address, GeBufferFormatToString(dst->fb_format));
|
||||||
pipeline = reinterpretFromTo_[(int)src->fb_format][(int)dst->fb_format];
|
|
||||||
|
float scaleFactorX = 1.0f;
|
||||||
|
pipeline = GetReinterpretPipeline(src->fb_format, dst->fb_format, &scaleFactorX);
|
||||||
|
dstX1 *= 0.5f;
|
||||||
|
dstX2 *= 0.5f;
|
||||||
|
|
||||||
pass_name = reinterpretStrings[(int)src->fb_format][(int)dst->fb_format];
|
pass_name = reinterpretStrings[(int)src->fb_format][(int)dst->fb_format];
|
||||||
if (!pipeline) {
|
|
||||||
pipeline = draw2D_.Create2DPipeline([=](ShaderWriter &shaderWriter) -> Draw2DPipelineInfo {
|
|
||||||
return GenerateReinterpretFragmentShader(shaderWriter, src->fb_format, dst->fb_format);
|
|
||||||
});
|
|
||||||
reinterpretFromTo_[(int)src->fb_format][(int)dst->fb_format] = pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
gpuStats.numReinterpretCopies++;
|
gpuStats.numReinterpretCopies++;
|
||||||
}
|
}
|
||||||
@ -823,6 +810,27 @@ void FramebufferManagerCommon::CopyToColorFromOverlappingFramebuffers(VirtualFra
|
|||||||
textureCache_->ForgetLastTexture();
|
textureCache_->ForgetLastTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw2DPipeline *FramebufferManagerCommon::GetReinterpretPipeline(GEBufferFormat from, GEBufferFormat to, float *scaleFactorX) {
|
||||||
|
if (IsBufferFormat16Bit(from) && !IsBufferFormat16Bit(to)) {
|
||||||
|
// We halve the X coordinates in the destination framebuffer.
|
||||||
|
// The shader will collect two pixels worth of input data and merge into one.
|
||||||
|
*scaleFactorX = 0.5f;
|
||||||
|
} else if (!IsBufferFormat16Bit(from) && IsBufferFormat16Bit(to)) {
|
||||||
|
// We double the X coordinates in the destination framebuffer.
|
||||||
|
// The shader will sample and depending on the X coordinate & 1, use the upper or lower bits.
|
||||||
|
*scaleFactorX = 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw2DPipeline *pipeline = reinterpretFromTo_[(int)from][(int)to];
|
||||||
|
if (!pipeline) {
|
||||||
|
pipeline = draw2D_.Create2DPipeline([=](ShaderWriter &shaderWriter) -> Draw2DPipelineInfo {
|
||||||
|
return GenerateReinterpretFragmentShader(shaderWriter, from, to);
|
||||||
|
});
|
||||||
|
reinterpretFromTo_[(int)from][(int)to] = pipeline;
|
||||||
|
}
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
void FramebufferManagerCommon::DestroyFramebuf(VirtualFramebuffer *v) {
|
void FramebufferManagerCommon::DestroyFramebuf(VirtualFramebuffer *v) {
|
||||||
// Notify the texture cache of both the color and depth buffers.
|
// Notify the texture cache of both the color and depth buffers.
|
||||||
textureCache_->NotifyFramebuffer(v, NOTIFY_FB_DESTROYED);
|
textureCache_->NotifyFramebuffer(v, NOTIFY_FB_DESTROYED);
|
||||||
|
@ -421,14 +421,15 @@ public:
|
|||||||
// Returns the resolved framebuffer.
|
// Returns the resolved framebuffer.
|
||||||
VirtualFramebuffer *ResolveFramebufferColorToFormat(VirtualFramebuffer *vfb, GEBufferFormat newFormat);
|
VirtualFramebuffer *ResolveFramebufferColorToFormat(VirtualFramebuffer *vfb, GEBufferFormat newFormat);
|
||||||
|
|
||||||
|
Draw2DPipeline *Get2DPipeline(Draw2DShader shader);
|
||||||
|
Draw2DPipeline *GetReinterpretPipeline(GEBufferFormat from, GEBufferFormat to, float *scaleFactorX);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel);
|
virtual void PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel);
|
||||||
void SetViewport2D(int x, int y, int w, int h);
|
void SetViewport2D(int x, int y, int w, int h);
|
||||||
Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height);
|
Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height);
|
||||||
void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags);
|
void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags);
|
||||||
|
|
||||||
Draw2DPipeline *Get2DPipeline(Draw2DShader shader);
|
|
||||||
|
|
||||||
void CopyToColorFromOverlappingFramebuffers(VirtualFramebuffer *dest);
|
void CopyToColorFromOverlappingFramebuffers(VirtualFramebuffer *dest);
|
||||||
void CopyToDepthFromOverlappingFramebuffers(VirtualFramebuffer *dest);
|
void CopyToDepthFromOverlappingFramebuffers(VirtualFramebuffer *dest);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user