diff --git a/code/renderer/srp_imgui.cpp b/code/renderer/srp_imgui.cpp index 6f38379..2adfeaa 100644 --- a/code/renderer/srp_imgui.cpp +++ b/code/renderer/srp_imgui.cpp @@ -258,10 +258,16 @@ void ImGUI::Draw(HTexture renderTarget) continue; } + static_assert(sizeof(ImTextureID) >= 4, "Unexpected ImTextureID size"); + const ImTextureID textureIndex = cmd->TextureId & 0xFFFF; + const ImTextureID mipIndex = (cmd->TextureId >> 16) & 0xFF; + const bool usePointFilter = ((cmd->TextureId >> 31) & 1) == 1; + const TextureFilter::Id filter = usePointFilter ? TextureFilter::Point : TextureFilter::Linear; + ImGUIPixelRC pixelRC = {}; - pixelRC.texture = (uint32_t)cmd->TextureId & 0xFFFF; - pixelRC.sampler = GetSamplerIndex(TW_CLAMP_TO_EDGE, TextureFilter::Linear); - pixelRC.mip = (float)(((uint32_t)cmd->TextureId >> 16) & 0xFFFF); + pixelRC.texture = (uint32_t)textureIndex; + pixelRC.sampler = GetSamplerIndex(TW_CLAMP_TO_EDGE, filter); + pixelRC.mip = (float)mipIndex; if(ddhi) { CmdSetGraphicsRootConstants(sizeof(vertexRC), sizeof(pixelRC), &pixelRC);