diff --git a/bin/Data/bc1.glsl b/bin/Data/bc1.glsl index 16d28fd..abab2c8 100644 --- a/bin/Data/bc1.glsl +++ b/bin/Data/bc1.glsl @@ -11,7 +11,7 @@ uniform uint p_numRefinements; uniform sampler2D srcTex; -layout( rg32ui ) uniform restrict writeonly highp uimage2D dstTexture; +layout( rgba16ui ) uniform restrict writeonly mediump uimage2D dstTexture; layout( std430, binding = 1 ) readonly restrict buffer globalBuffer { @@ -505,10 +505,12 @@ void main() mask ^= 0x55555555u; } - uint2 outputBytes; - outputBytes.x = uint( maxEndp16 ) | ( uint( minEndp16 ) << 16u ); - outputBytes.y = mask; + uint4 outputBytes; + outputBytes.x = uint( maxEndp16 ); + outputBytes.y = uint( minEndp16 ); + outputBytes.z = mask & 0xFFFFu; + outputBytes.w = mask >> 16u; uint2 dstUV = gl_GlobalInvocationID.xy; - imageStore( dstTexture, int2( dstUV ), uint4( outputBytes.xy, 0u, 0u ) ); + imageStore( dstTexture, int2( dstUV ), outputBytes ); } diff --git a/bin/Data/bc4.glsl b/bin/Data/bc4.glsl index 14511bf..b978388 100644 --- a/bin/Data/bc4.glsl +++ b/bin/Data/bc4.glsl @@ -15,7 +15,7 @@ layout( location = 0 ) uniform float2 params; uniform sampler2D srcTex; -layout( rg32ui ) uniform restrict writeonly highp uimage2D dstTexture; +layout( rgba16ui ) uniform restrict writeonly mediump uimage2D dstTexture; layout( local_size_x = 4, // local_size_y = 4, // @@ -134,7 +134,7 @@ void main() if( blockThreadId == 0u ) { // Save data - uint2 outputBytes; + uint4 outputBytes; if( p_useSNorm != 0.0f ) { @@ -147,10 +147,11 @@ void main() outputBytes.x = packUnorm4x8( float4( maxVal * ( 1.0f / 255.0f ), minVal * ( 1.0f / 255.0f ), 0.0f, 0.0f ) ); } - outputBytes.x |= g_mask[maskIdxBase].x; - outputBytes.y = g_mask[maskIdxBase].y; + outputBytes.y = g_mask[maskIdxBase].x >> 16u; + outputBytes.z = g_mask[maskIdxBase].y & 0xFFFFu; + outputBytes.w = g_mask[maskIdxBase].y >> 16u; uint2 dstUV = gl_GlobalInvocationID.yz; - imageStore( dstTexture, int2( dstUV ), uint4( outputBytes.xy, 0u, 0u ) ); + imageStore( dstTexture, int2( dstUV ), outputBytes ); } } diff --git a/src/betsy/EncoderBC1.cpp b/src/betsy/EncoderBC1.cpp index 4cdccd7..09903d8 100644 --- a/src/betsy/EncoderBC1.cpp +++ b/src/betsy/EncoderBC1.cpp @@ -116,7 +116,7 @@ namespace betsy { bindTexture( 0u, m_srcTexture ); bindComputePso( m_bc1Pso ); - bindUav( 0u, m_bc1TargetRes, PFG_RG32_UINT, ResourceAccess::Write ); + bindUav( 0u, m_bc1TargetRes, PFG_RGBA16_UINT, ResourceAccess::Write ); bindUavBuffer( 1u, m_bc1TablesSsbo, 0u, sizeof( Bc1Tables ) ); glUniform1ui( 0, 2u ); @@ -128,7 +128,7 @@ namespace betsy { // Compress Alpha too (using BC4) bindComputePso( m_bc4Pso ); - bindUav( 0u, m_bc4TargetRes, PFG_RG32_UINT, ResourceAccess::Write ); + bindUav( 0u, m_bc4TargetRes, PFG_RGBA16_UINT, ResourceAccess::Write ); // p_channelIdx, p_useSNorm glUniform2f( 0, 3.0f, 0.0f ); diff --git a/src/betsy/EncoderBC4.cpp b/src/betsy/EncoderBC4.cpp index 37b0e1f..0df6832 100644 --- a/src/betsy/EncoderBC4.cpp +++ b/src/betsy/EncoderBC4.cpp @@ -107,7 +107,7 @@ namespace betsy const size_t numChannels = m_bc4TargetRes[1] ? 2u : 1u; for( size_t i = 0u; i < numChannels; ++i ) { - bindUav( 0u, m_bc4TargetRes[i], PFG_RG32_UINT, ResourceAccess::Write ); + bindUav( 0u, m_bc4TargetRes[i], PFG_RGBA16_UINT, ResourceAccess::Write ); // p_channelIdx, p_useSNorm glUniform2f( 0, i == 0u ? 0.0f : 1.0f, m_encodeSNorm ? 1.0f : 0.0f );