mirror of
https://github.com/nothings/stb
synced 2024-12-15 04:22:35 +03:00
Reorder these loops because I think we get a cache win if we write the entire ring buffer entry at once.
This commit is contained in:
parent
01fb58d6b4
commit
155c71fb90
@ -777,26 +777,26 @@ static void stbr__resample_vertical_downsample(stbr__info* stbr_info, int n, int
|
|||||||
|
|
||||||
int n0 = vertical_contributors->n0;
|
int n0 = vertical_contributors->n0;
|
||||||
int n1 = vertical_contributors->n1;
|
int n1 = vertical_contributors->n1;
|
||||||
|
int max_n = stbr__min(n1, output_h - 1);
|
||||||
|
|
||||||
stbr__output_decode_coefficients output_decode_coefficients_fn = stbr__get_output_decode_coefficients_function(channels);
|
stbr__output_decode_coefficients output_decode_coefficients_fn = stbr__get_output_decode_coefficients_function(channels);
|
||||||
|
|
||||||
STBR_DEBUG_ASSERT(!stbr__use_height_upsampling(stbr_info));
|
STBR_DEBUG_ASSERT(!stbr__use_height_upsampling(stbr_info));
|
||||||
STBR_DEBUG_ASSERT(n0 >= in_first_scanline);
|
STBR_DEBUG_ASSERT(n0 >= in_first_scanline);
|
||||||
STBR_DEBUG_ASSERT(n1 <= in_last_scanline);
|
STBR_DEBUG_ASSERT(n1 <= in_last_scanline);
|
||||||
|
STBR_DEBUG_ASSERT(n1 >= n0);
|
||||||
|
|
||||||
for (x = 0; x < output_w; x++)
|
// Using min and max to avoid writing into ring buffers that will be thrown out.
|
||||||
|
for (k = stbr__max(n0, 0); k <= max_n; k++)
|
||||||
{
|
{
|
||||||
int in_texel_index = x * channels;
|
int coefficient_index = k - n0;
|
||||||
int max_n = stbr__min(n1, output_h-1);
|
|
||||||
|
|
||||||
STBR_DEBUG_ASSERT(n1 >= n0);
|
float* ring_buffer_entry = stbr__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_texel_width, ring_buffer_length);
|
||||||
|
float coefficient = vertical_coefficients[coefficient_index];
|
||||||
|
|
||||||
// Using min and max to avoid writing into ring buffers that will be thrown out.
|
for (x = 0; x < output_w; x++)
|
||||||
for (k = stbr__max(n0, 0); k <= max_n; k++)
|
|
||||||
{
|
{
|
||||||
int coefficient_index = k - n0;
|
int in_texel_index = x * channels;
|
||||||
float* ring_buffer_entry = stbr__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, kernel_texel_width, ring_buffer_length);
|
|
||||||
float coefficient = vertical_coefficients[coefficient_index];
|
|
||||||
|
|
||||||
output_decode_coefficients_fn(ring_buffer_entry, in_texel_index, horizontal_buffer, in_texel_index, channels, coefficient);
|
output_decode_coefficients_fn(ring_buffer_entry, in_texel_index, horizontal_buffer, in_texel_index, channels, coefficient);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user