Skip to content

Commit

Permalink
Address more feedback, cleanup scale parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Aug 21, 2022
1 parent 80772dd commit 8e7cf59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
18 changes: 9 additions & 9 deletions GPU/Common/Draw2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ static const SamplerDef samplers[1] = {
{ "tex" },
};

static const UniformDef uniforms[1] = {
static const UniformDef uniforms[2] = {
{ "vec2", "texSize", 0 },
{ "float", "scaleFactor", 1},
};

struct Draw2DUB {
float texSizeX;
float texSizeY;
float scaleFactor;
};

const UniformBufferDesc draw2DUBDesc{ sizeof(Draw2DUB), {
{ "texSize", -1, 0, UniformType::FLOAT2, 0 },
{ "scaleFactor", -1, 1, UniformType::FLOAT1, 0 },
} };


Expand Down Expand Up @@ -88,9 +91,6 @@ RasterChannel GenerateDraw2D565ToDepthFs(ShaderWriter &writer) {
return RASTER_DEPTH;
}

// ugly way to get the scale into the function
static float g_scale;

RasterChannel GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) {
writer.DeclareSamplers(samplers);
writer.BeginFSMain(uniforms, varyings, FSFLAG_WRITEDEPTH);
Expand All @@ -100,7 +100,7 @@ RasterChannel GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) {
DepthScaleFactors factors = GetDepthScaleFactors();
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.F(" float strip = 4.0 * scaleFactor;\n");
writer.C(" float in_strip = mod(coord.y, strip);\n");
writer.C(" coord.y = coord.y - in_strip + strip - in_strip;\n");
writer.C(" coord /= tsize;\n");
Expand Down Expand Up @@ -234,8 +234,8 @@ void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *ver
}
if (!draw2DPipelineDepth_) {
draw2DPipelineDepth_ = Create2DPipeline(&GenerateDraw2DDepthFs);
linearFilter = false;
}
linearFilter = false;
draw_->BindPipeline(draw2DPipelineDepth_);
break;

Expand All @@ -246,8 +246,8 @@ void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *ver
}
if (!draw2DPipeline565ToDepth_) {
draw2DPipeline565ToDepth_ = Create2DPipeline(&GenerateDraw2D565ToDepthFs);
linearFilter = false;
}
linearFilter = false;
draw_->BindPipeline(draw2DPipeline565ToDepth_);
break;

Expand All @@ -257,17 +257,17 @@ void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *ver
return;
}
if (!draw2DPipeline565ToDepthDeswizzle_) {
g_scale = renderScaleFactor_;
draw2DPipeline565ToDepthDeswizzle_ = Create2DPipeline(&GenerateDraw2D565ToDepthDeswizzleFs);
linearFilter = false;
}
linearFilter = false;
draw_->BindPipeline(draw2DPipeline565ToDepthDeswizzle_);
break;
}

Draw2DUB ub;
ub.texSizeX = tex ? tex->Width() : texW;
ub.texSizeY = tex ? tex->Height() : texH;
ub.scaleFactor = (float)renderScaleFactor_;
draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub));

if (tex) {
Expand Down
7 changes: 0 additions & 7 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,13 +1908,6 @@ void FramebufferManagerCommon::Resized() {
// Might have a new post shader - let's compile it.
presentation_->UpdatePostShader();

// Reset all shaders that might have resolution compiled-in.
if (draw2DPipeline565ToDepthDeswizzle_) {
draw2DPipeline565ToDepthDeswizzle_->Release();
draw2DPipeline565ToDepthDeswizzle_ = nullptr;
}


#ifdef _WIN32
// Seems related - if you're ok with numbers all the time, show some more :)
if (g_Config.iShowFPSCounter != 0) {
Expand Down

0 comments on commit 8e7cf59

Please sign in to comment.