bceff68114
Make them akin to shader buffers, with no refcounting/etc. Just used to pass data about the bound image in ->set_shader_images. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
746 lines
23 KiB
C
746 lines
23 KiB
C
/**************************************************************************
|
|
*
|
|
* Copyright 2015 Advanced Micro Devices, Inc.
|
|
* Copyright 2008 VMware, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
|
* license, and/or sell copies of the Software, and to permit persons to whom
|
|
* the Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
**************************************************************************/
|
|
|
|
#include "dd_pipe.h"
|
|
#include "tgsi/tgsi_parse.h"
|
|
#include "util/u_memory.h"
|
|
|
|
|
|
static void
|
|
safe_memcpy(void *dst, const void *src, size_t size)
|
|
{
|
|
if (src)
|
|
memcpy(dst, src, size);
|
|
else
|
|
memset(dst, 0, size);
|
|
}
|
|
|
|
|
|
/********************************************************************
|
|
* queries
|
|
*/
|
|
|
|
static struct dd_query *
|
|
dd_query(struct pipe_query *query)
|
|
{
|
|
return (struct dd_query *)query;
|
|
}
|
|
|
|
static struct pipe_query *
|
|
dd_query_unwrap(struct pipe_query *query)
|
|
{
|
|
if (query) {
|
|
return dd_query(query)->query;
|
|
} else {
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
static struct pipe_query *
|
|
dd_context_create_query(struct pipe_context *_pipe, unsigned query_type,
|
|
unsigned index)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
struct pipe_query *query;
|
|
|
|
query = pipe->create_query(pipe, query_type, index);
|
|
|
|
/* Wrap query object. */
|
|
if (query) {
|
|
struct dd_query *dd_query = CALLOC_STRUCT(dd_query);
|
|
if (dd_query) {
|
|
dd_query->type = query_type;
|
|
dd_query->query = query;
|
|
query = (struct pipe_query *)dd_query;
|
|
} else {
|
|
pipe->destroy_query(pipe, query);
|
|
query = NULL;
|
|
}
|
|
}
|
|
|
|
return query;
|
|
}
|
|
|
|
static void
|
|
dd_context_destroy_query(struct pipe_context *_pipe,
|
|
struct pipe_query *query)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->destroy_query(pipe, dd_query_unwrap(query));
|
|
FREE(query);
|
|
}
|
|
|
|
static boolean
|
|
dd_context_begin_query(struct pipe_context *_pipe, struct pipe_query *query)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
return pipe->begin_query(pipe, dd_query_unwrap(query));
|
|
}
|
|
|
|
static void
|
|
dd_context_end_query(struct pipe_context *_pipe, struct pipe_query *query)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
pipe->end_query(pipe, dd_query_unwrap(query));
|
|
}
|
|
|
|
static boolean
|
|
dd_context_get_query_result(struct pipe_context *_pipe,
|
|
struct pipe_query *query, boolean wait,
|
|
union pipe_query_result *result)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
return pipe->get_query_result(pipe, dd_query_unwrap(query), wait, result);
|
|
}
|
|
|
|
static void
|
|
dd_context_render_condition(struct pipe_context *_pipe,
|
|
struct pipe_query *query, boolean condition,
|
|
uint mode)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
pipe->render_condition(pipe, dd_query_unwrap(query), condition, mode);
|
|
dctx->render_cond.query = dd_query(query);
|
|
dctx->render_cond.condition = condition;
|
|
dctx->render_cond.mode = mode;
|
|
}
|
|
|
|
|
|
/********************************************************************
|
|
* constant (immutable) non-shader states
|
|
*/
|
|
|
|
#define DD_CSO_CREATE(name, shortname) \
|
|
static void * \
|
|
dd_context_create_##name##_state(struct pipe_context *_pipe, \
|
|
const struct pipe_##name##_state *state) \
|
|
{ \
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe; \
|
|
struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
|
|
\
|
|
if (!hstate) \
|
|
return NULL; \
|
|
hstate->cso = pipe->create_##name##_state(pipe, state); \
|
|
hstate->state.shortname = *state; \
|
|
return hstate; \
|
|
}
|
|
|
|
#define DD_CSO_BIND(name, shortname) \
|
|
static void \
|
|
dd_context_bind_##name##_state(struct pipe_context *_pipe, void *state) \
|
|
{ \
|
|
struct dd_context *dctx = dd_context(_pipe); \
|
|
struct pipe_context *pipe = dctx->pipe; \
|
|
struct dd_state *hstate = state; \
|
|
\
|
|
dctx->shortname = hstate; \
|
|
pipe->bind_##name##_state(pipe, hstate ? hstate->cso : NULL); \
|
|
}
|
|
|
|
#define DD_CSO_DELETE(name) \
|
|
static void \
|
|
dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
|
|
{ \
|
|
struct dd_context *dctx = dd_context(_pipe); \
|
|
struct pipe_context *pipe = dctx->pipe; \
|
|
struct dd_state *hstate = state; \
|
|
\
|
|
pipe->delete_##name##_state(pipe, hstate->cso); \
|
|
FREE(hstate); \
|
|
}
|
|
|
|
#define DD_CSO_WHOLE(name, shortname) \
|
|
DD_CSO_CREATE(name, shortname) \
|
|
DD_CSO_BIND(name, shortname) \
|
|
DD_CSO_DELETE(name)
|
|
|
|
DD_CSO_WHOLE(blend, blend)
|
|
DD_CSO_WHOLE(rasterizer, rs)
|
|
DD_CSO_WHOLE(depth_stencil_alpha, dsa)
|
|
|
|
DD_CSO_CREATE(sampler, sampler)
|
|
DD_CSO_DELETE(sampler)
|
|
|
|
static void
|
|
dd_context_bind_sampler_states(struct pipe_context *_pipe, unsigned shader,
|
|
unsigned start, unsigned count, void **states)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
memcpy(&dctx->sampler_states[shader][start], states,
|
|
sizeof(void*) * count);
|
|
|
|
if (states) {
|
|
void *samp[PIPE_MAX_SAMPLERS];
|
|
int i;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
struct dd_state *s = states[i];
|
|
samp[i] = s ? s->cso : NULL;
|
|
}
|
|
|
|
pipe->bind_sampler_states(pipe, shader, start, count, samp);
|
|
}
|
|
else
|
|
pipe->bind_sampler_states(pipe, shader, start, count, NULL);
|
|
}
|
|
|
|
static void *
|
|
dd_context_create_vertex_elements_state(struct pipe_context *_pipe,
|
|
unsigned num_elems,
|
|
const struct pipe_vertex_element *elems)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
struct dd_state *hstate = CALLOC_STRUCT(dd_state);
|
|
|
|
if (!hstate)
|
|
return NULL;
|
|
hstate->cso = pipe->create_vertex_elements_state(pipe, num_elems, elems);
|
|
memcpy(hstate->state.velems.velems, elems, sizeof(elems[0]) * num_elems);
|
|
hstate->state.velems.count = num_elems;
|
|
return hstate;
|
|
}
|
|
|
|
DD_CSO_BIND(vertex_elements, velems)
|
|
DD_CSO_DELETE(vertex_elements)
|
|
|
|
|
|
/********************************************************************
|
|
* shaders
|
|
*/
|
|
|
|
#define DD_SHADER(NAME, name) \
|
|
static void * \
|
|
dd_context_create_##name##_state(struct pipe_context *_pipe, \
|
|
const struct pipe_shader_state *state) \
|
|
{ \
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe; \
|
|
struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
|
|
\
|
|
if (!hstate) \
|
|
return NULL; \
|
|
hstate->cso = pipe->create_##name##_state(pipe, state); \
|
|
hstate->state.shader = *state; \
|
|
hstate->state.shader.tokens = tgsi_dup_tokens(state->tokens); \
|
|
return hstate; \
|
|
} \
|
|
\
|
|
static void \
|
|
dd_context_bind_##name##_state(struct pipe_context *_pipe, void *state) \
|
|
{ \
|
|
struct dd_context *dctx = dd_context(_pipe); \
|
|
struct pipe_context *pipe = dctx->pipe; \
|
|
struct dd_state *hstate = state; \
|
|
\
|
|
dctx->shaders[PIPE_SHADER_##NAME] = hstate; \
|
|
pipe->bind_##name##_state(pipe, hstate ? hstate->cso : NULL); \
|
|
} \
|
|
\
|
|
static void \
|
|
dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
|
|
{ \
|
|
struct dd_context *dctx = dd_context(_pipe); \
|
|
struct pipe_context *pipe = dctx->pipe; \
|
|
struct dd_state *hstate = state; \
|
|
\
|
|
pipe->delete_##name##_state(pipe, hstate->cso); \
|
|
tgsi_free_tokens(hstate->state.shader.tokens); \
|
|
FREE(hstate); \
|
|
}
|
|
|
|
DD_SHADER(FRAGMENT, fs)
|
|
DD_SHADER(VERTEX, vs)
|
|
DD_SHADER(GEOMETRY, gs)
|
|
DD_SHADER(TESS_CTRL, tcs)
|
|
DD_SHADER(TESS_EVAL, tes)
|
|
|
|
|
|
/********************************************************************
|
|
* immediate states
|
|
*/
|
|
|
|
#define DD_IMM_STATE(name, type, deref, ref) \
|
|
static void \
|
|
dd_context_set_##name(struct pipe_context *_pipe, type deref) \
|
|
{ \
|
|
struct dd_context *dctx = dd_context(_pipe); \
|
|
struct pipe_context *pipe = dctx->pipe; \
|
|
\
|
|
dctx->name = deref; \
|
|
pipe->set_##name(pipe, ref); \
|
|
}
|
|
|
|
DD_IMM_STATE(blend_color, const struct pipe_blend_color, *state, state)
|
|
DD_IMM_STATE(stencil_ref, const struct pipe_stencil_ref, *state, state)
|
|
DD_IMM_STATE(clip_state, const struct pipe_clip_state, *state, state)
|
|
DD_IMM_STATE(sample_mask, unsigned, sample_mask, sample_mask)
|
|
DD_IMM_STATE(min_samples, unsigned, min_samples, min_samples)
|
|
DD_IMM_STATE(framebuffer_state, const struct pipe_framebuffer_state, *state, state)
|
|
DD_IMM_STATE(polygon_stipple, const struct pipe_poly_stipple, *state, state)
|
|
|
|
static void
|
|
dd_context_set_constant_buffer(struct pipe_context *_pipe,
|
|
uint shader, uint index,
|
|
struct pipe_constant_buffer *constant_buffer)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->constant_buffers[shader][index], constant_buffer,
|
|
sizeof(*constant_buffer));
|
|
pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_scissor_states(struct pipe_context *_pipe,
|
|
unsigned start_slot, unsigned num_scissors,
|
|
const struct pipe_scissor_state *states)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->scissors[start_slot], states,
|
|
sizeof(*states) * num_scissors);
|
|
pipe->set_scissor_states(pipe, start_slot, num_scissors, states);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_viewport_states(struct pipe_context *_pipe,
|
|
unsigned start_slot, unsigned num_viewports,
|
|
const struct pipe_viewport_state *states)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->viewports[start_slot], states,
|
|
sizeof(*states) * num_viewports);
|
|
pipe->set_viewport_states(pipe, start_slot, num_viewports, states);
|
|
}
|
|
|
|
static void dd_context_set_tess_state(struct pipe_context *_pipe,
|
|
const float default_outer_level[4],
|
|
const float default_inner_level[2])
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
memcpy(dctx->tess_default_levels, default_outer_level, sizeof(float) * 4);
|
|
memcpy(dctx->tess_default_levels+4, default_inner_level, sizeof(float) * 2);
|
|
pipe->set_tess_state(pipe, default_outer_level, default_inner_level);
|
|
}
|
|
|
|
|
|
/********************************************************************
|
|
* views
|
|
*/
|
|
|
|
static struct pipe_surface *
|
|
dd_context_create_surface(struct pipe_context *_pipe,
|
|
struct pipe_resource *resource,
|
|
const struct pipe_surface *surf_tmpl)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
struct pipe_surface *view =
|
|
pipe->create_surface(pipe, resource, surf_tmpl);
|
|
|
|
if (!view)
|
|
return NULL;
|
|
view->context = _pipe;
|
|
return view;
|
|
}
|
|
|
|
static void
|
|
dd_context_surface_destroy(struct pipe_context *_pipe,
|
|
struct pipe_surface *surf)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->surface_destroy(pipe, surf);
|
|
}
|
|
|
|
static struct pipe_sampler_view *
|
|
dd_context_create_sampler_view(struct pipe_context *_pipe,
|
|
struct pipe_resource *resource,
|
|
const struct pipe_sampler_view *templ)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
struct pipe_sampler_view *view =
|
|
pipe->create_sampler_view(pipe, resource, templ);
|
|
|
|
if (!view)
|
|
return NULL;
|
|
view->context = _pipe;
|
|
return view;
|
|
}
|
|
|
|
static void
|
|
dd_context_sampler_view_destroy(struct pipe_context *_pipe,
|
|
struct pipe_sampler_view *view)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->sampler_view_destroy(pipe, view);
|
|
}
|
|
|
|
static struct pipe_stream_output_target *
|
|
dd_context_create_stream_output_target(struct pipe_context *_pipe,
|
|
struct pipe_resource *res,
|
|
unsigned buffer_offset,
|
|
unsigned buffer_size)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
struct pipe_stream_output_target *view =
|
|
pipe->create_stream_output_target(pipe, res, buffer_offset,
|
|
buffer_size);
|
|
|
|
if (!view)
|
|
return NULL;
|
|
view->context = _pipe;
|
|
return view;
|
|
}
|
|
|
|
static void
|
|
dd_context_stream_output_target_destroy(struct pipe_context *_pipe,
|
|
struct pipe_stream_output_target *target)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->stream_output_target_destroy(pipe, target);
|
|
}
|
|
|
|
|
|
/********************************************************************
|
|
* set states
|
|
*/
|
|
|
|
static void
|
|
dd_context_set_sampler_views(struct pipe_context *_pipe, unsigned shader,
|
|
unsigned start, unsigned num,
|
|
struct pipe_sampler_view **views)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->sampler_views[shader][start], views,
|
|
sizeof(views[0]) * num);
|
|
pipe->set_sampler_views(pipe, shader, start, num, views);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_shader_images(struct pipe_context *_pipe, unsigned shader,
|
|
unsigned start, unsigned num,
|
|
struct pipe_image_view *views)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->shader_images[shader][start], views,
|
|
sizeof(views[0]) * num);
|
|
pipe->set_shader_images(pipe, shader, start, num, views);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_shader_buffers(struct pipe_context *_pipe, unsigned shader,
|
|
unsigned start, unsigned num_buffers,
|
|
struct pipe_shader_buffer *buffers)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->shader_buffers[shader][start], buffers,
|
|
sizeof(buffers[0]) * num_buffers);
|
|
pipe->set_shader_buffers(pipe, shader, start, num_buffers, buffers);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_vertex_buffers(struct pipe_context *_pipe,
|
|
unsigned start, unsigned num_buffers,
|
|
const struct pipe_vertex_buffer *buffers)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->vertex_buffers[start], buffers,
|
|
sizeof(buffers[0]) * num_buffers);
|
|
pipe->set_vertex_buffers(pipe, start, num_buffers, buffers);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_index_buffer(struct pipe_context *_pipe,
|
|
const struct pipe_index_buffer *ib)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
safe_memcpy(&dctx->index_buffer, ib, sizeof(*ib));
|
|
pipe->set_index_buffer(pipe, ib);
|
|
}
|
|
|
|
static void
|
|
dd_context_set_stream_output_targets(struct pipe_context *_pipe,
|
|
unsigned num_targets,
|
|
struct pipe_stream_output_target **tgs,
|
|
const unsigned *offsets)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
dctx->num_so_targets = num_targets;
|
|
safe_memcpy(dctx->so_targets, tgs, sizeof(*tgs) * num_targets);
|
|
safe_memcpy(dctx->so_offsets, offsets, sizeof(*offsets) * num_targets);
|
|
pipe->set_stream_output_targets(pipe, num_targets, tgs, offsets);
|
|
}
|
|
|
|
static void
|
|
dd_context_destroy(struct pipe_context *_pipe)
|
|
{
|
|
struct dd_context *dctx = dd_context(_pipe);
|
|
struct pipe_context *pipe = dctx->pipe;
|
|
|
|
pipe->destroy(pipe);
|
|
FREE(dctx);
|
|
}
|
|
|
|
|
|
/********************************************************************
|
|
* transfer
|
|
*/
|
|
|
|
static void *
|
|
dd_context_transfer_map(struct pipe_context *_pipe,
|
|
struct pipe_resource *resource, unsigned level,
|
|
unsigned usage, const struct pipe_box *box,
|
|
struct pipe_transfer **transfer)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
return pipe->transfer_map(pipe, resource, level, usage, box, transfer);
|
|
}
|
|
|
|
static void
|
|
dd_context_transfer_flush_region(struct pipe_context *_pipe,
|
|
struct pipe_transfer *transfer,
|
|
const struct pipe_box *box)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->transfer_flush_region(pipe, transfer, box);
|
|
}
|
|
|
|
static void
|
|
dd_context_transfer_unmap(struct pipe_context *_pipe,
|
|
struct pipe_transfer *transfer)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->transfer_unmap(pipe, transfer);
|
|
}
|
|
|
|
static void
|
|
dd_context_transfer_inline_write(struct pipe_context *_pipe,
|
|
struct pipe_resource *resource,
|
|
unsigned level, unsigned usage,
|
|
const struct pipe_box *box,
|
|
const void *data, unsigned stride,
|
|
unsigned layer_stride)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->transfer_inline_write(pipe, resource, level, usage, box, data,
|
|
stride, layer_stride);
|
|
}
|
|
|
|
|
|
/********************************************************************
|
|
* miscellaneous
|
|
*/
|
|
|
|
static void
|
|
dd_context_texture_barrier(struct pipe_context *_pipe)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->texture_barrier(pipe);
|
|
}
|
|
|
|
static void
|
|
dd_context_memory_barrier(struct pipe_context *_pipe, unsigned flags)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->memory_barrier(pipe, flags);
|
|
}
|
|
|
|
static void
|
|
dd_context_get_sample_position(struct pipe_context *_pipe,
|
|
unsigned sample_count, unsigned sample_index,
|
|
float *out_value)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
return pipe->get_sample_position(pipe, sample_count, sample_index,
|
|
out_value);
|
|
}
|
|
|
|
static void
|
|
dd_context_invalidate_resource(struct pipe_context *_pipe,
|
|
struct pipe_resource *resource)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
pipe->invalidate_resource(pipe, resource);
|
|
}
|
|
|
|
static enum pipe_reset_status
|
|
dd_context_get_device_reset_status(struct pipe_context *_pipe)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
return pipe->get_device_reset_status(pipe);
|
|
}
|
|
|
|
static void
|
|
dd_context_dump_debug_state(struct pipe_context *_pipe, FILE *stream,
|
|
unsigned flags)
|
|
{
|
|
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
|
|
|
return pipe->dump_debug_state(pipe, stream, flags);
|
|
}
|
|
|
|
struct pipe_context *
|
|
dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
|
|
{
|
|
struct dd_context *dctx;
|
|
|
|
if (!pipe)
|
|
return NULL;
|
|
|
|
dctx = CALLOC_STRUCT(dd_context);
|
|
if (!dctx) {
|
|
pipe->destroy(pipe);
|
|
return NULL;
|
|
}
|
|
|
|
dctx->pipe = pipe;
|
|
dctx->base.priv = pipe->priv; /* expose wrapped priv data */
|
|
dctx->base.screen = &dscreen->base;
|
|
|
|
dctx->base.destroy = dd_context_destroy;
|
|
|
|
CTX_INIT(render_condition);
|
|
CTX_INIT(create_query);
|
|
CTX_INIT(destroy_query);
|
|
CTX_INIT(begin_query);
|
|
CTX_INIT(end_query);
|
|
CTX_INIT(get_query_result);
|
|
CTX_INIT(create_blend_state);
|
|
CTX_INIT(bind_blend_state);
|
|
CTX_INIT(delete_blend_state);
|
|
CTX_INIT(create_sampler_state);
|
|
CTX_INIT(bind_sampler_states);
|
|
CTX_INIT(delete_sampler_state);
|
|
CTX_INIT(create_rasterizer_state);
|
|
CTX_INIT(bind_rasterizer_state);
|
|
CTX_INIT(delete_rasterizer_state);
|
|
CTX_INIT(create_depth_stencil_alpha_state);
|
|
CTX_INIT(bind_depth_stencil_alpha_state);
|
|
CTX_INIT(delete_depth_stencil_alpha_state);
|
|
CTX_INIT(create_fs_state);
|
|
CTX_INIT(bind_fs_state);
|
|
CTX_INIT(delete_fs_state);
|
|
CTX_INIT(create_vs_state);
|
|
CTX_INIT(bind_vs_state);
|
|
CTX_INIT(delete_vs_state);
|
|
CTX_INIT(create_gs_state);
|
|
CTX_INIT(bind_gs_state);
|
|
CTX_INIT(delete_gs_state);
|
|
CTX_INIT(create_tcs_state);
|
|
CTX_INIT(bind_tcs_state);
|
|
CTX_INIT(delete_tcs_state);
|
|
CTX_INIT(create_tes_state);
|
|
CTX_INIT(bind_tes_state);
|
|
CTX_INIT(delete_tes_state);
|
|
CTX_INIT(create_vertex_elements_state);
|
|
CTX_INIT(bind_vertex_elements_state);
|
|
CTX_INIT(delete_vertex_elements_state);
|
|
CTX_INIT(set_blend_color);
|
|
CTX_INIT(set_stencil_ref);
|
|
CTX_INIT(set_sample_mask);
|
|
CTX_INIT(set_min_samples);
|
|
CTX_INIT(set_clip_state);
|
|
CTX_INIT(set_constant_buffer);
|
|
CTX_INIT(set_framebuffer_state);
|
|
CTX_INIT(set_polygon_stipple);
|
|
CTX_INIT(set_scissor_states);
|
|
CTX_INIT(set_viewport_states);
|
|
CTX_INIT(set_sampler_views);
|
|
CTX_INIT(set_tess_state);
|
|
CTX_INIT(set_shader_buffers);
|
|
CTX_INIT(set_shader_images);
|
|
CTX_INIT(set_vertex_buffers);
|
|
CTX_INIT(set_index_buffer);
|
|
CTX_INIT(create_stream_output_target);
|
|
CTX_INIT(stream_output_target_destroy);
|
|
CTX_INIT(set_stream_output_targets);
|
|
CTX_INIT(create_sampler_view);
|
|
CTX_INIT(sampler_view_destroy);
|
|
CTX_INIT(create_surface);
|
|
CTX_INIT(surface_destroy);
|
|
CTX_INIT(transfer_map);
|
|
CTX_INIT(transfer_flush_region);
|
|
CTX_INIT(transfer_unmap);
|
|
CTX_INIT(transfer_inline_write);
|
|
CTX_INIT(texture_barrier);
|
|
CTX_INIT(memory_barrier);
|
|
/* create_video_codec */
|
|
/* create_video_buffer */
|
|
/* create_compute_state */
|
|
/* bind_compute_state */
|
|
/* delete_compute_state */
|
|
/* set_compute_resources */
|
|
/* set_global_binding */
|
|
CTX_INIT(get_sample_position);
|
|
CTX_INIT(invalidate_resource);
|
|
CTX_INIT(get_device_reset_status);
|
|
CTX_INIT(dump_debug_state);
|
|
|
|
dd_init_draw_functions(dctx);
|
|
|
|
dctx->sample_mask = ~0;
|
|
return &dctx->base;
|
|
}
|