mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Fixes for D3D11
This commit is contained in:
parent
e2707d3ab3
commit
ca24f1b9aa
@ -423,3 +423,19 @@ ShaderWriter &ShaderWriter::SampleTexture2D(const char *sampName, const char *uv
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
ShaderWriter &ShaderWriter::GetTextureSize(const char *szVariable, const char *texName) {
|
||||
switch (lang_.shaderLanguage) {
|
||||
case HLSL_D3D11:
|
||||
F(" float2 %s; %s.GetDimensions(%s.x, %s.y);", szVariable, texName, szVariable, szVariable);
|
||||
break;
|
||||
case HLSL_D3D9:
|
||||
F(" float2 %s; %s.GetDimensions(%s.x, %s.y);", szVariable, texName, szVariable, szVariable);
|
||||
break;
|
||||
default:
|
||||
// Note: we ignore the sampler. make sure you bound samplers to the textures correctly.
|
||||
F("vec2 %s = textureSize(%s, 0);", szVariable, texName);
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ public:
|
||||
|
||||
void ConstFloat(const char *name, float value);
|
||||
|
||||
ShaderWriter &SampleTexture2D(const char *sampName, const char *uv);
|
||||
ShaderWriter &SampleTexture2D(const char *texName, const char *uv);
|
||||
ShaderWriter &GetTextureSize(const char *szVariable, const char *texName);
|
||||
|
||||
// Simple shaders with no special tricks.
|
||||
void BeginVSMain(Slice<InputDef> inputs, Slice<UniformDef> uniforms, Slice<VaryingDef> varyings);
|
||||
|
@ -70,6 +70,7 @@ RasterChannel GenerateDraw2D565ToDepthFs(ShaderWriter &writer) {
|
||||
writer.F(" highp float depthValue = (floor(rgb.x * 31.99) + floor(rgb.y * 63.99) * 32.0 + floor(rgb.z * 31.99) * 2048.0); \n");
|
||||
writer.F(" gl_FragDepth = (depthValue / %f) + %f;\n", factors.scale, factors.offset);
|
||||
writer.EndFSMain("outColor", FSFLAG_WRITEDEPTH);
|
||||
|
||||
return RASTER_DEPTH;
|
||||
}
|
||||
|
||||
@ -83,7 +84,7 @@ RasterChannel GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) {
|
||||
// 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.C(" vec2 tsize = vec2(textureSize(tex, 0));\n");
|
||||
writer.GetTextureSize("tsize", "tex").C("\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");
|
||||
@ -255,4 +256,8 @@ void FramebufferManagerCommon::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *ver
|
||||
}
|
||||
draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, linearFilter ? &draw2DSamplerLinear_ : &draw2DSamplerNearest_);
|
||||
draw_->DrawUP(verts, vertexCount);
|
||||
|
||||
draw_->InvalidateCachedState();
|
||||
|
||||
gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE | DIRTY_VERTEXSHADER_STATE);
|
||||
}
|
||||
|
@ -552,6 +552,8 @@ void FramebufferManagerCommon::CopyToDepthFromOverlappingFramebuffers(VirtualFra
|
||||
|
||||
// for (auto &source : sources) {
|
||||
if (!sources.empty()) {
|
||||
draw_->InvalidateCachedState();
|
||||
|
||||
auto &source = sources.back();
|
||||
if (source.channel == RASTER_DEPTH) {
|
||||
// Good old depth->depth copy.
|
||||
|
Loading…
Reference in New Issue
Block a user