Avoid using the to-BGRA converter for luminance textures

When inspecting bitmasks for old-style DDS headers, we were labelling luminance as `l`, then later using that to attempt to look up a GL enum by name. The luminance enums actually call it `LUMINANCE` instead of `L`, despite using single letters for single-colour channels, so the lookup was failing, and we were falling back to conversion instead of uploading the data directly.
This commit is contained in:
Chris Djali
2020-03-16 21:54:34 +00:00
committed by GitHub
parent c566b732fc
commit 165c27b0be
+8 -8
View File
@@ -463,10 +463,10 @@ def buildConverter(byteCount, usedBitCounts = {8}, bitmasks = None, intmasks = N
bIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["b"][:byteCount]))
if "a" in bitmasks:
aIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["a"][:byteCount]))
if "l" in bitmasks:
rIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["l"][:byteCount]))
gIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["l"][:byteCount]))
bIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["l"][:byteCount]))
if "luminance" in bitmasks:
rIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["luminance"][:byteCount]))
gIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["luminance"][:byteCount]))
bIntMask = unpackCombiner(*struct.unpack("<" + unpackFormat, bitmasks["luminance"][:byteCount]))
rDivisor = 2 ** bin(rIntMask).count("1") - 1
gDivisor = 2 ** bin(gIntMask).count("1") - 1
@@ -573,9 +573,9 @@ def getGLFormat(pixelFormat, dxt10Header = None):
starts["a"] = firstBit(aBitmask)
namedBitmasks["a"] = aBitmask
if lumBitmask:
bitCounts["l"] = bitCount(lumBitmask)
starts["l"] = firstBit(lumBitmask)
namedBitmasks["l"] = lumBitmask
bitCounts["luminance"] = bitCount(lumBitmask)
starts["luminancel"] = firstBit(lumBitmask)
namedBitmasks["luminance"] = lumBitmask
toSort = []
for key in starts:
@@ -676,4 +676,4 @@ def sizeFromFormat(dxgiFormat, width, height):
currentNum = ""
pixelSize = (count + 7) // 8
return width * height * pixelSize
pass
pass