static void r600_destroy_context(struct pipe_context *context)
{
- struct r600_context *rctx = (struct r600_context*)context;
+ struct r600_context *rctx = r600_context(context);
FREE(rctx);
}
static void r600_flush(struct pipe_context *ctx, unsigned flags,
struct pipe_fence_handle **fence)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
+ struct r600_context *rctx = r600_context(ctx);
+ struct r600_screen *rscreen = rctx->screen;
static int dc = 0;
if (radeon_ctx_pm4(rctx->ctx))
rctx->context.draw_elements = r600_draw_elements;
rctx->context.draw_range_elements = r600_draw_range_elements;
rctx->context.flush = r600_flush;
+
+ /* Easy accessing of screen/winsys. */
+ rctx->screen = rscreen;
+ rctx->rw = rscreen->rw;
+
r600_init_query_functions(rctx);
r600_init_state_functions(rctx);
r600_init_context_resource_functions(rctx);
static int r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *rpshader)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
struct r600_shader *rshader = &rpshader->shader;
struct radeon_state *state;
unsigned i, tmp;
static int r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *rpshader)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
struct r600_shader *rshader = &rpshader->shader;
struct radeon_state *state;
unsigned i, tmp;
static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *rpshader)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
+ struct r600_context *rctx = r600_context(ctx);
struct r600_shader *rshader = &rpshader->shader;
int r;
void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *rpshader)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
if (rpshader == NULL)
return;
int r600_pipe_shader_update(struct pipe_context *ctx, struct r600_pipe_shader *rpshader)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
struct r600_shader *rshader;
enum pipe_format resource_format[160];
unsigned i, nresources = 0;
static void *r600_create_blend_state(struct pipe_context *ctx,
const struct pipe_blend_state *state)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
struct radeon_state *rstate;
rstate = radeon_state(rscreen->rw, R600_BLEND_TYPE, R600_BLEND);
static void r600_bind_blend_state(struct pipe_context *ctx, void *state)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
radeon_draw_set(rctx->draw, state);
}
static void r600_set_framebuffer_state(struct pipe_context *ctx,
const struct pipe_framebuffer_state *state)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
+ struct r600_context *rctx = r600_context(ctx);
struct r600_texture *rtex;
struct r600_buffer *rbuffer;
struct radeon_state *rstate;
static void r600_bind_fs_state(struct pipe_context *ctx, void *state)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
rctx->ps_shader = state;
}
static void r600_bind_vs_state(struct pipe_context *ctx, void *state)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
rctx->vs_shader = state;
}
static void *r600_create_rs_state(struct pipe_context *ctx,
const struct pipe_rasterizer_state *state)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
+ struct r600_context *rctx = r600_context(ctx);
struct radeon_state *rstate;
rctx->flat_shade = state->flatshade;
static void r600_bind_rs_state(struct pipe_context *ctx, void *state)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
radeon_draw_set(rctx->draw, state);
}
static void r600_set_scissor_state(struct pipe_context *ctx,
const struct pipe_scissor_state *state)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
+ struct r600_context *rctx = r600_context(ctx);
struct radeon_state *rstate;
u32 tl, br;
static void r600_set_viewport_state(struct pipe_context *ctx,
const struct pipe_viewport_state *state)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
+ struct r600_context *rctx = r600_context(ctx);
struct radeon_state *rstate;
rstate = radeon_state(rscreen->rw, R600_VIEWPORT_TYPE, R600_VIEWPORT);
unsigned count,
const struct pipe_vertex_buffer *buffers)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
memcpy(rctx->vertex_buffer, buffers, sizeof(struct pipe_vertex_buffer) * count);
rctx->nvertex_buffer = count;
static void r600_bind_vertex_elements_state(struct pipe_context *ctx, void *state)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
struct r600_vertex_elements_state *v = (struct r600_vertex_elements_state*)state;
rctx->vertex_elements = v;
static void *r600_create_dsa_state(struct pipe_context *ctx,
const struct pipe_depth_stencil_alpha_state *state)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
struct radeon_state *rstate;
unsigned db_depth_control;
static void r600_bind_dsa_state(struct pipe_context *ctx, void *state)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
radeon_draw_set(rctx->draw, state);
}
uint shader, uint index,
struct pipe_resource *buffer)
{
- struct r600_screen *rscreen = (struct r600_screen*)ctx->screen;
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_screen *rscreen = r600_screen(ctx->screen);
+ struct r600_context *rctx = r600_context(ctx);
unsigned nconstant = 0, i, type, id;
struct radeon_state *rstate;
struct pipe_transfer *transfer;
static void r600_set_stencil_ref(struct pipe_context *ctx,
const struct pipe_stencil_ref *sr)
{
- struct r600_context *rctx = (struct r600_context*)ctx;
+ struct r600_context *rctx = r600_context(ctx);
rctx->stencil_ref = *sr;
}