@@ -104,35 +104,46 @@ static inline uint8<4> resample_internal(const uniform Image src_image, const fl
104104
105105export void resample (
106106 uniform const Parameters * uniform params,
107- uniform const Image * uniform src,
108- uniform Image * uniform dst,
107+
108+ // TODO: Use the builtin type when ISPC 1.22 is released
109+ // https://github.com/ispc/ispc/issues/2650
110+ // https://github.com/ispc/ispc/pull/2654
111+ // uniform const Image &uniform src,
112+ // uniform Image &uniform dst,
113+ uniform uint32 width, uniform uint32 height,
114+ uniform const uint8 src_data[],
115+ uniform uint32 target_width, uniform uint32 target_height,
116+ uniform uint8 dst_data[],
117+
109118 // Passed separately because it should be the same between input and output:
110119 uniform uint8 num_channels
111120) {
112- const uniform float < 2 > inv_target_size = 1.0f / dst-> size;
121+ const uniform Image src = {src_data, {width, height}};
122+ const uniform Image dst = {dst_data, {target_width, target_height}};
123+ const uniform float < 2 > inv_target_size = 1.0f / dst. size;
113124
114125 if (params-> degamma) {
115- foreach_tiled (y = 0 ... src-> size. y, x = 0 ... src-> size. x)
126+ foreach_tiled (y = 0 ... src. size. y, x = 0 ... src. size. x)
116127 {
117- uint p = (x + y * src-> size. x) * num_channels;
128+ uint p = (x + y * src. size. x) * num_channels;
118129 for (uniform int i = 0 ; i < num_channels; i++ ) {
119130 uint c = p + i;
120131 // TODO: This texture should be writeonly!
121- src-> data[c] = float_to_byte (pow (byte_to_float (src-> data[c]), GAMMA ), false );
132+ src. data[c] = float_to_byte (pow (byte_to_float (src. data[c]), GAMMA ), false );
122133 }
123134 }
124135 }
125136
126- foreach_tiled (y = 0 ... dst-> size. y, x = 0 ... dst-> size. x) {
137+ foreach_tiled (y = 0 ... dst. size. y, x = 0 ... dst. size. x) {
127138 float < 2 > uv = {x, y};
128139 // Use the center of each pixel, not the top-left:
129140 uv += 0.5f ;
130141 // Convert to uniform space:
131142 uv *= inv_target_size;
132143
133- const float < 4 > col = resample_internal (* src, uv, num_channels);
144+ const float < 4 > col = resample_internal (src, uv, num_channels);
134145
135146 for (uniform int i = 0 ; i < num_channels; i++ )
136- dst-> data[(x + y * dst-> size. x) * num_channels + i] = float_to_byte (col[i], params-> gamma);
147+ dst. data[(x + y * dst. size. x) * num_channels + i] = float_to_byte (col[i], params-> gamma);
137148 }
138149}
0 commit comments