Skip to content

Commit

Permalink
HLSL: various changes similar to Metal side
Browse files Browse the repository at this point in the history
- change "uber" manually spelled 3 iterations into a loop
- merge compute_least_squares_endpoints_rgba and compute_least_squares_endpoints_rgb
- small cleanup
- remove OPT_OPAQUE_ONLY mode
- fixed not properly skipping some non-mode6 passes in ultrafast setting
- fixed non-perceptual due to mixed up arguments to select()
  • Loading branch information
aras-p committed Jan 5, 2021
1 parent 235533c commit e071892
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 200 deletions.
210 changes: 46 additions & 164 deletions src/shaders/hlsl/bc7e.hlsl

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions src/shaders/hlsl/bc7e_compress_blocks_mode0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode0(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,15 +19,13 @@ void bc7e_compress_blocks_mode0(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
return;
}
else
#endif
{
if (!(g_params.m_opaq_use_modes0123 & 0xFF))
if (!(g_params.m_opaq_use_modes0123 & 0xFF) || glob_is_mode6_only())
return;
uint4 lists = s_BufOutput[block_index];
handle_opaque_block_mode0(res, pixels, params, lists);
Expand Down
5 changes: 1 addition & 4 deletions src/shaders/hlsl/bc7e_compress_blocks_mode1.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode1(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,15 +19,13 @@ void bc7e_compress_blocks_mode1(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
return;
}
else
#endif
{
if (!(g_params.m_opaq_use_modes0123 & 0xFF00))
if (!(g_params.m_opaq_use_modes0123 & 0xFF00) || glob_is_mode6_only())
return;
uint4 lists = s_BufOutput[block_index];
handle_opaque_block_mode1(res, pixels, params, lists);
Expand Down
5 changes: 1 addition & 4 deletions src/shaders/hlsl/bc7e_compress_blocks_mode2.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode2(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,15 +19,13 @@ void bc7e_compress_blocks_mode2(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
return;
}
else
#endif
{
if (!(g_params.m_opaq_use_modes0123 & 0xFF0000))
if (!(g_params.m_opaq_use_modes0123 & 0xFF0000) || glob_is_mode6_only())
return;
uint4 lists = s_BufOutput[block_index];
handle_opaque_block_mode2(res, pixels, params, lists);
Expand Down
5 changes: 1 addition & 4 deletions src/shaders/hlsl/bc7e_compress_blocks_mode3.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode3(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,15 +19,13 @@ void bc7e_compress_blocks_mode3(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
return;
}
else
#endif
{
if (!(g_params.m_opaq_use_modes0123 & 0xFF000000))
if (!(g_params.m_opaq_use_modes0123 & 0xFF000000) || glob_is_mode6_only())
return;
uint4 lists = s_BufOutput[block_index];
handle_opaque_block_mode3(res, pixels, params, lists);
Expand Down
3 changes: 0 additions & 3 deletions src/shaders/hlsl/bc7e_compress_blocks_mode4_alpha.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode4_alpha(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,7 +19,6 @@ void bc7e_compress_blocks_mode4_alpha(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
if (!(g_params.m_alpha_use_modes4567 & 0xFF))
Expand All @@ -29,7 +27,6 @@ void bc7e_compress_blocks_mode4_alpha(uint3 id : SV_DispatchThreadID)
handle_block_mode4(res, pixels, params, lo_a, hi_a, num_rotations);
}
else
#endif
{
return;
}
Expand Down
3 changes: 0 additions & 3 deletions src/shaders/hlsl/bc7e_compress_blocks_mode4_opaq.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode4_opaq(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,13 +19,11 @@ void bc7e_compress_blocks_mode4_opaq(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
return;
}
else
#endif
{
#ifdef OPT_ULTRAFAST_ONLY
return;
Expand Down
5 changes: 1 addition & 4 deletions src/shaders/hlsl/bc7e_compress_blocks_mode5.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode5(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,17 +19,15 @@ void bc7e_compress_blocks_mode5(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
if (!(g_params.m_alpha_use_modes4567 & 0xFF00))
return;
handle_alpha_block_mode5(res, pixels, params, lo_a, hi_a);
}
else
#endif
{
if (glob_is_perceptual() || !(g_params.m_opaq_use_modes456 & 0xFF00))
if (glob_is_perceptual() || !(g_params.m_opaq_use_modes456 & 0xFF00) || glob_is_mode6_only())
return;
handle_opaque_block_mode5(res, pixels, params);
}
Expand Down
3 changes: 0 additions & 3 deletions src/shaders/hlsl/bc7e_compress_blocks_mode6.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode6(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,14 +19,12 @@ void bc7e_compress_blocks_mode6(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
if (!(g_params.m_alpha_use_modes4567 & 0xFF0000))
return;
}
else
#endif
{
if (!(g_params.m_opaq_use_modes456 & 0xFF0000))
return;
Expand Down
3 changes: 0 additions & 3 deletions src/shaders/hlsl/bc7e_compress_blocks_mode7.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void bc7e_compress_blocks_mode7(uint3 id : SV_DispatchThreadID)

color_cell_compressor_params params;
color_cell_compressor_params_clear(params);
params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
Expand All @@ -20,7 +19,6 @@ void bc7e_compress_blocks_mode7(uint3 id : SV_DispatchThreadID)
bc7_optimization_results res = (bc7_optimization_results)0;
res.m_error = prev_error;

#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
{
# if defined(OPT_ULTRAFAST_ONLY)
Expand All @@ -33,7 +31,6 @@ void bc7e_compress_blocks_mode7(uint3 id : SV_DispatchThreadID)
# endif
}
else
#endif
{
return;
}
Expand Down
4 changes: 0 additions & 4 deletions src/shaders/hlsl/bc7e_estimate_partition_lists.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@ void bc7e_estimate_partition_lists(uint3 id : SV_DispatchThreadID)
color_cell_compressor_params params;
color_cell_compressor_params_clear(params);

params.m_weights = g_params.m_weights;

color_quad_i pixels[16];
float lo_a, hi_a;
load_pixel_block(pixels, lo_a, hi_a, id, g_width);

const bool has_alpha = (lo_a < 255);

uint4 lists = 0;
#if !defined(OPT_OPAQUE_ONLY)
if (has_alpha)
lists = get_lists_alpha(pixels);
else
#endif
{
#ifdef OPT_ULTRAFAST_ONLY
;
Expand Down

0 comments on commit e071892

Please sign in to comment.