Permalink
Browse files

Fix another little inconsistency (two uniforms were merged for bad re…

…asons)
  • Loading branch information...
hrydgard committed Dec 7, 2017
1 parent fb74c9d commit b75c8b72c67d95c615090b3ae2248bbb267601d8
@@ -71,9 +71,6 @@ enum : uint64_t {
DIRTY_SHADERBLEND = 1ULL << 17, // Used only for in-shader blending.
DIRTY_UVSCALEOFFSET = 1ULL << 18,
// Texclamp is fairly rare so let's share it's bit with DIRTY_DEPTHRANGE.
DIRTY_TEXCLAMP = 1ULL << 19,
DIRTY_DEPTHRANGE = 1ULL << 19,
DIRTY_WORLDMATRIX = 1ULL << 21,
@@ -90,10 +87,13 @@ enum : uint64_t {
// These are for hardware tessellation
DIRTY_BEZIERSPLINE = 1ULL << 32,
DIRTY_TEXCLAMP = 1ULL << 33,
// space for 7 more uniforms.
DIRTY_BONE_UNIFORMS = 0xFF000000ULL,
DIRTY_ALL_UNIFORMS = 0x1FFFFFFFFULL,
DIRTY_ALL_UNIFORMS = 0x3FFFFFFFFULL,
DIRTY_ALL_LIGHTS = DIRTY_LIGHT0 | DIRTY_LIGHT1 | DIRTY_LIGHT2 | DIRTY_LIGHT3,
// Other dirty elements that aren't uniforms!
@@ -6,7 +6,6 @@
// Used by the "modern" backends that use uniform buffers. They can share this without issue.
// Pretty much full. Will need more bits for more fine grained dirty tracking for lights.
enum : uint64_t {
DIRTY_BASE_UNIFORMS =
DIRTY_WORLDMATRIX | DIRTY_PROJTHROUGHMATRIX | DIRTY_VIEWMATRIX | DIRTY_TEXMATRIX | DIRTY_ALPHACOLORREF |
@@ -836,7 +836,9 @@ void TextureCacheCommon::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFram
gstate_c.bgraTexture = false;
gstate_c.curTextureXOffset = fbInfo.xOffset;
gstate_c.curTextureYOffset = fbInfo.yOffset;
gstate_c.SetNeedShaderTexclamp(gstate_c.curTextureWidth != (u32)gstate.getTextureWidth(0) || gstate_c.curTextureHeight != (u32)gstate.getTextureHeight(0));
u32 texW = (u32)gstate.getTextureWidth(0);
u32 texH = (u32)gstate.getTextureHeight(0);
gstate_c.SetNeedShaderTexclamp(gstate_c.curTextureWidth != texW || gstate_c.curTextureHeight != texH);
if (gstate_c.curTextureXOffset != 0 || gstate_c.curTextureYOffset != 0) {
gstate_c.SetNeedShaderTexclamp(true);
}
@@ -426,11 +426,6 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
textureCache_->SetTexture();
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
if (gstate_c.needShaderTexClamp) {
// We will rarely need to set this, so let's do it every time on use rather than in runloop.
// Most of the time non-framebuffer textures will be used which can be clamped themselves.
gstate_c.Dirty(DIRTY_TEXCLAMP);
}
}
}
@@ -103,11 +103,6 @@ void DrawEngineDX9::ApplyDrawState(int prim) {
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
textureCache_->SetTexture();
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
if (gstate_c.needShaderTexClamp) {
// We will rarely need to set this, so let's do it every time on use rather than in runloop.
// Most of the time non-framebuffer textures will be used which can be clamped themselves.
gstate_c.Dirty(DIRTY_TEXCLAMP);
}
}
// Start profiling here to skip SetTexture which is already accounted for
@@ -134,11 +134,6 @@ void DrawEngineGLES::ApplyDrawState(int prim) {
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
textureCache_->SetTexture();
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
if (gstate_c.needShaderTexClamp) {
// We will rarely need to set this, so let's do it every time on use rather than in runloop.
// Most of the time non-framebuffer textures will be used which can be clamped themselves.
gstate_c.Dirty(DIRTY_TEXCLAMP);
}
}
if (!gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE)) {
@@ -528,6 +528,8 @@ struct GPUStateCache {
if (need != needShaderTexClamp) {
needShaderTexClamp = need;
Dirty(DIRTY_FRAGMENTSHADER_STATE);
if (need)
Dirty(DIRTY_TEXCLAMP);

This comment has been minimized.

@unknownbrackets

unknownbrackets Dec 9, 2017

Collaborator

This needs to be dirtied even if it was already true. Luckily, it's doing that, but I think it's something we could easily accidentally remove.

Example (think bloom):

  1. I texture from framebuffer A, sized 480x272, but texture is 256x256. Tex clamp params are updated.
  2. I texture from framebuffer B, sized 256x272, but texture is 128x128. Tex clamp params NEED UPDATING.

So maybe we add a comment at gstate_c.SetNeedShaderTexclamp(false); that it NEEDS to happen before framebuffers are set so that it will always be toggled off/on again in the case of a different framebuffer.

-[Unknown]

This comment has been minimized.

@hrydgard

hrydgard Dec 9, 2017

Owner

Ah yes, you are right of course. I'll do that.

}
}
void SetAllowShaderBlend(bool allow) {
@@ -619,11 +619,6 @@ void DrawEngineVulkan::DoFlush() {
textureCache_->SetTexture();
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
textureNeedsApply = true;
if (gstate_c.needShaderTexClamp) {
// We will rarely need to set this, so let's do it every time on use rather than in runloop.
// Most of the time non-framebuffer textures will be used which can be clamped themselves.
gstate_c.Dirty(DIRTY_TEXCLAMP);
}
}
GEPrimitiveType prim = prevPrim_;

0 comments on commit b75c8b7

Please sign in to comment.