OpenGL: Fix shader depal too.

This commit is contained in:
Henrik Rydgård 2022-08-05 11:09:16 +02:00
parent 37555fd442
commit 4e89174b85
6 changed files with 24 additions and 18 deletions

View File

@ -163,7 +163,7 @@ public:
}
}
uint64_t GetNativeObject(NativeObject obj) override {
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override {
switch (obj) {
case NativeObject::DEVICE:
return (uint64_t)(uintptr_t)device_;

View File

@ -560,7 +560,7 @@ public:
void DrawUP(const void *vdata, int vertexCount) override;
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
uint64_t GetNativeObject(NativeObject obj) override {
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override {
switch (obj) {
case NativeObject::CONTEXT:
return (uint64_t)(uintptr_t)d3d_;

View File

@ -456,14 +456,7 @@ public:
}
}
uint64_t GetNativeObject(NativeObject obj) override {
switch (obj) {
case NativeObject::RENDER_MANAGER:
return (uint64_t)(uintptr_t)&renderManager_;
default:
return 0;
}
}
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override;
void HandleEvent(Event ev, int width, int height, void *param1, void *param2) override {}
@ -1427,6 +1420,17 @@ void OpenGLContext::GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) {
}
}
uint64_t OpenGLContext::GetNativeObject(NativeObject obj, void *srcObject) {
switch (obj) {
case NativeObject::RENDER_MANAGER:
return (uint64_t)(uintptr_t)&renderManager_;
case NativeObject::TEXTURE: // Gets the GLRTexture *
return (uint64_t)(((OpenGLTexture *)srcObject)->GetTex());
default:
return 0;
}
}
uint32_t OpenGLContext::GetDataFormatSupport(DataFormat fmt) const {
switch (fmt) {
case DataFormat::R4G4B4A4_UNORM_PACK16:

View File

@ -464,7 +464,7 @@ public:
std::vector<std::string> GetFeatureList() const override;
std::vector<std::string> GetExtensionList() const override;
uint64_t GetNativeObject(NativeObject obj) override {
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override {
switch (obj) {
case NativeObject::CONTEXT:
return (uint64_t)vulkan_;

View File

@ -246,7 +246,7 @@ enum class NativeObject {
BOUND_TEXTURE0_IMAGEVIEW,
BOUND_TEXTURE1_IMAGEVIEW,
RENDER_MANAGER,
TEXTURE_IMAGEVIEW,
TEXTURE,
NULL_IMAGEVIEW,
};
@ -700,7 +700,7 @@ public:
}
virtual std::string GetInfoString(InfoField info) const = 0;
virtual uint64_t GetNativeObject(NativeObject obj) = 0;
virtual uint64_t GetNativeObject(NativeObject obj, void *srcObject = nullptr) = 0; // Most uses don't need an srcObject.
virtual void HandleEvent(Event ev, int width, int height, void *param1 = nullptr, void *param2 = nullptr) = 0;

View File

@ -333,9 +333,9 @@ protected:
};
void TextureCacheGLES::BindAsClutTexture(Draw::Texture *tex) {
draw_->BindTexture(1, tex);
GLRTexture *glrTex = (GLRTexture *)draw_->GetNativeObject(Draw::NativeObject::BOUND_TEXTURE1_IMAGEVIEW);
GLRTexture *glrTex = (GLRTexture *)draw_->GetNativeObject(Draw::NativeObject::TEXTURE, tex);
render_->BindTexture(TEX_SLOT_CLUT, glrTex);
render_->SetTextureSampler(TEX_SLOT_CLUT, GL_REPEAT, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST, 0.0f);
}
void TextureCacheGLES::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer, GETextureFormat texFormat, FramebufferNotificationChannel channel) {
@ -353,18 +353,17 @@ void TextureCacheGLES::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer,
if (need_depalettize && !g_Config.bDisableSlowFramebufEffects) {
if (useShaderDepal) {
const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat();
// Very icky conflation here of native and thin3d rendering. This will need careful work per backend.
// Very icky conflation here of native and thin3d rendering. This will need careful work per backend in BindAsClutTexture.
Draw::Texture *clutTexture = depalShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBuf_);
BindAsClutTexture(clutTexture);
render_->SetTextureSampler(TEX_SLOT_CLUT, GL_REPEAT, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST, 0.0f);
framebufferManagerGL_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
SamplerCacheKey samplerKey = GetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight);
samplerKey.magFilt = false;
samplerKey.minFilt = false;
samplerKey.mipEnable = false;
ApplySamplingParams(samplerKey);
InvalidateLastTexture();
// Since we started/ended render passes, might need these.
gstate_c.Dirty(DIRTY_DEPAL);
@ -374,6 +373,9 @@ void TextureCacheGLES::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer,
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
CheckAlphaResult alphaStatus = CheckAlpha((const uint8_t *)clutBuf_, getClutDestFormat(clutFormat), clutTotalColors);
gstate_c.SetTextureFullAlpha(alphaStatus == CHECKALPHA_FULL);
draw_->InvalidateCachedState();
InvalidateLastTexture();
return;
}