Skip to content

Commit

Permalink
Add support for HDR canvas textures
Browse files Browse the repository at this point in the history
Vulkan only.
  • Loading branch information
Cacodemon345 authored and madame-rachelle committed Aug 12, 2023
1 parent b695e84 commit fe7beaa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/rendering/vulkan/textures/vk_hwtexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void VkHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
}
else
{
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
VkFormat format = tex->IsHDR() ? VK_FORMAT_R32G32B32A32_SFLOAT : VK_FORMAT_R8G8B8A8_UNORM;
int w = tex->GetWidth();
int h = tex->GetHeight();

Expand Down
9 changes: 9 additions & 0 deletions src/common/textures/textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class FTexture : public RefCountedBase

bool Masked = false; // Texture (might) have holes
bool bHasCanvas = false;
bool bHdr = false; // only canvas textures for now.
int8_t bTranslucent = -1;
int8_t areacount = 0; // this is capped at 4 sections.

Expand Down Expand Up @@ -253,6 +254,8 @@ class FTexture : public RefCountedBase
bool isHardwareCanvas() const { return bHasCanvas; } // There's two here so that this can deal with software canvases in the hardware renderer later.
bool isCanvas() const { return bHasCanvas; }

bool IsHDR() const { return bHdr; }

int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
void SetSourceLump(int sl) { SourceLump = sl; }
bool FindHoles(const unsigned char * buffer, int w, int h);
Expand Down Expand Up @@ -345,6 +348,12 @@ class FCanvasTexture : public FTexture
float aspectRatio;

friend struct FCanvasTextureInfo;
friend class FTextureAnimator;

private:
void SetHDR(bool hdr) {
bHdr = hdr;
}
};


Expand Down
11 changes: 11 additions & 0 deletions src/gamedata/textures/animations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,17 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc)
TexMan.AddGameTexture (viewer);
}
if (sc.GetString())
{
if (sc.Compare ("hdr"))
{
canvas->SetHDR(true);
}
else
{
sc.UnGet();
}
}
if (sc.GetString())
{
if (sc.Compare ("fit"))
{
Expand Down

0 comments on commit fe7beaa

Please sign in to comment.