MCPcopy Create free account
hub / github.com/baldurk/renderdoc / MakeResourceFormat

Function MakeResourceFormat

renderdoc/driver/gl/gl_common.cpp:1941–2391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1939}
1940
1941ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt)
1942{
1943 ResourceFormat ret;
1944
1945 ret.type = ResourceFormatType::Regular;
1946
1947 if(fmt == eGL_NONE)
1948 {
1949 ret.type = ResourceFormatType::Undefined;
1950 return ret;
1951 }
1952
1953 // special handling for formats that don't query neatly
1954 if(fmt == eGL_LUMINANCE8_EXT || fmt == eGL_INTENSITY8_EXT || fmt == eGL_LUMINANCE)
1955 {
1956 ret.compByteWidth = 1;
1957 ret.compCount = 1;
1958 ret.compType = CompType::UNorm;
1959 return ret;
1960 }
1961 else if(fmt == eGL_ALPHA || fmt == eGL_ALPHA8_EXT)
1962 {
1963 ret.compByteWidth = 1;
1964 ret.compCount = 1;
1965 ret.compType = CompType::UNorm;
1966 ret.type = ResourceFormatType::A8;
1967 return ret;
1968 }
1969 else if(fmt == eGL_LUMINANCE8_ALPHA8_EXT || fmt == eGL_LUMINANCE_ALPHA)
1970 {
1971 ret.compByteWidth = 1;
1972 ret.compCount = 2;
1973 ret.compType = CompType::UNorm;
1974 return ret;
1975 }
1976 else if(fmt == eGL_RGBA2)
1977 {
1978 // pretend it's RGBA8 and hope for the best
1979 ret.compByteWidth = 1;
1980 ret.compCount = 4;
1981 ret.compType = CompType::UNorm;
1982 return ret;
1983 }
1984
1985 if(IsCompressedFormat(fmt))
1986 {
1987 switch(fmt)
1988 {
1989 // BC1
1990 case eGL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1991 case eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT: ret.compCount = 3; break;
1992 case eGL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1993 case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: ret.compCount = 4; break;
1994
1995 // BC2
1996 case eGL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1997 case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: ret.compCount = 4; break;
1998

Calls 4

IsCompressedFormatFunction · 0.85
ToStrFunction · 0.85
glGetInternalformativMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected