* If none is found an empty slot is initialized with a
* template and returned instead.
*/
-static struct pipe_sampler_view **
+static struct st_sampler_view *
st_texture_get_sampler_view(struct st_context *st,
struct st_texture_object *stObj)
{
- struct pipe_sampler_view **free = NULL;
+ struct st_sampler_view *free = NULL;
GLuint i;
for (i = 0; i < stObj->num_sampler_views; ++i) {
- struct pipe_sampler_view **sv = &stObj->sampler_views[i];
+ struct st_sampler_view *sv = &stObj->sampler_views[i];
/* Is the array entry used ? */
- if (*sv) {
+ if (sv->view) {
/* check if the context matches */
- if ((*sv)->context == st->pipe) {
+ if (sv->view->context == st->pipe) {
return sv;
}
} else {
if (!free) {
/* Haven't even found a free one, resize the array */
unsigned new_size = (stObj->num_sampler_views + 1) *
- sizeof(struct pipe_sampler_view *);
+ sizeof(struct st_sampler_view);
stObj->sampler_views = realloc(stObj->sampler_views, new_size);
free = &stObj->sampler_views[stObj->num_sampler_views++];
- *free = NULL;
+ free->view = NULL;
}
- assert(*free == NULL);
+ assert(free->view == NULL);
return free;
}
GLuint i;
for (i = 0; i < stObj->num_sampler_views; ++i) {
- struct pipe_sampler_view **sv = &stObj->sampler_views[i];
+ struct pipe_sampler_view **sv = &stObj->sampler_views[i].view;
if (*sv && (*sv)->context == st->pipe) {
pipe_sampler_view_reference(sv, NULL);
/* XXX This should use sampler_views[i]->pipe, not st->pipe */
for (i = 0; i < stObj->num_sampler_views; ++i)
- pipe_sampler_view_release(st->pipe, &stObj->sampler_views[i]);
+ pipe_sampler_view_release(st->pipe, &stObj->sampler_views[i].view);
}
const struct gl_sampler_object *samp,
bool glsl130_or_later)
{
- struct pipe_sampler_view **sv;
+ struct st_sampler_view *sv;
+ struct pipe_sampler_view *view;
sv = st_texture_get_sampler_view(st, stObj);
+ view = sv->view;
- if (*sv) {
+ if (view &&
+ sv->glsl130_or_later == glsl130_or_later &&
+ sv->sRGBDecode == samp->sRGBDecode) {
/* Debug check: make sure that the sampler view's parameters are
* what they're supposed to be.
*/
- MAYBE_UNUSED struct pipe_sampler_view *view = *sv;
+ MAYBE_UNUSED struct pipe_sampler_view *view = sv->view;
assert(stObj->pt == view->texture);
assert(!check_sampler_swizzle(st, stObj, view, glsl130_or_later));
assert(get_sampler_view_format(st, stObj, samp) == view->format);
/* create new sampler view */
enum pipe_format format = get_sampler_view_format(st, stObj, samp);
- *sv = st_create_texture_sampler_view_from_stobj(st, stObj,
- format, glsl130_or_later);
+ sv->glsl130_or_later = glsl130_or_later;
+ sv->sRGBDecode = samp->sRGBDecode;
+ pipe_sampler_view_release(st->pipe, &sv->view);
+ view = sv->view =
+ st_create_texture_sampler_view_from_stobj(st, stObj, format, glsl130_or_later);
}
- return *sv;
+ return view;
}
st_get_buffer_sampler_view_from_stobj(struct st_context *st,
struct st_texture_object *stObj)
{
- struct pipe_sampler_view **sv;
+ struct st_sampler_view *sv;
struct st_buffer_object *stBuf =
st_buffer_object(stObj->base.BufferObject);
sv = st_texture_get_sampler_view(st, stObj);
struct pipe_resource *buf = stBuf->buffer;
- struct pipe_sampler_view *view = *sv;
+ struct pipe_sampler_view *view = sv->view;
if (view && view->texture == buf) {
/* Debug check: make sure that the sampler view's parameters are
templ.u.buf.offset = base;
templ.u.buf.size = size;
- pipe_sampler_view_reference(sv, NULL);
- *sv = st->pipe->create_sampler_view(st->pipe, buf, &templ);
+ pipe_sampler_view_release(st->pipe, &sv->view);
+ view = sv->view = st->pipe->create_sampler_view(st->pipe, buf, &templ);
}
- return *sv;
+ return view;
}
};
+/**
+ * Container for one context's validated sampler view.
+ */
+struct st_sampler_view {
+ struct pipe_sampler_view *view;
+
+ /** The glsl version of the shader seen during validation */
+ bool glsl130_or_later;
+ /** The value of the sampler's sRGBDecode state during validation */
+ GLenum sRGBDecode;
+};
+
+
/**
* Subclass of gl_texure_image.
*/
/* Array of sampler views (one per context) attached to this texture
* object. Created lazily on first binding in context.
*/
- struct pipe_sampler_view **sampler_views;
+ struct st_sampler_view *sampler_views;
/* True if this texture comes from the window system. Such a texture
* cannot be reallocated and the format can only be changed with a sampler
*/
uint layer_override;
- /** The glsl version of the shader seen during the previous validation */
- bool prev_glsl130_or_later;
- /** The value of the sampler's sRGBDecode state at the previous validation */
- GLenum prev_sRGBDecode;
-
/**
* Set when the texture images of this texture object might not all be in
* the pipe_resource *pt above.