- indexed rendering fixes

backported from GZDoom.
This commit is contained in:
Christoph Oelckers 2020-09-28 21:24:08 +02:00
parent 6cf921dbfe
commit 012bccd916
2 changed files with 9 additions and 5 deletions

View file

@ -49,7 +49,11 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags)
auto imgtex = tx->GetTexture();
mTextureLayers.Push({ imgtex, scaleflags, -1 });
if ((tx->GetUseType() == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(imgtex)->GetColorFormat() == 0) || (scaleflags & CTF_Indexed))
if (tx->GetUseType() == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(imgtex)->GetColorFormat() == 0)
{
mShaderIndex = SHADER_Paletted;
}
else if (scaleflags & CTF_Indexed)
{
mTextureLayers[0].scaleFlags |= CTF_Indexed;
mShaderIndex = SHADER_Paletted;
@ -159,7 +163,7 @@ FMaterial::~FMaterial()
IHardwareTexture* FMaterial::GetLayer(int i, int translation, MaterialLayerInfo** pLayer) const
{
if (mShaderIndex == SHADER_Paletted && i > 0 && layercallback)
if ((mScaleFlags & CTF_Indexed) && i > 0 && layercallback)
{
static MaterialLayerInfo deflayer = { nullptr, 0, CLAMP_XY };
if (i == 1 || i == 2)
@ -173,7 +177,7 @@ IHardwareTexture* FMaterial::GetLayer(int i, int translation, MaterialLayerInfo*
{
auto& layer = mTextureLayers[i];
if (pLayer) *pLayer = &layer;
if (mShaderIndex == SHADER_Paletted) translation = -1;
if (mScaleFlags & CTF_Indexed) translation = -1;
if (layer.layerTexture) return layer.layerTexture->GetHardwareTexture(translation, layer.scaleFlags);
}
return nullptr;

View file

@ -12,9 +12,9 @@ enum ECreateTexBufferFlags
CTF_Expand = 1, // create buffer with a one-pixel wide border
CTF_Upscale = 2, // Upscale the texture
CTF_CreateMask = 3, // Flags that are relevant for hardware texture creation.
CTF_ProcessData = 4, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture.
CTF_Indexed = 4, // Tell the backend to create an indexed texture.
CTF_CheckOnly = 8, // Only runs the code to get a content ID but does not create a texture. Can be used to access a caching system for the hardware textures.
CTF_Indexed = 16 // Tell the backend to create an indexed texture.
CTF_ProcessData = 16, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture.
};
class FHardwareTextureContainer