#define LP_BLD_SAMPLE_H
+#include "pipe/p_state.h"
#include "util/format/u_formats.h"
#include "util/u_debug.h"
#include "gallivm/lp_bld.h"
extern "C" {
#endif
-struct pipe_resource;
-struct pipe_sampler_view;
-struct pipe_sampler_state;
-struct pipe_image_view;
struct util_format_description;
struct lp_type;
struct lp_build_context;
lp_build_swizzle_soa_inplace(&bld->texel_bld, texel, swizzles);
}
-
/*
* not really dimension as such, this indicates the amount of
* "normal" texture coords subject to minification, wrapping etc.
}
} else {
/*
- * For buffers, we don't have "offset", instead adjust
- * the size (stored as width) plus the base pointer.
+ * For tex2d_from_buf, adjust width and height with application
+ * values. If is_tex2d_from_buf is false (1D images),
+ * adjust using size value (stored as width).
*/
unsigned view_blocksize = util_format_get_blocksize(view->format);
- /* probably don't really need to fill that out */
+
jit_tex->mip_offsets[0] = 0;
- jit_tex->row_stride[0] = 0;
jit_tex->img_stride[0] = 0;
- /* everything specified in number of elements here. */
- jit_tex->width = view->u.buf.size / view_blocksize;
- jit_tex->base = (uint8_t *)jit_tex->base + view->u.buf.offset;
- /* XXX Unsure if we need to sanitize parameters? */
- assert(view->u.buf.offset + view->u.buf.size <= res->width0);
+ /* If it's not a 2D texture view of a buffer, adjust using size. */
+ if (!view->is_tex2d_from_buf) {
+ /* everything specified in number of elements here. */
+ jit_tex->width = view->u.buf.size / view_blocksize;
+ jit_tex->row_stride[0] = 0;
+
+ /* Adjust base pointer with offset. */
+ jit_tex->base = (uint8_t *)jit_tex->base + view->u.buf.offset;
+
+ /* XXX Unsure if we need to sanitize parameters? */
+ assert(view->u.buf.offset + view->u.buf.size <= res->width0);
+ } else {
+ jit_tex->width = view->u.tex2d_from_buf.width;
+ jit_tex->height = view->u.tex2d_from_buf.height;
+ jit_tex->row_stride[0] = view->u.tex2d_from_buf.row_stride * view_blocksize;
+
+ jit_tex->base = (uint8_t *)jit_tex->base +
+ view->u.tex2d_from_buf.offset * view_blocksize;
+ }
}
}
} else {
jit_image->sample_stride = lp_res->sample_stride;
jit_image->base = (uint8_t *)jit_image->base + mip_offset;
} else {
- unsigned view_blocksize = util_format_get_blocksize(image->format);
- jit_image->width = image->u.buf.size / view_blocksize;
- jit_image->base = (uint8_t *)jit_image->base + image->u.buf.offset;
+ unsigned image_blocksize = util_format_get_blocksize(image->format);
+
+ jit_image->img_stride = 0;
+
+ /* If it's not a 2D image view of a buffer, adjust using size. */
+ if (!(image->access & PIPE_IMAGE_ACCESS_TEX2D_FROM_BUFFER)) {
+ /* everything specified in number of elements here. */
+ jit_image->width = image->u.buf.size / image_blocksize;
+ jit_image->row_stride = 0;
+
+ /* Adjust base pointer with offset. */
+ jit_image->base = (uint8_t *)jit_image->base + image->u.buf.offset;
+
+ /* XXX Unsure if we need to sanitize parameters? */
+ assert(image->u.buf.offset + image->u.buf.size <= res->width0);
+ } else {
+ jit_image->width = image->u.tex2d_from_buf.width;
+ jit_image->height = image->u.tex2d_from_buf.height;
+ jit_image->row_stride = image->u.tex2d_from_buf.row_stride * image_blocksize;
+
+ jit_image->base = (uint8_t *)jit_image->base +
+ image->u.tex2d_from_buf.offset * image_blocksize;
+ }
}
}
}