summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r600/r600_blit.c4
-rw-r--r--src/gallium/drivers/r600/r600_context.c11
-rw-r--r--src/gallium/drivers/r600/r600_context.h8
-rw-r--r--src/gallium/drivers/r600/r600_draw.c4
-rw-r--r--src/gallium/drivers/r600/r600_screen.h7
-rw-r--r--src/gallium/drivers/r600/r600_shader.c12
-rw-r--r--src/gallium/drivers/r600/r600_state.c40
7 files changed, 51 insertions, 35 deletions
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index ffb2d37263..52a2921d47 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -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);
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index d819c14148..22fffc4f47 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -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);
diff --git a/src/gallium/drivers/r600/r600_context.h b/src/gallium/drivers/r600/r600_context.h
index 8e996b7d20..464209f4f4 100644
--- a/src/gallium/drivers/r600/r600_context.h
+++ b/src/gallium/drivers/r600/r600_context.h
@@ -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,
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index 8b6a6d96aa..724fb6c988 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -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;
diff --git a/src/gallium/drivers/r600/r600_screen.h b/src/gallium/drivers/r600/r600_screen.h
index d424af304f..49f6f50ee6 100644
--- a/src/gallium/drivers/r600/r600_screen.h
+++ b/src/gallium/drivers/r600/r600_screen.h
@@ -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);
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 6729fdd0e5..9708d95188 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -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;
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 929814e706..4150f88785 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -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;
}