struct u_vbuf *vbuf;
struct u_vbuf *vbuf_current;
bool always_use_vbuf;
+ bool sampler_format;
boolean has_geometry_shader;
boolean has_tessellation;
ctx->has_streamout = TRUE;
}
+ if (pipe->screen->get_param(pipe->screen, PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK) &
+ PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_FREEDRENO)
+ ctx->sampler_format = true;
+
ctx->max_fs_samplerviews = pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_FRAGMENT,
PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
cso_set_vertex_elements_direct(ctx, velems);
}
-static bool
-cso_set_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
- unsigned idx, const struct pipe_sampler_state *templ)
+ALWAYS_INLINE static struct cso_sampler *
+set_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
+ unsigned idx, const struct pipe_sampler_state *templ, size_t key_size)
{
- unsigned key_size = sizeof(struct pipe_sampler_state);
unsigned hash_key = cso_construct_key((void*)templ, key_size);
struct cso_sampler *cso;
struct cso_hash_iter iter =
} else {
cso = cso_hash_iter_data(iter);
}
+ return cso;
+}
+ALWAYS_INLINE static bool
+cso_set_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
+ unsigned idx, const struct pipe_sampler_state *templ, size_t size)
+{
+ struct cso_sampler *cso = set_sampler(ctx, shader_stage, idx, templ, size);
ctx->samplers[shader_stage].cso_samplers[idx] = cso;
ctx->samplers[shader_stage].samplers[idx] = cso->data;
return true;
cso_single_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
unsigned idx, const struct pipe_sampler_state *templ)
{
- if (cso_set_sampler(ctx, shader_stage, idx, templ))
+ size_t size = ctx->sampler_format ? sizeof(struct pipe_sampler_state) :
+ offsetof(struct pipe_sampler_state, border_color_format);
+ if (cso_set_sampler(ctx, shader_stage, idx, templ, size))
ctx->max_sampler_seen = MAX2(ctx->max_sampler_seen, (int)idx);
}
ctx->max_sampler_seen = -1;
}
-
-/*
- * If the function encouters any errors it will return the
- * last one. Done to always try to set as many samplers
- * as possible.
- */
-void
-cso_set_samplers(struct cso_context *ctx,
- enum pipe_shader_type shader_stage,
- unsigned nr,
- const struct pipe_sampler_state **templates)
+ALWAYS_INLINE static int
+set_samplers(struct cso_context *ctx,
+ enum pipe_shader_type shader_stage,
+ unsigned nr,
+ const struct pipe_sampler_state **templates,
+ size_t key_size)
{
int last = -1;
-
for (unsigned i = 0; i < nr; i++) {
if (!templates[i])
continue;
*/
if (last >= 0 &&
!memcmp(templates[i], templates[last],
- sizeof(struct pipe_sampler_state))) {
+ key_size)) {
ctx->samplers[shader_stage].cso_samplers[i] =
ctx->samplers[shader_stage].cso_samplers[last];
ctx->samplers[shader_stage].samplers[i] =
ctx->samplers[shader_stage].samplers[last];
} else {
/* Look up the sampler state CSO. */
- cso_set_sampler(ctx, shader_stage, i, templates[i]);
+ cso_set_sampler(ctx, shader_stage, i, templates[i], key_size);
}
last = i;
}
+ return last;
+}
+
+/*
+ * If the function encouters any errors it will return the
+ * last one. Done to always try to set as many samplers
+ * as possible.
+ */
+void
+cso_set_samplers(struct cso_context *ctx,
+ enum pipe_shader_type shader_stage,
+ unsigned nr,
+ const struct pipe_sampler_state **templates)
+{
+ int last = -1;
+
+ /* ensure sampler size is a constant for memcmp */
+ size_t size = ctx->sampler_format ? sizeof(struct pipe_sampler_state) :
+ offsetof(struct pipe_sampler_state, border_color_format);
+ last = set_samplers(ctx, shader_stage, nr, templates, size);
ctx->max_sampler_seen = MAX2(ctx->max_sampler_seen, last);
cso_single_sampler_done(ctx, shader_stage);