Remove "pixelMapped" from gstate_c.

This commit is contained in:
Henrik Rydgård committed 2026-07-16 17:45:22 +02:00
1 parent 6f4f0c41b4
commit 92ec6a992b
14 files changed
+44 -53

No files matched your search

+4 -4
View File
@@ -32,7 +32,7 @@ void UpdateRotation(float rotMatrix[4], bool useBufferedRendering) {
}
}
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool useBufferedRendering) {
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool useBufferedRendering, bool pixelMapped) {
if (dirtyUniforms & DIRTY_TEXENV) {
Uint8x3ToFloat3(ub->texEnvColor, gstate.texenvcolor);
}
@@ -147,11 +147,11 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool useBuffe
}
if (dirtyUniforms & DIRTY_DEPAL) {
ub->depal_mask_shift_off_fmt = PackDepalBits();
ub->depal_mask_shift_off_fmt = PackDepalBits(pixelMapped);
}
}
uint32_t PackDepalBits() {
uint32_t PackDepalBits(bool pixelMapped) {
const int indexMask = gstate.getClutIndexMask();
const int indexShift = gstate.getClutIndexShift();
const int indexOffset = gstate.getClutIndexStartPos() >> 4;
@@ -160,7 +160,7 @@ uint32_t PackDepalBits() {
// NOTE: This must follow similar logic to TextureCacheCommon::GetSamplingParams -
// maybe we can share it somehow.
// TOOD: Handle replaced textures.
bool bilinear = gstate.isMagnifyFilteringEnabled() && !gstate_c.pixelMapped;
bool bilinear = gstate.isMagnifyFilteringEnabled() && !pixelMapped;
switch (g_Config.iTexFiltering) {
case TEX_FILTER_FORCE_NEAREST:
bilinear = false;
+2 -2
View File
@@ -105,11 +105,11 @@ R"( vec4 u_ambient;
)";
// useBufferedRendering is only used to determine the rotation uniform.
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool useBufferedRendering);
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool useBufferedRendering, bool pixelMapped);
void LightUpdateUniforms(UB_VS_Lights *ub, uint64_t dirtyUniforms);
uint32_t PackLightControlBits();
uint32_t PackDepalBits();
uint32_t PackDepalBits(bool pixelMapped);
void UpdateFogCoef(const GEState &state, float fogCoef[2]);
+10 -10
View File
@@ -182,7 +182,7 @@ static int TexLog2(float delta) {
return useful - 127 * 256;
}
SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCacheEntry *entry, bool flatZ) {
SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCacheEntry *entry, bool flatZ, bool pixelMapped) {
SamplerCacheKey key{};
int minFilt = gstate.texfilter & 0x7;
@@ -276,7 +276,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac
if (uglyColorTest)
forceFiltering = TEX_FILTER_FORCE_NEAREST;
}
if (gstate_c.pixelMapped) {
if (pixelMapped) {
forceFiltering = TEX_FILTER_FORCE_NEAREST;
}
break;
@@ -303,7 +303,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac
key.aniso = false;
}
}
if (gstate_c.pixelMapped) {
if (pixelMapped) {
forceFiltering = TEX_FILTER_FORCE_NEAREST;
key.aniso = false;
}
@@ -337,7 +337,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac
return key;
}
SamplerCacheKey GetFramebufferSamplingParams(const GEState &gstate, u16 bufferWidth, u16 bufferHeight) {
SamplerCacheKey GetFramebufferSamplingParams(const GEState &gstate, u16 bufferWidth, u16 bufferHeight, bool pixelMapped) {
SamplerCacheKey key{};
key.magFilt = gstate.isMagnifyFilteringEnabled();
@@ -355,7 +355,7 @@ SamplerCacheKey GetFramebufferSamplingParams(const GEState &gstate, u16 bufferWi
switch ((TextureFiltering)g_Config.iTexFiltering) {
case TEX_FILTER_AUTO:
case TEX_FILTER_AUTO_MAX_QUALITY:
if (gstate_c.pixelMapped) {
if (pixelMapped) {
key.magFilt = false;
key.minFilt = false;
}
@@ -2314,15 +2314,15 @@ TextureApplyResult TextureCacheCommon::ApplyTexture(bool doBind) {
return TextureApplyResult{entry, nullptr};
}
void TextureCacheCommon::ApplySampler(const TextureApplyResult &result, bool flatZ) {
void TextureCacheCommon::ApplySampler(const TextureApplyResult &result, bool flatZ, bool pixelMapped) {
SamplerCacheKey samplerKey;
if (result.texCacheEntry) {
int maxLevel = (result.texCacheEntry->status & TexStatus::NO_MIPS) ? 0 : result.texCacheEntry->maxLevel;
samplerKey = GetSamplingParams(maxLevel, result.texCacheEntry, flatZ);
samplerKey = GetSamplingParams(maxLevel, result.texCacheEntry, flatZ, pixelMapped);
} else if (result.framebuffer) {
samplerKey = GetFramebufferSamplingParams(gstate, result.framebuffer->bufferWidth, result.framebuffer->bufferHeight);
samplerKey = GetFramebufferSamplingParams(gstate, result.framebuffer->bufferWidth, result.framebuffer->bufferHeight, pixelMapped);
} else {
samplerKey = GetSamplingParams(0, nullptr, flatZ);
samplerKey = GetSamplingParams(0, nullptr, flatZ, pixelMapped);
}
ApplySamplerByKey(samplerKey);
}
@@ -2448,7 +2448,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
// Vulkan needs to do some extra work here to pick out the native handle from Draw.
BoundFramebufferTexture();
SamplerCacheKey samplerKey = GetFramebufferSamplingParams(gstate, framebuffer->bufferWidth, framebuffer->bufferHeight);
SamplerCacheKey samplerKey = GetFramebufferSamplingParams(gstate, framebuffer->bufferWidth, framebuffer->bufferHeight, false);
samplerKey.magFilt = false;
samplerKey.minFilt = false;
samplerKey.mipEnable = false;
+3 -3
View File
@@ -348,7 +348,7 @@ public:
}
TextureApplyResult ApplyTexture(bool doBind);
void ApplySampler(const TextureApplyResult &result, bool flatZ); // Should follow ApplyTexture
void ApplySampler(const TextureApplyResult &result, bool flatZ, bool pixelMapped); // Should follow ApplyTexture
bool SetOffsetTexture(u32 yOffset);
void Invalidate(u32 addr, int size, GPUInvalidationType type);
@@ -439,7 +439,7 @@ protected:
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *mapData, size_t dataSize, int mapRowPitch, BuildTexturePlan &plan, int srcLevel, Draw::DataFormat dstFmt, TexDecodeFlags texDecFlags);
// This needs to be a member functions just for IsVideo and Replacer.
SamplerCacheKey GetSamplingParams(int maxLevel, const TexCacheEntry *entry, bool flatZ);
SamplerCacheKey GetSamplingParams(int maxLevel, const TexCacheEntry *entry, bool flatZ, bool pixelMapped);
void UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode);
@@ -533,4 +533,4 @@ inline u64 TexCacheEntry::CacheKey(u32 addr, u8 format, u16 dim, u32 cluthash) {
return cachekey;
}
SamplerCacheKey GetFramebufferSamplingParams(const GEState &gstate, u16 bufferWidth, u16 bufferHeight);
SamplerCacheKey GetFramebufferSamplingParams(const GEState &gstate, u16 bufferWidth, u16 bufferHeight, bool pixelMapped);
+4 -6
View File
@@ -328,7 +328,7 @@ void DrawEngineD3D11::Flush() {
if (textureNeedsApply) {
gstate_c.dstSquared = false;
TextureApplyResult textureResult = textureCache_->ApplyTexture(true);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ, false);
if (gstate_c.dstSquared) {
gstate_c.Dirty(DIRTY_BLEND_STATE);
}
@@ -345,7 +345,7 @@ void DrawEngineD3D11::Flush() {
SetupDecFmtForDraw(vshader, dec_->GetDecVtxFmt(), dec_->VertexType(), &inputLayout);
context_->PSSetShader(fshader->GetShader(), nullptr, 0);
context_->VSSetShader(vshader->GetShader(), nullptr, 0);
shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering());
shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering(), false);
shaderManager_->BindUniforms();
context_->IASetInputLayout(inputLayout);
@@ -440,10 +440,8 @@ void DrawEngineD3D11::Flush() {
// TODO: This should be after BuildDrawingParams!
if (textureNeedsApply) {
gstate_c.pixelMapped = result.pixelMapped;
TextureApplyResult textureResult = textureCache_->ApplyTexture(true);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ);
gstate_c.pixelMapped = false;
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ, result.pixelMapped);
}
// Need to ApplyDrawState after ApplyTexture because depal can launch a render pass and that wrecks the state.
@@ -456,7 +454,7 @@ void DrawEngineD3D11::Flush() {
shaderManager_->GetShaders(prim, swDec->VertexType(), &vshader, &fshader, pipelineState_, false, clipInfoFlags_);
context_->PSSetShader(fshader->GetShader(), nullptr, 0);
context_->VSSetShader(vshader->GetShader(), nullptr, 0);
shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering());
shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering(), result.pixelMapped);
shaderManager_->BindUniforms();
// We really do need a vertex layout for each vertex shader (or at least check its ID bits for what inputs it uses)!
+2 -2
View File
@@ -141,12 +141,12 @@ void ShaderManagerD3D11::ClearShaders() {
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
}
uint64_t ShaderManagerD3D11::UpdateUniforms(bool useBufferedRendering) {
uint64_t ShaderManagerD3D11::UpdateUniforms(bool useBufferedRendering, bool pixelMapped) {
uint64_t dirty = gstate_c.GetDirtyUniforms();
if (dirty != 0) {
D3D11_MAPPED_SUBRESOURCE map;
if (dirty & DIRTY_BASE_UNIFORMS) {
BaseUpdateUniforms(&ub_base, dirty, useBufferedRendering);
BaseUpdateUniforms(&ub_base, dirty, useBufferedRendering, pixelMapped);
context_->Map(push_base.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
memcpy(map.pData, &ub_base, sizeof(ub_base));
context_->Unmap(push_base.Get(), 0);
+1 -1
View File
@@ -102,7 +102,7 @@ public:
std::vector<std::string> DebugGetShaderIDs(DebugShaderType type) override;
std::string DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType) override;
uint64_t UpdateUniforms(bool useBufferedRendering);
uint64_t UpdateUniforms(bool useBufferedRendering, bool pixelMapped);
void BindUniforms();
// TODO: Avoid copying these buffers if same as last draw, can still point to it assuming we're still in the same pushbuffer.
+4 -6
View File
@@ -315,14 +315,14 @@ void DrawEngineGLES::Flush() {
if (textureNeedsApply) {
TextureApplyResult textureResult = textureCache_->ApplyTexture(true);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ, false);
}
// Need to ApplyDrawState after ApplyTexture because depal can launch a render pass and that wrecks the state.
ApplyDrawState(prim);
ApplyDrawStateLate(false, 0);
LinkedShader *program = shaderManager_->ApplyFragmentShader(vsid, vshader, pipelineState_, clipInfoFlags_);
LinkedShader *program = shaderManager_->ApplyFragmentShader(vsid, vshader, pipelineState_, clipInfoFlags_, false);
GLRInputLayout *inputLayout = SetupDecFmtForDraw(dec_->GetDecVtxFmt());
if (useElements) {
render_->DrawIndexed(inputLayout,
@@ -393,21 +393,19 @@ void DrawEngineGLES::Flush() {
}
if (textureNeedsApply) {
gstate_c.pixelMapped = result.pixelMapped;
gstate_c.dstSquared = false;
TextureApplyResult textureResult = textureCache_->ApplyTexture(true);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ, result.pixelMapped);
if (gstate_c.dstSquared) {
gstate_c.Dirty(DIRTY_BLEND_STATE);
}
gstate_c.pixelMapped = false;
}
// Need to ApplyDrawState after ApplyTexture because depal can launch a render pass and that wrecks the state.
ApplyDrawState(prim);
ApplyDrawStateLate(result.setStencil, result.stencilValue);
LinkedShader *linked = shaderManager_->ApplyFragmentShader(vsid, vshader, pipelineState_, clipInfoFlags_);
LinkedShader *linked = shaderManager_->ApplyFragmentShader(vsid, vshader, pipelineState_, clipInfoFlags_, result.pixelMapped);
if (!linked) {
// Not much we can do here. Let's skip drawing.
goto bail;
+5 -5
View File
@@ -351,7 +351,7 @@ void LinkedShader::use(const ShaderID &VSID) const {
// Note that we no longer track attr masks here - we do it for the input layouts instead.
}
void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc &shaderLanguage) {
void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc &shaderLanguage, bool pixelMapped) {
u64 dirty = dirtyUniforms & availableUniforms;
dirtyUniforms = 0;
@@ -369,7 +369,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, const ShaderLanguageDesc
return;
if (dirty & DIRTY_DEPAL) {
render_->SetUniformUI1(&u_depal_mask_shift_off_fmt, PackDepalBits());
render_->SetUniformUI1(&u_depal_mask_shift_off_fmt, PackDepalBits(pixelMapped));
}
// Set HUD mode
@@ -727,7 +727,7 @@ Shader *ShaderManagerGLES::ApplyVertexShader(bool useHWTransform, u32 vertexType
return vs;
}
LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs, const ComputedPipelineState &pipelineState, ClipInfoFlags clipInfoFlags) {
LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs, const ComputedPipelineState &pipelineState, ClipInfoFlags clipInfoFlags, bool pixelMapped) {
uint64_t dirty = gstate_c.GetDirtyUniforms();
if (dirty) {
if (lastShader_)
@@ -746,7 +746,7 @@ LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs,
}
if (lastShader_ && lastVShaderSame_ && FSID == lastFSID_) {
lastShader_->UpdateUniforms(VSID, draw_->GetShaderLanguageDesc());
lastShader_->UpdateUniforms(VSID, draw_->GetShaderLanguageDesc(), pixelMapped);
return lastShader_;
}
@@ -798,7 +798,7 @@ LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs,
} else {
ls->use(VSID);
}
ls->UpdateUniforms(VSID, draw_->GetShaderLanguageDesc());
ls->UpdateUniforms(VSID, draw_->GetShaderLanguageDesc(), pixelMapped);
lastShader_ = ls;
return ls;
+2 -2
View File
@@ -41,7 +41,7 @@ public:
~LinkedShader();
void use(const ShaderID &VSID) const;
void UpdateUniforms(const ShaderID &VSID, const ShaderLanguageDesc &shaderLanguage);
void UpdateUniforms(const ShaderID &VSID, const ShaderLanguageDesc &shaderLanguage, bool pixelMapped);
void Delete();
GLRenderManager *render_;
@@ -173,7 +173,7 @@ public:
// This is the old ApplyShader split into two parts, because of annoying information dependencies.
// If you call ApplyVertexShader, you MUST call ApplyFragmentShader soon afterwards.
Shader *ApplyVertexShader(bool useHWTransform, u32 vertexType, ClipInfoFlags clipInfoFlags, VShaderID *VSID);
LinkedShader *ApplyFragmentShader(VShaderID VSID, Shader *vs, const ComputedPipelineState &pipelineState, ClipInfoFlags clipInfoFlags);
LinkedShader *ApplyFragmentShader(VShaderID VSID, Shader *vs, const ComputedPipelineState &pipelineState, ClipInfoFlags clipInfoFlags, bool pixelMapped);
void DeviceLost() override;
void DeviceRestore(Draw::DrawContext *draw) override;
-3
View File
@@ -650,9 +650,6 @@ public:
// DST squared, used in Brave Story
bool dstSquared;
// U/V is 1:1 to pixels. Can influence texture sampling.
bool pixelMapped;
// TODO: These should be accessed from the current VFB object directly.
u32 curRTWidth;
u32 curRTHeight;
+4 -6
View File
@@ -287,7 +287,7 @@ void DrawEngineVulkan::Flush() {
if (textureNeedsApply) {
TextureApplyResult textureResult = textureCache_->ApplyTexture(true);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ, false);
textureCache_->GetVulkanHandles(imageView, sampler);
if (imageView == VK_NULL_HANDLE)
imageView = (VkImageView)draw_->GetNativeObject(gstate_c.textureIsArray ? Draw::NativeObject::NULL_IMAGEVIEW_ARRAY : Draw::NativeObject::NULL_IMAGEVIEW);
@@ -332,7 +332,7 @@ void DrawEngineVulkan::Flush() {
}
lastPrim_ = prim;
dirtyUniforms_ |= shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering());
dirtyUniforms_ |= shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering(), false);
UpdateUBOs();
int descCount = 5;
@@ -436,11 +436,9 @@ void DrawEngineVulkan::Flush() {
// to use a "pre-clear" render pass, for high efficiency on tilers.
if (action == SW_DRAW_INDEXED) {
if (textureNeedsApply) {
gstate_c.pixelMapped = result.pixelMapped;
gstate_c.dstSquared = false;
TextureApplyResult textureResult = textureCache_->ApplyTexture(true);
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ);
gstate_c.pixelMapped = false;
textureCache_->ApplySampler(textureResult, clipInfoFlags_ & ClipInfoFlags::FlatZ, result.pixelMapped);
textureCache_->GetVulkanHandles(imageView, sampler);
if (imageView == VK_NULL_HANDLE)
imageView = (VkImageView)draw_->GetNativeObject(gstate_c.textureIsArray ? Draw::NativeObject::NULL_IMAGEVIEW_ARRAY : Draw::NativeObject::NULL_IMAGEVIEW);
@@ -488,7 +486,7 @@ void DrawEngineVulkan::Flush() {
lastPrim_ = prim;
dirtyUniforms_ |= shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering());
dirtyUniforms_ |= shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering(), result.pixelMapped);
// Even if the first draw is through-mode, make sure we at least have one copy of these uniforms buffered
UpdateUBOs();
+2 -2
View File
@@ -217,11 +217,11 @@ void ShaderManagerVulkan::ClearShaders() {
gstate_c.Dirty(DIRTY_ALL_UNIFORMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
}
uint64_t ShaderManagerVulkan::UpdateUniforms(bool useBufferedRendering) {
uint64_t ShaderManagerVulkan::UpdateUniforms(bool useBufferedRendering, bool pixelMapped) {
uint64_t dirty = gstate_c.GetDirtyUniforms();
if (dirty != 0) {
if (dirty & DIRTY_BASE_UNIFORMS)
BaseUpdateUniforms(&uniforms_->ub_base, dirty, useBufferedRendering);
BaseUpdateUniforms(&uniforms_->ub_base, dirty, useBufferedRendering, pixelMapped);
if (dirty & DIRTY_LIGHT_UNIFORMS)
LightUpdateUniforms(&uniforms_->ub_lights, dirty);
}
+1 -1
View File
@@ -113,7 +113,7 @@ public:
std::vector<std::string> DebugGetShaderIDs(DebugShaderType type) override;
std::string DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType) override;
uint64_t UpdateUniforms(bool useBufferedRendering);
uint64_t UpdateUniforms(bool useBufferedRendering, bool pixelMapped);
// TODO: Avoid copying these buffers if same as last draw, can still point to it assuming we're still in the same pushbuffer.
// Applies dirty changes and copies the buffer.