Commit ffd0a2e2 authored by Marek Olšák's avatar Marek Olšák

r600g: use cast wrappers

parent 42aad574
......@@ -33,7 +33,7 @@
static void r600_blitter_save_states(struct pipe_context *ctx)
{
struct r600_context *rctx = (struct r600_context*)ctx;
struct r600_context *rctx = r600_context(ctx);
util_blitter_save_blend(rctx->blitter,
rctx->draw->state[R600_BLEND]);
......@@ -55,7 +55,7 @@ static void r600_blitter_save_states(struct pipe_context *ctx)
void r600_clear(struct pipe_context *ctx, unsigned buffers,
const float *rgba, double depth, unsigned stencil)
{
struct r600_context *rctx = (struct r600_context*)ctx;
struct r600_context *rctx = r600_context(ctx);
struct pipe_framebuffer_state *fb = &rctx->fb_state;
r600_blitter_save_states(ctx);
......
......@@ -35,7 +35,7 @@
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);
}
......@@ -43,8 +43,8 @@ static void r600_destroy_context(struct pipe_context *context)
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))
......@@ -78,6 +78,11 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
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);
......
......@@ -48,6 +48,8 @@ struct r600_pipe_shader {
struct r600_context {
struct pipe_context context;
struct r600_screen *screen;
struct radeon *rw;
struct radeon_ctx *ctx;
struct radeon_state *cb_cntl;
struct radeon_state *db;
......@@ -65,6 +67,12 @@ struct r600_context {
struct pipe_viewport_state viewport;
};
/* Convenience cast wrapper. */
static INLINE struct r600_context *r600_context(struct pipe_context *pipe)
{
return (struct r600_context*)pipe;
}
void r600_draw_arrays(struct pipe_context *ctx, unsigned mode,
unsigned start, unsigned count);
void r600_draw_elements(struct pipe_context *ctx,
......
......@@ -48,8 +48,8 @@ struct r600_draw {
static int r600_draw_common(struct r600_draw *draw)
{
struct r600_context *rctx = (struct r600_context*)draw->ctx;
struct r600_screen *rscreen = (struct r600_screen*)draw->ctx->screen;
struct r600_context *rctx = r600_context(draw->ctx);
struct r600_screen *rscreen = rctx->screen;
struct radeon_state *vs_resource;
struct r600_buffer *rbuffer;
unsigned i, j, offset, format, prim;
......
......@@ -31,8 +31,6 @@
#include "radeon.h"
#include "util/u_transfer.h"
#define r600_screen(s) ((struct r600_screen*)s)
/* Texture transfer. */
struct r600_transfer {
/* Base class. */
......@@ -55,6 +53,11 @@ struct r600_screen {
struct radeon *rw;
};
static INLINE struct r600_screen *r600_screen(struct pipe_screen *screen)
{
return (struct r600_screen*)screen;
}
/* Buffer functions. */
struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ);
......
......@@ -35,7 +35,7 @@
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;
......@@ -63,7 +63,7 @@ static int r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader
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;
......@@ -92,8 +92,8 @@ static int r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
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;
......@@ -176,7 +176,7 @@ struct r600_pipe_shader *r600_pipe_shader_create(struct pipe_context *ctx, unsig
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;
......@@ -188,7 +188,7 @@ void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader
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;
......
......@@ -43,7 +43,7 @@ static void r600_delete_state(struct pipe_context *ctx, void *state)
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);
......@@ -71,7 +71,7 @@ static void *r600_create_blend_state(struct pipe_context *ctx,
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);
}
......@@ -88,8 +88,8 @@ static void r600_set_clip_state(struct pipe_context *ctx,
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;
......@@ -156,7 +156,7 @@ static void *r600_create_fs_state(struct pipe_context *ctx,
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;
}
......@@ -169,7 +169,7 @@ static void *r600_create_vs_state(struct pipe_context *ctx,
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;
}
......@@ -182,8 +182,8 @@ static void r600_set_polygon_stipple(struct pipe_context *ctx,
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;
......@@ -220,7 +220,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
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);
}
......@@ -266,8 +266,8 @@ static void r600_set_vertex_sampler_views(struct pipe_context *ctx,
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;
......@@ -305,8 +305,8 @@ static void r600_set_scissor_state(struct pipe_context *ctx,
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);
......@@ -333,7 +333,7 @@ static void r600_set_vertex_buffers(struct pipe_context *ctx,
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;
......@@ -354,7 +354,7 @@ static void *r600_create_vertex_elements_state(struct pipe_context *ctx,
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;
......@@ -368,7 +368,7 @@ static void r600_delete_vertex_elements_state(struct pipe_context *ctx, void *st
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;
......@@ -402,7 +402,7 @@ static void *r600_create_dsa_state(struct pipe_context *ctx,
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);
}
......@@ -410,8 +410,8 @@ static void r600_set_constant_buffer(struct pipe_context *ctx,
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;
......@@ -455,7 +455,7 @@ static void r600_set_constant_buffer(struct pipe_context *ctx,
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment