mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-21 14:41:39 +00:00
Use a DX9-compatible method to pass texwidth and height. the effect doesn't work on DX9 yet though.
This commit is contained in:
parent
ca24f1b9aa
commit
9cc8cfaa08
@ -40,6 +40,20 @@ static const SamplerDef samplers[1] = {
|
||||
{ "tex" },
|
||||
};
|
||||
|
||||
static const UniformDef uniforms[1] = {
|
||||
{ "vec2", "texSize", 0 },
|
||||
};
|
||||
|
||||
struct Draw2DUB {
|
||||
float texSizeX;
|
||||
float texSizeY;
|
||||
};
|
||||
|
||||
const UniformBufferDesc draw2DUBDesc{ sizeof(Draw2DUB), {
|
||||
{ "texSize", -1, 0, UniformType::FLOAT2, 0 },
|
||||
} };
|
||||
|
||||
|
||||
RasterChannel GenerateDraw2DFs(ShaderWriter &writer) {
|
||||
writer.DeclareSamplers(samplers);
|
||||
writer.BeginFSMain(Slice<UniformDef>::empty(), varyings, FSFLAG_NONE);
|
||||
@ -79,12 +93,12 @@ static float g_scale;
|
||||
|
||||
RasterChannel GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) {
|
||||
writer.DeclareSamplers(samplers);
|
||||
writer.BeginFSMain(Slice<UniformDef>::empty(), varyings, FSFLAG_WRITEDEPTH);
|
||||
writer.BeginFSMain(uniforms, varyings, FSFLAG_WRITEDEPTH);
|
||||
writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n");
|
||||
// Unlike when just copying a depth buffer, here we're generating new depth values so we'll
|
||||
// have to apply the scaling.
|
||||
DepthScaleFactors factors = GetDepthScaleFactors();
|
||||
writer.GetTextureSize("tsize", "tex").C("\n");
|
||||
writer.C(" vec2 tsize = texSize;\n");
|
||||
writer.C(" vec2 coord = v_texcoord * tsize;\n");
|
||||
writer.F(" float strip = 4.0 * %f;\n", g_scale);
|
||||
writer.C(" float in_strip = mod(coord.y, strip);\n");
|
||||
@ -183,7 +197,7 @@ Draw::Pipeline *FramebufferManagerCommon::Create2DPipeline(RasterChannel (*gener
|
||||
{ draw2DVs_, fs },
|
||||
inputLayout,
|
||||
depthStencil,
|
||||
blend, rasterNoCull, nullptr,
|
||||
blend, rasterNoCull, &draw2DUBDesc,
|
||||
};
|
||||
|
||||
Draw::Pipeline *pipeline = draw_->CreateGraphicsPipeline(pipelineDesc);
|
||||
@ -198,7 +212,7 @@ Draw::Pipeline *FramebufferManagerCommon::Create2DPipeline(RasterChannel (*gener
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DShader shader) {
|
||||
void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DShader shader, float texW, float texH) {
|
||||
using namespace Draw;
|
||||
|
||||
Ensure2DResources();
|
||||
@ -251,6 +265,11 @@ void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *ver
|
||||
break;
|
||||
}
|
||||
|
||||
Draw2DUB ub;
|
||||
ub.texSizeX = tex ? tex->Width() : texW;
|
||||
ub.texSizeY = tex ? tex->Height() : texH;
|
||||
draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub));
|
||||
|
||||
if (tex) {
|
||||
draw_->BindTextures(TEX_SLOT_PSP_TEXTURE, 1, &tex);
|
||||
}
|
||||
|
@ -2566,7 +2566,7 @@ void FramebufferManagerCommon::BlitUsingRaster(
|
||||
Draw::Viewport vp{ 0.0f, 0.0f, (float)dest->Width(), (float)dest->Height(), 0.0f, 1.0f };
|
||||
draw_->SetViewports(1, &vp);
|
||||
draw_->SetScissorRect(0, 0, (int)dest->Width(), (int)dest->Height());
|
||||
DrawStrip2D(nullptr, vtx, 4, linearFilter, shader);
|
||||
DrawStrip2D(nullptr, vtx, 4, linearFilter, shader, src->Width(), src->Height());
|
||||
|
||||
gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ protected:
|
||||
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 DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DShader channel);
|
||||
void DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DShader channel, float texW = 0.0f, float texH = 0.0f);
|
||||
void Ensure2DResources();
|
||||
Draw::Pipeline *Create2DPipeline(RasterChannel (*generate)(ShaderWriter &));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user