memcpy(p + 4, default_inner_level, 2 * sizeof(float));
}
-struct tc_constant_buffer {
+struct tc_constant_buffer_info {
ubyte shader, index;
+ bool is_null;
+};
+
+struct tc_constant_buffer {
+ struct tc_constant_buffer_info info;
struct pipe_constant_buffer cb;
};
{
struct tc_constant_buffer *p = (struct tc_constant_buffer *)payload;
- pipe->set_constant_buffer(pipe, p->shader, p->index, true, &p->cb);
+ if (unlikely(p->info.is_null)) {
+ pipe->set_constant_buffer(pipe, p->info.shader, p->info.index, false, NULL);
+ return;
+ }
+
+ pipe->set_constant_buffer(pipe, p->info.shader, p->info.index, true, &p->cb);
}
static void
{
struct threaded_context *tc = threaded_context(_pipe);
- if (cb && cb->user_buffer) {
+ if (unlikely(!cb || (!cb->buffer && !cb->user_buffer))) {
+ struct tc_constant_buffer_info *p =
+ tc_add_struct_typed_call(tc, TC_CALL_set_constant_buffer,
+ tc_constant_buffer_info);
+ p->shader = shader;
+ p->index = index;
+ p->is_null = true;
+ return;
+ }
+
+ if (cb->user_buffer) {
struct pipe_resource *buffer = NULL;
unsigned offset;
struct tc_constant_buffer *p =
tc_add_struct_typed_call(tc, TC_CALL_set_constant_buffer,
tc_constant_buffer);
- p->shader = shader;
- p->index = index;
+ p->info.shader = shader;
+ p->info.index = index;
+ p->info.is_null = false;
p->cb.buffer_size = cb->buffer_size;
p->cb.user_buffer = NULL;
p->cb.buffer_offset = offset;
struct tc_constant_buffer *p =
tc_add_struct_typed_call(tc, TC_CALL_set_constant_buffer,
tc_constant_buffer);
- p->shader = shader;
- p->index = index;
-
- if (cb) {
- if (take_ownership)
- p->cb.buffer = cb->buffer;
- else
- tc_set_resource_reference(&p->cb.buffer, cb->buffer);
-
- p->cb.user_buffer = NULL;
- p->cb.buffer_offset = cb->buffer_offset;
- p->cb.buffer_size = cb->buffer_size;
- } else {
- memset(&p->cb, 0, sizeof(*cb));
- }
+ p->info.shader = shader;
+ p->info.index = index;
+ p->info.is_null = false;
+ p->cb.user_buffer = NULL;
+ p->cb.buffer_offset = cb->buffer_offset;
+ p->cb.buffer_size = cb->buffer_size;
+
+ if (take_ownership)
+ p->cb.buffer = cb->buffer;
+ else
+ tc_set_resource_reference(&p->cb.buffer, cb->buffer);
}
struct tc_inlinable_constants {