From 49cb978aa46af0d86ab609013d7883c8105a6d1d Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Fri, 17 Sep 2010 18:41:05 -0600
Subject: gallium: better docs for pipe_rasterizer_state::sprite_coord_enable
---
src/gallium/docs/source/cso/rasterizer.rst | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst
index ee3419ccfc..d547055096 100644
--- a/src/gallium/docs/source/cso/rasterizer.rst
+++ b/src/gallium/docs/source/cso/rasterizer.rst
@@ -124,17 +124,24 @@ Points
sprite_coord_enable
^^^^^^^^^^^^^^^^^^^
-Specifies if a texture unit has its texture coordinates replaced or not. This
-is a packed bitfield containing the enable for all texcoords -- if all bits
-are zero, point sprites are effectively disabled.
+Controls automatic texture coordinate generation for rendering sprite points.
+
+When bit k in the sprite_coord_enable bitfield is set, then generic
+input k to the fragment shader will get an automatically computed
+texture coordinate.
+
+The texture coordinate will be of the form (s, t, 0, 1) where s varies
+from 0 to 1 from left to right while t varies from 0 to 1 according to
+the state of 'sprite_coord_mode' (see below).
If any bit is set, then point_smooth MUST be disabled (there are no
round sprites) and point_quad_rasterization MUST be true (sprites are
always rasterized as quads). Any mismatch between these states should
be considered a bug in the state-tracker.
-If enabled, the four vertices of the resulting quad will be assigned
-texture coordinates, according to sprite_coord_mode.
+This feature is implemented in the :ref:`Draw` module but may also be
+implemented natively by GPUs or implemented with a geometry shader.
+
sprite_coord_mode
^^^^^^^^^^^^^^^^^
@@ -145,6 +152,7 @@ have coordinates (0,0,0,1). For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left
vertex will have coordinates (0,0,0,1).
This state is used by :ref:`Draw` to generate texcoords.
+
point_quad_rasterization
^^^^^^^^^^^^^^^^^^^^^^^^
--
cgit v1.2.3
From e22e3927b056806e9bbb089734132ad0bcb98df1 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Fri, 17 Sep 2010 18:41:30 -0600
Subject: gallium: rework handling of sprite_coord_enable state
Implement the pipe_rasterizer_state::sprite_coord_enable field
in the draw module (and softpipe) according to what's specified
in the documentation.
The draw module can now add any number of extra vertex attributes
to a post-transformed vertex and generate texcoords for those
attributes per sprite_coord_enable. Auto-generated texcoords
for sprites only worked for one texcoord unit before.
The frag shader gl_PointCoord input is now implemented like any
other generic/texcoord attribute.
The draw module now needs to be informed about fragment shaders
since we need to look at the fragment shader's inputs to know
which ones need auto-generated texcoords.
Only softpipe has been updated so far.
---
src/gallium/auxiliary/Makefile | 1 +
src/gallium/auxiliary/SConscript | 1 +
src/gallium/auxiliary/draw/draw_context.c | 56 +++++++++--
src/gallium/auxiliary/draw/draw_context.h | 12 +++
src/gallium/auxiliary/draw/draw_pipe_aaline.c | 9 +-
src/gallium/auxiliary/draw/draw_pipe_aapoint.c | 8 +-
src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 114 ++++++++++------------
src/gallium/auxiliary/draw/draw_private.h | 17 +++-
src/gallium/drivers/softpipe/sp_state.h | 2 +
src/gallium/drivers/softpipe/sp_state_fs.c | 15 ++-
src/mesa/state_tracker/st_atom_rasterizer.c | 14 +++
src/mesa/state_tracker/st_program.c | 17 +---
12 files changed, 172 insertions(+), 94 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 2de764c4ee..f05538bbac 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -8,6 +8,7 @@ C_SOURCES = \
cso_cache/cso_context.c \
cso_cache/cso_hash.c \
draw/draw_context.c \
+ draw/draw_fs.c \
draw/draw_gs.c \
draw/draw_pipe.c \
draw/draw_pipe_aaline.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 294df30094..baaa26fea9 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -54,6 +54,7 @@ source = [
'cso_cache/cso_context.c',
'cso_cache/cso_hash.c',
'draw/draw_context.c',
+ 'draw/draw_fs.c',
'draw/draw_gs.c',
'draw/draw_pipe.c',
'draw/draw_pipe_aaline.c',
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 937b093479..b07de76a49 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -413,6 +413,42 @@ draw_set_force_passthrough( struct draw_context *draw, boolean enable )
}
+
+/**
+ * Allocate an extra vertex/geometry shader vertex attribute.
+ * This is used by some of the optional draw module stages such
+ * as wide_point which may need to allocate additional generic/texcoord
+ * attributes.
+ */
+int
+draw_alloc_extra_vertex_attrib(struct draw_context *draw,
+ uint semantic_name, uint semantic_index)
+{
+ const int num_outputs = draw_current_shader_outputs(draw);
+ const int n = draw->extra_shader_outputs.num;
+
+ assert(n < Elements(draw->extra_shader_outputs.semantic_name));
+
+ draw->extra_shader_outputs.semantic_name[n] = semantic_name;
+ draw->extra_shader_outputs.semantic_index[n] = semantic_index;
+ draw->extra_shader_outputs.slot[n] = num_outputs + n;
+ draw->extra_shader_outputs.num++;
+
+ return draw->extra_shader_outputs.slot[n];
+}
+
+
+/**
+ * Remove all extra vertex attributes that were allocated with
+ * draw_alloc_extra_vertex_attrib().
+ */
+void
+draw_remove_extra_vertex_attribs(struct draw_context *draw)
+{
+ draw->extra_shader_outputs.num = 0;
+}
+
+
/**
* Ask the draw module for the location/slot of the given vertex attribute in
* a post-transformed vertex.
@@ -446,12 +482,12 @@ draw_find_shader_output(const struct draw_context *draw,
return i;
}
- /* XXX there may be more than one extra vertex attrib.
- * For example, simulated gl_FragCoord and gl_PointCoord.
- */
- if (draw->extra_shader_outputs.semantic_name == semantic_name &&
- draw->extra_shader_outputs.semantic_index == semantic_index) {
- return draw->extra_shader_outputs.slot;
+ /* Search the extra vertex attributes */
+ for (i = 0; i < draw->extra_shader_outputs.num; i++) {
+ if (draw->extra_shader_outputs.semantic_name[i] == semantic_name &&
+ draw->extra_shader_outputs.semantic_index[i] == semantic_index) {
+ return draw->extra_shader_outputs.slot[i];
+ }
}
return 0;
@@ -470,16 +506,18 @@ draw_find_shader_output(const struct draw_context *draw,
uint
draw_num_shader_outputs(const struct draw_context *draw)
{
- uint count = draw->vs.vertex_shader->info.num_outputs;
+ uint count;
/* If a geometry shader is present, its outputs go to the
* driver, else the vertex shader's outputs.
*/
if (draw->gs.geometry_shader)
count = draw->gs.geometry_shader->info.num_outputs;
+ else
+ count = draw->vs.vertex_shader->info.num_outputs;
+
+ count += draw->extra_shader_outputs.num;
- if (draw->extra_shader_outputs.slot > 0)
- count++;
return count;
}
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index 4f0d30123a..1f27cbf488 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -46,6 +46,7 @@ struct draw_context;
struct draw_stage;
struct draw_vertex_shader;
struct draw_geometry_shader;
+struct draw_fragment_shader;
struct tgsi_sampler;
#define DRAW_MAX_TEXTURE_LEVELS 13 /* 4K x 4K for now */
@@ -137,6 +138,17 @@ void draw_delete_vertex_shader(struct draw_context *draw,
struct draw_vertex_shader *dvs);
+/*
+ * Fragment shader functions
+ */
+struct draw_fragment_shader *
+draw_create_fragment_shader(struct draw_context *draw,
+ const struct pipe_shader_state *shader);
+void draw_bind_fragment_shader(struct draw_context *draw,
+ struct draw_fragment_shader *dvs);
+void draw_delete_fragment_shader(struct draw_context *draw,
+ struct draw_fragment_shader *dvs);
+
/*
* Geometry shader functions
*/
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index eac21110be..d1aba76309 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -688,10 +688,9 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
aaline->tex_slot = draw_current_shader_outputs(draw);
aaline->pos_slot = draw_current_shader_position_output(draw);;
- /* advertise the extra post-transformed vertex attribute */
- draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_shader_outputs.semantic_index = aaline->fs->generic_attrib;
- draw->extra_shader_outputs.slot = aaline->tex_slot;
+ /* allocate the extra post-transformed vertex attribute */
+ (void) draw_alloc_extra_vertex_attrib(draw, TGSI_SEMANTIC_GENERIC,
+ aaline->fs->generic_attrib);
/* how many samplers? */
/* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
@@ -744,7 +743,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
draw->suspend_flushing = FALSE;
- draw->extra_shader_outputs.slot = 0;
+ draw_remove_extra_vertex_attribs(draw);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index d406a86ccb..5ea552f51c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -701,9 +701,9 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
aapoint->pos_slot = draw_current_shader_position_output(draw);
- draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_shader_outputs.semantic_index = aapoint->fs->generic_attrib;
- draw->extra_shader_outputs.slot = aapoint->tex_slot;
+ /* allocate the extra post-transformed vertex attribute */
+ (void) draw_alloc_extra_vertex_attrib(draw, TGSI_SEMANTIC_GENERIC,
+ aapoint->fs->generic_attrib);
/* find psize slot in post-transform vertex */
aapoint->psize_slot = -1;
@@ -754,7 +754,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
draw->suspend_flushing = FALSE;
- draw->extra_shader_outputs.slot = 0;
+ draw_remove_extra_vertex_attribs(draw);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index ee2945c7c9..40843c58c2 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -57,26 +57,24 @@
#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "draw_fs.h"
#include "draw_vs.h"
#include "draw_pipe.h"
struct widepoint_stage {
- struct draw_stage stage;
+ struct draw_stage stage; /**< base class */
float half_point_size;
float xbias;
float ybias;
- uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS];
- uint texcoord_enable[PIPE_MAX_SHADER_OUTPUTS];
- uint num_texcoords;
- uint texcoord_mode;
+ /** for automatic texcoord generation/replacement */
+ uint num_texcoord_gen;
+ uint texcoord_gen_slot[PIPE_MAX_SHADER_OUTPUTS];
int psize_slot;
-
- int point_coord_fs_input; /**< input for pointcoord */
};
@@ -96,30 +94,20 @@ widepoint_stage( struct draw_stage *stage )
static void set_texcoords(const struct widepoint_stage *wide,
struct vertex_header *v, const float tc[4])
{
+ const struct draw_context *draw = wide->stage.draw;
+ const struct pipe_rasterizer_state *rast = draw->rasterizer;
+ const uint texcoord_mode = rast->sprite_coord_mode;
uint i;
- for (i = 0; i < wide->num_texcoords; i++) {
- if (wide->texcoord_enable[i]) {
- uint j = wide->texcoord_slot[i];
- v->data[j][0] = tc[0];
- if (wide->texcoord_mode == PIPE_SPRITE_COORD_LOWER_LEFT)
- v->data[j][1] = 1.0f - tc[1];
- else
- v->data[j][1] = tc[1];
- v->data[j][2] = tc[2];
- v->data[j][3] = tc[3];
- }
- }
- if (wide->point_coord_fs_input >= 0) {
- /* put gl_PointCoord into the extra vertex slot */
- uint slot = wide->stage.draw->extra_shader_outputs.slot;
+ for (i = 0; i < wide->num_texcoord_gen; i++) {
+ const uint slot = wide->texcoord_gen_slot[i];
v->data[slot][0] = tc[0];
- if (wide->texcoord_mode == PIPE_SPRITE_COORD_LOWER_LEFT)
+ if (texcoord_mode == PIPE_SPRITE_COORD_LOWER_LEFT)
v->data[slot][1] = 1.0f - tc[1];
else
v->data[slot][1] = tc[1];
- v->data[slot][2] = 0.0F;
- v->data[slot][3] = 1.0F;
+ v->data[slot][2] = tc[2];
+ v->data[slot][3] = tc[3];
}
}
@@ -201,18 +189,9 @@ static void widepoint_point( struct draw_stage *stage,
}
-static int
-find_pntc_input_attrib(struct draw_context *draw)
-{
- /* Scan the fragment program's input decls to find the pointcoord
- * attribute. The xy components will store the point coord.
- */
- return 0; /* XXX fix this */
-}
-
-
-static void widepoint_first_point( struct draw_stage *stage,
- struct prim_header *header )
+static void
+widepoint_first_point(struct draw_stage *stage,
+ struct prim_header *header)
{
struct widepoint_stage *wide = widepoint_stage(stage);
struct draw_context *draw = stage->draw;
@@ -244,31 +223,45 @@ static void widepoint_first_point( struct draw_stage *stage,
stage->point = draw_pipe_passthrough_point;
}
+ draw_remove_extra_vertex_attribs(draw);
+
if (rast->point_quad_rasterization) {
- /* find vertex shader texcoord outputs */
- const struct draw_vertex_shader *vs = draw->vs.vertex_shader;
- uint i, j = 0;
- wide->texcoord_mode = rast->sprite_coord_mode;
- for (i = 0; i < vs->info.num_outputs; i++) {
- if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
- wide->texcoord_slot[j] = i;
- wide->texcoord_enable[j] = (rast->sprite_coord_enable >> j) & 1;
- j++;
+ const struct draw_fragment_shader *fs = draw->fs.fragment_shader;
+ uint i;
+
+ wide->num_texcoord_gen = 0;
+
+ /* Loop over fragment shader inputs looking for generic inputs
+ * for which bit 'k' in sprite_coord_enable is set.
+ */
+ for (i = 0; i < fs->info.num_inputs; i++) {
+ if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
+ const int generic_index = fs->info.input_semantic_index[i];
+ if (rast->sprite_coord_enable & (1 << generic_index)) {
+ /* OK, this generic attribute needs to be replaced with a
+ * texcoord (see above).
+ */
+ int slot = draw_find_shader_output(draw,
+ TGSI_SEMANTIC_GENERIC,
+ generic_index);
+
+ if (slot > 0) {
+ /* there's already a post-vertex shader attribute
+ * for this fragment shader input attribute.
+ */
+ }
+ else {
+ /* need to allocate a new post-vertex shader attribute */
+ slot = draw_alloc_extra_vertex_attrib(draw,
+ TGSI_SEMANTIC_GENERIC,
+ generic_index);
+ }
+
+ /* add this slot to the texcoord-gen list */
+ wide->texcoord_gen_slot[wide->num_texcoord_gen++] = slot;
+ }
}
}
- wide->num_texcoords = j;
-
- /* find fragment shader PointCoord input */
- wide->point_coord_fs_input = find_pntc_input_attrib(draw);
-
- /* setup extra vp output (point coord implemented as a texcoord) */
- draw->extra_shader_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_shader_outputs.semantic_index = 0;
- draw->extra_shader_outputs.slot = draw_current_shader_outputs(draw);
- }
- else {
- wide->point_coord_fs_input = -1;
- draw->extra_shader_outputs.slot = 0;
}
wide->psize_slot = -1;
@@ -295,7 +288,8 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags )
stage->point = widepoint_first_point;
stage->next->flush( stage->next, flags );
- stage->draw->extra_shader_outputs.slot = 0;
+
+ draw_remove_extra_vertex_attribs(draw);
/* restore original rasterizer state */
if (draw->rast_handle) {
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 362f563ba6..d417f825a0 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -250,6 +250,11 @@ struct draw_context
struct tgsi_sampler **samplers;
} gs;
+ /** Fragment shader state */
+ struct {
+ struct draw_fragment_shader *fragment_shader;
+ } fs;
+
/** Stream output (vertex feedback) state */
struct {
struct pipe_stream_output_state state;
@@ -266,9 +271,10 @@ struct draw_context
/* If a prim stage introduces new vertex attributes, they'll be stored here
*/
struct {
- uint semantic_name;
- uint semantic_index;
- int slot;
+ uint num;
+ uint semantic_name[10];
+ uint semantic_index[10];
+ uint slot[10];
} extra_shader_outputs;
unsigned reduced_prim;
@@ -362,6 +368,11 @@ void draw_gs_destroy( struct draw_context *draw );
uint draw_current_shader_outputs(const struct draw_context *draw);
uint draw_current_shader_position_output(const struct draw_context *draw);
+int draw_alloc_extra_vertex_attrib(struct draw_context *draw,
+ uint semantic_name, uint semantic_index);
+void draw_remove_extra_vertex_attribs(struct draw_context *draw);
+
+
/*******************************************************************************
* Vertex processing (was passthrough) code:
*/
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index 39d204de8a..c5d61f840f 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -70,6 +70,8 @@ struct sp_fragment_shader {
struct tgsi_shader_info info;
+ struct draw_fragment_shader *draw_shader;
+
boolean origin_lower_left; /**< fragment shader uses lower left position origin? */
boolean pixel_center_integer; /**< fragment shader uses integer pixel center? */
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index ded242d3dc..50bc2eea5f 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -60,7 +60,15 @@ softpipe_create_fs_state(struct pipe_context *pipe,
state = softpipe_create_fs_exec( softpipe, templ );
}
- assert(state);
+ if (!state)
+ return NULL;
+
+ /* draw's fs state */
+ state->draw_shader = draw_create_fragment_shader(softpipe->draw, templ);
+ if (!state->draw_shader) {
+ state->delete( state );
+ return NULL;
+ }
/* get/save the summary info for this shader */
tgsi_scan_shader(templ->tokens, &state->info);
@@ -90,6 +98,9 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
softpipe->fs = fs;
+ draw_bind_fragment_shader(softpipe->draw,
+ (softpipe->fs ? softpipe->fs->draw_shader : NULL));
+
softpipe->dirty |= SP_NEW_FS;
}
@@ -109,6 +120,8 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
tgsi_exec_machine_bind_shader(softpipe->fs_machine, NULL, 0, NULL);
}
+ draw_delete_fragment_shader(softpipe->draw, state->draw_shader);
+
state->delete( state );
}
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 2599bd5ca0..0fe333ae8a 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -60,6 +60,7 @@ static void update_raster_state( struct st_context *st )
GLcontext *ctx = st->ctx;
struct pipe_rasterizer_state *raster = &st->state.rasterizer;
const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current;
+ const struct gl_fragment_program *fragProg = ctx->FragmentProgram._Current;
uint i;
memset(raster, 0, sizeof(*raster));
@@ -175,17 +176,30 @@ static void update_raster_state( struct st_context *st )
if (!ctx->Point.PointSprite && ctx->Point.SmoothFlag)
raster->point_smooth = 1;
+ /* _NEW_POINT | _NEW_PROGRAM
+ */
if (ctx->Point.PointSprite) {
+ /* origin */
if ((ctx->Point.SpriteOrigin == GL_UPPER_LEFT) ^
(st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM))
raster->sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
else
raster->sprite_coord_mode = PIPE_SPRITE_COORD_LOWER_LEFT;
+
+ /* Coord replacement flags. If bit 'k' is set that means
+ * that we need to replace GENERIC[k] attrib with an automatically
+ * computed texture coord.
+ */
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
if (ctx->Point.CoordReplace[i]) {
raster->sprite_coord_enable |= 1 << i;
}
}
+ if (fragProg->Base.InputsRead & FRAG_BIT_PNTC) {
+ raster->sprite_coord_enable |=
+ 1 << (FRAG_ATTRIB_PNTC - FRAG_ATTRIB_TEX0);
+ }
+
raster->point_quad_rasterization = 1;
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 8c2d8b6154..18a7bbe0f9 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -338,17 +338,6 @@ st_translate_fragment_program(struct st_context *st,
input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
break;
- case FRAG_ATTRIB_PNTC:
- /* This is a hack. We really need a new semantic label for
- * point coord. The draw module needs to know which fragment
- * shader input is the point coord attribute so that it can set
- * up the right vertex attribute values.
- */
- input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- input_semantic_index[slot] = 0;
- interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
- break;
-
/* In most cases, there is nothing special about these
* inputs, so adopt a convention to use the generic
* semantic name and the mesa FRAG_ATTRIB_ number as the
@@ -364,6 +353,7 @@ st_translate_fragment_program(struct st_context *st,
* zero or be restricted to a particular range -- nobody
* should be building tables based on semantic index.
*/
+ case FRAG_ATTRIB_PNTC:
case FRAG_ATTRIB_TEX0:
case FRAG_ATTRIB_TEX1:
case FRAG_ATTRIB_TEX2:
@@ -380,7 +370,10 @@ st_translate_fragment_program(struct st_context *st,
assert(attr >= FRAG_ATTRIB_TEX0);
input_semantic_index[slot] = (attr - FRAG_ATTRIB_TEX0);
input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
+ if (attr == FRAG_ATTRIB_PNTC)
+ interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
+ else
+ interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
break;
}
}
--
cgit v1.2.3
From f964f92bcc7d4fbbceb16ea972fbbdd278953d75 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Fri, 17 Sep 2010 18:48:50 -0600
Subject: gallium/docs: added new pipeline.txt diagram
This diagram shows the rendering pipeline with an emphasis on
the inputs/outputs for each stage. Some stages emit new vertex
attributes and others consume some attributes.
---
src/gallium/docs/source/pipeline.txt | 128 +++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
create mode 100644 src/gallium/docs/source/pipeline.txt
(limited to 'src/gallium')
diff --git a/src/gallium/docs/source/pipeline.txt b/src/gallium/docs/source/pipeline.txt
new file mode 100644
index 0000000000..fd1fbe9c76
--- /dev/null
+++ b/src/gallium/docs/source/pipeline.txt
@@ -0,0 +1,128 @@
+XXX this could be converted/formatted for Sphinx someday.
+XXX do not use tabs in this file.
+
+
+
+ position ]
+ primary/secondary colors ]
+ generics (normals, ]
+ texcoords, fog) ] User vertices / arrays
+ point size ]
+ edge flag ]
+ primitive ID } System-generated values
+ vertex ID }
+ | | |
+ V V V
+ +-------------------+
+ | Vertex shader |
+ +-------------------+
+ | | |
+ V V V
+ position
+ clip distance
+ generics
+ front/back & primary/secondary colors
+ point size
+ edge flag
+ primitive ID
+ | | |
+ V V V
+ +------------------------+
+ | Geometry shader |
+ | (consume vertex ID) |
+ | (may change prim type) |
+ +------------------------+
+ | | |
+ V V V
+ [...]
+ fb layer
+ | | |
+ V V V
+ +--------------------------+
+ | Clipper |
+ | (consume clip distances) |
+ +--------------------------+
+ | | |
+ V V V
+ +-------------------+
+ | Polygon Culling |
+ +-------------------+
+ | | |
+ V V V
+ +-----------------------+
+ | Choose front or |
+ | back face color |
+ | (consume other color) |
+ +-----------------------+
+ | | |
+ V V V
+ [...]
+ primary/secondary colors only
+ | | |
+ V V V
+ +-------------------+
+ | Polygon Offset |
+ +-------------------+
+ | | |
+ V V V
+ +----------------------+
+ | Unfilled polygons |
+ | (consume edge flags) |
+ | (change prim type) |
+ +----------------------+
+ | | |
+ V V V
+ position
+ generics
+ primary/secondary colors
+ point size
+ primitive ID
+ fb layer
+ | | |
+ V V V
+ +---------------------------------+
+ | Optional Draw module helpers |
+ | * Polygon Stipple |
+ | * Line Stipple |
+ | * Line AA/smooth (as tris) |
+ | * Wide lines (as tris) |
+ | * Wide points/sprites (as tris) |
+ | * Point AA/smooth (as tris) |
+ | (NOTE: these stages may emit |
+ | new/extra generic attributes |
+ | such as texcoords) |
+ +---------------------------------+
+ | | |
+ V V V
+ position ]
+ generics (+ new/extra ones) ]
+ primary/secondary colors ] Software rast vertices
+ point size ]
+ primitive ID ]
+ fb layer ]
+ | | |
+ V V V
+ +---------------------+
+ | Triangle/Line/Point |
+ | Rasterization |
+ +---------------------+
+ | | |
+ V V V
+ generic attribs
+ primary/secondary colors
+ primitive ID
+ fragment win coord pos } System-generated values
+ front/back face flag }
+ | | |
+ V V V
+ +-------------------+
+ | Fragment shader |
+ +-------------------+
+ | | |
+ V V V
+ zero or more colors
+ zero or one Z value
+
+
+NOTE: The instance ID is not shown. It can be imagined to be a global variable
+accessible to all shader stages.
--
cgit v1.2.3
From 013e4cca9f9c74e52f8372b500fb3ff07c692a61 Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Sat, 18 Sep 2010 00:47:36 -0700
Subject: nvfx: Remove const qualifer from nvfx_vertprog_translate.
Silences this GCC warning.
nvfx_vertprog.c: In function 'nvfx_vertprog_translate':
nvfx_vertprog.c:998: warning: assignment discards qualifiers from pointer target type
---
src/gallium/drivers/nvfx/nvfx_vertprog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
index 23f045ecf6..db352de939 100644
--- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
@@ -973,7 +973,7 @@ nvfx_vertprog_prepare(struct nvfx_context* nvfx, struct nvfx_vpc *vpc)
DEBUG_GET_ONCE_BOOL_OPTION(nvfx_dump_vp, "NVFX_DUMP_VP", FALSE)
static struct nvfx_vertex_program*
-nvfx_vertprog_translate(struct nvfx_context *nvfx, const struct pipe_shader_state* vps, const struct tgsi_shader_info* info)
+nvfx_vertprog_translate(struct nvfx_context *nvfx, const struct pipe_shader_state* vps, struct tgsi_shader_info* info)
{
struct tgsi_parse_context parse;
struct nvfx_vertex_program* vp = NULL;
--
cgit v1.2.3
From b1a5c63467b01265c8652862053b7f2f90dc8044 Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Sat, 18 Sep 2010 00:51:07 -0700
Subject: nvfx: Silence uninitialized variable warnings.
---
src/gallium/drivers/nvfx/nvfx_vertprog.c | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
index db352de939..e543fda50e 100644
--- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
@@ -377,6 +377,8 @@ tgsi_src(struct nvfx_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
src.swz[2] = fsrc->Register.SwizzleZ;
src.swz[3] = fsrc->Register.SwizzleW;
src.indirect = 0;
+ src.indirect_reg = 0;
+ src.indirect_swz = 0;
if(fsrc->Register.Indirect) {
if(fsrc->Indirect.File == TGSI_FILE_ADDRESS &&
--
cgit v1.2.3
From cef42f925cc8b38df741c4571676dab4bd3fd14e Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Sat, 18 Sep 2010 00:59:16 -0700
Subject: r600g: Remove unused variable.
---
src/gallium/drivers/r600/r600_draw.c | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index 5480ca002d..cbfa44868e 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -40,7 +40,6 @@
static int r600_draw_common(struct r600_draw *draw)
{
struct r600_context *rctx = r600_context(draw->ctx);
- struct r600_screen *rscreen = rctx->screen;
/* FIXME vs_resource */
struct radeon_state *vs_resource;
struct r600_resource *rbuffer;
--
cgit v1.2.3
From 275a81af13624be70566e190d4dd1f457ea1ff33 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller
Date: Sat, 18 Sep 2010 13:40:10 +0200
Subject: nv50: add relocs for stack and local mem buffers
---
src/gallium/drivers/nv50/nv50_context.h | 1 +
src/gallium/drivers/nv50/nv50_pc.c | 2 ++
src/gallium/drivers/nv50/nv50_program.h | 1 +
src/gallium/drivers/nv50/nv50_screen.c | 13 +++++++++++++
src/gallium/drivers/nv50/nv50_shader_state.c | 17 ++++++++++++++---
5 files changed, 31 insertions(+), 3 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index 6ec9095a74..ac69c7848e 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -157,6 +157,7 @@ struct nv50_context {
unsigned sampler_view_nr[3];
unsigned vbo_fifo;
+ unsigned req_lmem;
};
static INLINE struct nv50_context *
diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index 676540538e..42127a138a 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -547,6 +547,8 @@ nv50_generate_code(struct nv50_translation_info *ti)
ti->p->fixups = pc->fixups;
ti->p->num_fixups = pc->num_fixups;
+ ti->p->uses_lmem = ti->store_to_memory;
+
NV50_DBGMSG("SHADER TRANSLATION - %s\n", ret ? "failure" : "success");
out:
diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h
index 37b02bbec7..33c4c8ca6d 100644
--- a/src/gallium/drivers/nv50/nv50_program.h
+++ b/src/gallium/drivers/nv50/nv50_program.h
@@ -45,6 +45,7 @@ struct nv50_program {
ubyte type;
boolean translated;
+ boolean uses_lmem;
struct nouveau_bo *bo;
struct nouveau_stateobj *so;
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 49af9b59be..a8f7721337 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -265,6 +265,19 @@ nv50_screen_relocs(struct nv50_screen *screen)
OUT_RELOC (chan, screen->constbuf_parm[i],
((NV50_CB_PVP + i) << 16) | 0x0000, rl, 0, 0);
}
+
+ BGN_RELOC (chan, screen->stack_bo,
+ tesla, NV50TCL_STACK_ADDRESS_HIGH, 2, rl);
+ OUT_RELOCh(chan, screen->stack_bo, 0, rl);
+ OUT_RELOCl(chan, screen->stack_bo, 0, rl);
+
+ if (!screen->cur_ctx->req_lmem)
+ return;
+
+ BGN_RELOC (chan, screen->local_bo,
+ tesla, NV50TCL_LOCAL_ADDRESS_HIGH, 2, rl);
+ OUT_RELOCh(chan, screen->local_bo, 0, rl);
+ OUT_RELOCl(chan, screen->local_bo, 0, rl);
}
#ifndef NOUVEAU_GETPARAM_GRAPH_UNITS
diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c
index 8c1a5999cf..8057ec9fcf 100644
--- a/src/gallium/drivers/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nv50/nv50_shader_state.c
@@ -281,6 +281,17 @@ nv50_program_validate(struct nv50_program *p)
return p->translated;
}
+static INLINE void
+nv50_program_validate_common(struct nv50_context *nv50, struct nv50_program *p)
+{
+ nv50_program_validate_code(nv50, p);
+
+ if (p->uses_lmem)
+ nv50->req_lmem |= 1 << p->type;
+ else
+ nv50->req_lmem &= ~(1 << p->type);
+}
+
struct nouveau_stateobj *
nv50_vertprog_validate(struct nv50_context *nv50)
{
@@ -300,7 +311,7 @@ nv50_vertprog_validate(struct nv50_context *nv50)
if (!(nv50->dirty & NV50_NEW_VERTPROG))
return NULL;
- nv50_program_validate_code(nv50, p);
+ nv50_program_validate_common(nv50, p);
so_ref(p->so, &so);
return so;
@@ -325,7 +336,7 @@ nv50_fragprog_validate(struct nv50_context *nv50)
if (!(nv50->dirty & NV50_NEW_FRAGPROG))
return NULL;
- nv50_program_validate_code(nv50, p);
+ nv50_program_validate_common(nv50, p);
so_ref(p->so, &so);
return so;
@@ -350,7 +361,7 @@ nv50_geomprog_validate(struct nv50_context *nv50)
if (!(nv50->dirty & NV50_NEW_GEOMPROG))
return NULL;
- nv50_program_validate_code(nv50, p);
+ nv50_program_validate_common(nv50, p);
so_ref(p->so, &so);
return so;
--
cgit v1.2.3
From 4c1e7d931dd6e5676297bee23932cc6d66c93cac Mon Sep 17 00:00:00 2001
From: Christoph Bumiller
Date: Sat, 18 Sep 2010 15:19:34 +0200
Subject: nv50: emit constbuf relocs before uploading constants
---
src/gallium/drivers/nv50/nv50_screen.c | 47 +++++++++++++++++++---------
src/gallium/drivers/nv50/nv50_screen.h | 2 ++
src/gallium/drivers/nv50/nv50_shader_state.c | 28 ++++++++++++-----
3 files changed, 56 insertions(+), 21 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index a8f7721337..7c9342b747 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -221,6 +221,36 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
#define BGN_RELOC(ch, bo, gr, m, n, fl) \
OUT_RELOC(ch, bo, (n << 18) | (gr->subc << 13) | m, fl, 0, 0)
+void
+nv50_screen_reloc_constbuf(struct nv50_screen *screen, unsigned cbi)
+{
+ struct nouveau_bo *bo;
+ struct nouveau_channel *chan = screen->base.channel;
+ struct nouveau_grobj *tesla = screen->tesla;
+ unsigned size;
+ const unsigned rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_DUMMY;
+
+ switch (cbi) {
+ case NV50_CB_PMISC:
+ bo = screen->constbuf_misc[0];
+ size = 0x200;
+ break;
+ case NV50_CB_PVP:
+ case NV50_CB_PFP:
+ case NV50_CB_PGP:
+ bo = screen->constbuf_parm[cbi - NV50_CB_PVP];
+ size = 0;
+ break;
+ default:
+ return;
+ }
+
+ BGN_RELOC (chan, bo, tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
+ OUT_RELOCh(chan, bo, 0, rl);
+ OUT_RELOCl(chan, bo, 0, rl);
+ OUT_RELOC (chan, bo, (cbi << 16) | size, rl, 0, 0);
+}
+
void
nv50_screen_relocs(struct nv50_screen *screen)
{
@@ -243,12 +273,7 @@ nv50_screen_relocs(struct nv50_screen *screen)
OUT_RELOCh(chan, screen->tsc, 0, rl);
OUT_RELOCl(chan, screen->tsc, 0, rl);
- BGN_RELOC (chan, screen->constbuf_misc[0],
- tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
- OUT_RELOCh(chan, screen->constbuf_misc[0], 0, rl);
- OUT_RELOCl(chan, screen->constbuf_misc[0], 0, rl);
- OUT_RELOC (chan, screen->constbuf_misc[0],
- (NV50_CB_PMISC << 16) | 0x0200, rl, 0, 0);
+ nv50_screen_reloc_constbuf(screen, NV50_CB_PMISC);
BGN_RELOC (chan, screen->constbuf_misc[0],
tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
@@ -257,14 +282,8 @@ nv50_screen_relocs(struct nv50_screen *screen)
OUT_RELOC (chan, screen->constbuf_misc[0],
(NV50_CB_AUX << 16) | 0x0200, rl, 0, 0);
- for (i = 0; i < 3; ++i) {
- BGN_RELOC (chan, screen->constbuf_parm[i],
- tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3, rl);
- OUT_RELOCh(chan, screen->constbuf_parm[i], 0, rl);
- OUT_RELOCl(chan, screen->constbuf_parm[i], 0, rl);
- OUT_RELOC (chan, screen->constbuf_parm[i],
- ((NV50_CB_PVP + i) << 16) | 0x0000, rl, 0, 0);
- }
+ for (i = 0; i < 3; ++i)
+ nv50_screen_reloc_constbuf(screen, NV50_CB_PVP + i);
BGN_RELOC (chan, screen->stack_bo,
tesla, NV50TCL_STACK_ADDRESS_HIGH, 2, rl);
diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
index ad6bdeb27c..6e15230b48 100644
--- a/src/gallium/drivers/nv50/nv50_screen.h
+++ b/src/gallium/drivers/nv50/nv50_screen.h
@@ -39,6 +39,8 @@ nv50_screen(struct pipe_screen *screen)
extern void nv50_screen_relocs(struct nv50_screen *);
+extern void nv50_screen_reloc_constbuf(struct nv50_screen *, unsigned cbi);
+
struct nv50_format {
uint32_t rt;
uint32_t tic;
diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c
index 8057ec9fcf..7d2989da05 100644
--- a/src/gallium/drivers/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nv50/nv50_shader_state.c
@@ -47,10 +47,17 @@ nv50_transfer_constbuf(struct nv50_context *nv50,
start = 0;
while (count) {
- unsigned nr = count;
- nr = MIN2(nr, 2047);
+ unsigned nr = AVAIL_RING(chan);
+
+ if (nr < 8) {
+ FIRE_RING(chan);
+ continue;
+ }
+ nr = MIN2(count, nr - 7);
+ nr = MIN2(nr, 2074);
+
+ nv50_screen_reloc_constbuf(nv50->screen, cbi);
- /* FIXME: emit relocs for unsuiTed MM */
BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
OUT_RING (chan, (start << 8) | cbi);
BEGIN_RING_NI(chan, tesla, NV50TCL_CB_DATA(0), nr);
@@ -77,8 +84,16 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
unsigned start = 0;
while (count) {
- unsigned nr = count;
- nr = MIN2(nr, 2047);
+ unsigned nr = AVAIL_RING(chan);
+
+ if (nr < 8) {
+ FIRE_RING(chan);
+ continue;
+ }
+ nr = MIN2(count, nr - 7);
+ nr = MIN2(nr, 2074);
+
+ nv50_screen_reloc_constbuf(nv50->screen, NV50_CB_PMISC);
BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
OUT_RING (chan, (start << 8) | NV50_CB_PMISC);
@@ -111,8 +126,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
break;
default:
assert(0);
- cbi = 0;
- break;
+ return;
}
nv50_transfer_constbuf(nv50, nv50->constbuf[p->type], p->parm_size, cbi);
--
cgit v1.2.3
From 613c3901c3cb748d7ef0bc3162ce3fcb986e9047 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller
Date: Sat, 18 Sep 2010 20:52:44 +0200
Subject: nv50: fix typo in fifo packet length limit
---
src/gallium/drivers/nouveau/nouveau_winsys.h | 4 ++++
src/gallium/drivers/nv50/nv50_shader_state.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index c9003c97f5..ab480cabd0 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -12,6 +12,10 @@
#include "nouveau/nouveau_resource.h"
#include "nouveau/nouveau_pushbuf.h"
+#ifndef NV04_PFIFO_MAX_PACKET_LEN
+#define NV04_PFIFO_MAX_PACKET_LEN 2047
+#endif
+
static INLINE uint32_t
nouveau_screen_transfer_flags(unsigned pipe)
{
diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c
index 7d2989da05..1a2fe758a8 100644
--- a/src/gallium/drivers/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nv50/nv50_shader_state.c
@@ -54,7 +54,7 @@ nv50_transfer_constbuf(struct nv50_context *nv50,
continue;
}
nr = MIN2(count, nr - 7);
- nr = MIN2(nr, 2074);
+ nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
nv50_screen_reloc_constbuf(nv50->screen, cbi);
@@ -91,7 +91,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
continue;
}
nr = MIN2(count, nr - 7);
- nr = MIN2(nr, 2074);
+ nr = MIN2(nr, NV04_PFIFO_MAX_PACKET_LEN);
nv50_screen_reloc_constbuf(nv50->screen, NV50_CB_PMISC);
--
cgit v1.2.3
From ef715b866b6858b79530b44ec7be61f271591adc Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Sat, 18 Sep 2010 15:59:00 -0700
Subject: nv50: Silence missing initializer warning.
Fixes this GCC warning.
nv50_state_validate.c:336: warning: missing initializer
nv50_state_validate.c:336: error: (near initialization for 'validate_list[20].func')
---
src/gallium/drivers/nv50/nv50_state_validate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c
index f1d8202dff..16c2dab9af 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -333,7 +333,7 @@ struct state_validate {
{ validate_vtxbuf , NV50_NEW_ARRAYS },
{ validate_vtxattr , NV50_NEW_ARRAYS },
{ validate_clip , NV50_NEW_CLIP },
- {}
+ { NULL , 0 }
};
#define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0]))
--
cgit v1.2.3
From 03cf572598a1eb593ecebf8c72759bab41588c44 Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Sat, 18 Sep 2010 23:06:29 -0700
Subject: nv50: Remove dead initialization.
---
src/gallium/drivers/nv50/nv50_pc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index 42127a138a..c88e7ba742 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -328,7 +328,7 @@ nv_pc_pass_in_order(struct nv_basic_block *root, nv_pc_pass_func f, void *priv)
static void
nv_do_print_function(void *priv, struct nv_basic_block *b)
{
- struct nv_instruction *i = b->phi;
+ struct nv_instruction *i;
debug_printf("=== BB %i ", b->id);
if (b->out[0])
--
cgit v1.2.3
From fa1056190897719d9ae7410965abb187392ef520 Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Sat, 18 Sep 2010 23:07:41 -0700
Subject: nv50: Remove dead initialization.
---
src/gallium/drivers/nv50/nv50_pc_regalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/nv50/nv50_pc_regalloc.c b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
index b9d5ba5ef6..39ae36681c 100644
--- a/src/gallium/drivers/nv50/nv50_pc_regalloc.c
+++ b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
@@ -767,7 +767,7 @@ nv50_ctor_register_set(struct nv_pc *pc, struct register_set *set)
static void
insert_ordered_tail(struct nv_value *list, struct nv_value *nval)
{
- struct nv_value *elem = list->prev;
+ struct nv_value *elem;
for (elem = list->prev;
elem != list && elem->livei->bgn > nval->livei->bgn;
--
cgit v1.2.3
From 8861727c9190c35f7391ad848fefc6a401872007 Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck
Date: Sat, 18 Sep 2010 16:42:22 +0200
Subject: r600g: Added support for TGSI_SEMANTIC_FACE.
This makes the 'glsl1-gl_FrontFacing var (1)' piglit test pass.
Signed-off-by: Tilman Sauerbeck
---
src/gallium/drivers/r600/eg_hw_states.c | 9 ++++++++-
src/gallium/drivers/r600/r600_hw_states.c | 9 ++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_hw_states.c b/src/gallium/drivers/r600/eg_hw_states.c
index d6f417e1e3..ad8aa4ca9a 100644
--- a/src/gallium/drivers/r600/eg_hw_states.c
+++ b/src/gallium/drivers/r600/eg_hw_states.c
@@ -930,7 +930,7 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
const struct pipe_rasterizer_state *rasterizer;
struct r600_shader *rshader = &rpshader->shader;
unsigned i, tmp, exports_ps, num_cout;
- boolean have_pos = FALSE;
+ boolean have_pos = FALSE, have_face = FALSE;
rasterizer = &rctx->rasterizer->state.rasterizer;
@@ -945,6 +945,10 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
}
+
+ if (rshader->input[i].name == TGSI_SEMANTIC_FACE)
+ have_face = TRUE;
+
if (rasterizer->sprite_coord_enable & (1 << i)) {
tmp |= S_028644_PT_SPRITE_TEX(1);
}
@@ -971,7 +975,10 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
state->states[EG_PS_SHADER__SPI_PS_IN_CONTROL_0] |= S_0286CC_POSITION_ENA(1);
state->states[EG_PS_SHADER__SPI_INPUT_Z] |= 1;
}
+
state->states[EG_PS_SHADER__SPI_PS_IN_CONTROL_1] = 0x00000000;
+ state->states[EG_PS_SHADER__SPI_PS_IN_CONTROL_1] |= S_0286D0_FRONT_FACE_ENA(have_face);
+
state->states[EG_PS_SHADER__SQ_PGM_RESOURCES_PS] = S_028844_NUM_GPRS(rshader->bc.ngpr) | S_028844_PRIME_CACHE_ON_DRAW(1) |
S_028844_STACK_SIZE(rshader->bc.nstack);
state->states[EG_PS_SHADER__SQ_PGM_EXPORTS_PS] = exports_ps;
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index bca78ee8de..25344c6f82 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -943,7 +943,7 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
const struct pipe_rasterizer_state *rasterizer;
struct r600_shader *rshader = &rpshader->shader;
unsigned i, tmp, exports_ps, num_cout;
- boolean have_pos = FALSE;
+ boolean have_pos = FALSE, have_face = FALSE;
rasterizer = &rctx->rasterizer->state.rasterizer;
@@ -958,6 +958,10 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
}
+
+ if (rshader->input[i].name == TGSI_SEMANTIC_FACE)
+ have_face = TRUE;
+
if (rasterizer->sprite_coord_enable & (1 << i)) {
tmp |= S_028644_PT_SPRITE_TEX(1);
}
@@ -985,7 +989,10 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
S_0286CC_BARYC_SAMPLE_CNTL(1);
state->states[R600_PS_SHADER__SPI_INPUT_Z] |= 1;
}
+
state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] = 0x00000000;
+ state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] |= S_0286D0_FRONT_FACE_ENA(have_face);
+
state->states[R600_PS_SHADER__SQ_PGM_RESOURCES_PS] = S_028868_NUM_GPRS(rshader->bc.ngpr) |
S_028868_STACK_SIZE(rshader->bc.nstack);
state->states[R600_PS_SHADER__SQ_PGM_EXPORTS_PS] = exports_ps;
--
cgit v1.2.3
From c5edfcc410bdf3dbe4f37418de8f0009746c9578 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Sun, 19 Sep 2010 17:14:57 +1000
Subject: r600g; add uses waterfall to asm cf for r6xx.
On r6xx if an MOVA instruction is emitted we should set this bit.
---
src/gallium/drivers/r600/r600_asm.c | 1 +
src/gallium/drivers/r600/r600_asm.h | 1 +
src/gallium/drivers/r600/r600_shader.c | 1 +
3 files changed, 3 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c
index 0d17f75da7..93dc142011 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -696,6 +696,7 @@ static int r600_bc_cf_build(struct r600_bc *bc, struct r600_bc_cf *cf)
bc->bytecode[id++] = S_SQ_CF_ALU_WORD1_CF_INST(cf->inst >> 3) |
S_SQ_CF_ALU_WORD1_BARRIER(1) |
+ S_SQ_CF_ALU_WORD1_USES_WATERFALL(cf->r6xx_uses_waterfall) |
S_SQ_CF_ALU_WORD1_COUNT((cf->ndw / 2) - 1);
break;
case V_SQ_CF_WORD1_SQ_CF_INST_TEX:
diff --git a/src/gallium/drivers/r600/r600_asm.h b/src/gallium/drivers/r600/r600_asm.h
index 62a46cb0e1..6aadf72957 100644
--- a/src/gallium/drivers/r600/r600_asm.h
+++ b/src/gallium/drivers/r600/r600_asm.h
@@ -127,6 +127,7 @@ struct r600_bc_cf {
unsigned pop_count;
unsigned cf_addr; /* control flow addr */
unsigned kcache0_mode;
+ unsigned r6xx_uses_waterfall;
struct list_head alu;
struct list_head tex;
struct list_head vtx;
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 4da6850b0a..eac46a7ae6 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -2313,6 +2313,7 @@ static int tgsi_arl(struct r600_shader_ctx *ctx)
r = r600_bc_add_alu_type(ctx->bc, &alu, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU));
if (r)
return r;
+ ctx->bc->cf_last->r6xx_uses_waterfall = 1;
return 0;
}
--
cgit v1.2.3
From ed4f740127d6896506a91c8c5b9c527a971e982b Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Sun, 19 Sep 2010 17:25:50 +1000
Subject: r600g: only emit uses waterfall on r6xx hw.
---
src/gallium/drivers/r600/r600_asm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c
index 93dc142011..8c01987318 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -696,7 +696,7 @@ static int r600_bc_cf_build(struct r600_bc *bc, struct r600_bc_cf *cf)
bc->bytecode[id++] = S_SQ_CF_ALU_WORD1_CF_INST(cf->inst >> 3) |
S_SQ_CF_ALU_WORD1_BARRIER(1) |
- S_SQ_CF_ALU_WORD1_USES_WATERFALL(cf->r6xx_uses_waterfall) |
+ S_SQ_CF_ALU_WORD1_USES_WATERFALL(bc->chiprev == 0 ? cf->r6xx_uses_waterfall : 0) |
S_SQ_CF_ALU_WORD1_COUNT((cf->ndw / 2) - 1);
break;
case V_SQ_CF_WORD1_SQ_CF_INST_TEX:
--
cgit v1.2.3
From c7c2e7d0ce97b1586219be2ba742758f23f5c7aa Mon Sep 17 00:00:00 2001
From: Chia-I Wu
Date: Sun, 19 Sep 2010 16:32:06 +0800
Subject: st/egl: Split modeset code support to modeset.c.
The modeset code supports now obsolete EGL_MESA_screen_surface. Move it
to a file of its own.
---
src/gallium/state_trackers/egl/kms/modeset.c | 619 ++++++++++++++++++++++++
src/gallium/state_trackers/egl/kms/native_kms.c | 572 +---------------------
src/gallium/state_trackers/egl/kms/native_kms.h | 43 +-
3 files changed, 647 insertions(+), 587 deletions(-)
create mode 100644 src/gallium/state_trackers/egl/kms/modeset.c
(limited to 'src/gallium')
diff --git a/src/gallium/state_trackers/egl/kms/modeset.c b/src/gallium/state_trackers/egl/kms/modeset.c
new file mode 100644
index 0000000000..9473a0e5f4
--- /dev/null
+++ b/src/gallium/state_trackers/egl/kms/modeset.c
@@ -0,0 +1,619 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ * Chia-I Wu
+ */
+
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+#include "egllog.h"
+
+#include "native_kms.h"
+
+static boolean
+kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_resource **textures,
+ int *width, int *height)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+
+ if (!resource_surface_add_resources(ksurf->rsurf, attachment_mask))
+ return FALSE;
+ if (textures)
+ resource_surface_get_resources(ksurf->rsurf, textures, attachment_mask);
+
+ if (seq_num)
+ *seq_num = ksurf->sequence_number;
+ if (width)
+ *width = ksurf->width;
+ if (height)
+ *height = ksurf->height;
+
+ return TRUE;
+}
+
+/**
+ * Add textures as DRM framebuffers.
+ */
+static boolean
+kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ struct kms_display *kdpy = ksurf->kdpy;
+ int num_framebuffers = (need_back) ? 2 : 1;
+ int i, err;
+
+ for (i = 0; i < num_framebuffers; i++) {
+ struct kms_framebuffer *fb;
+ enum native_attachment natt;
+ struct winsys_handle whandle;
+ uint block_bits;
+
+ if (i == 0) {
+ fb = &ksurf->front_fb;
+ natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+ }
+ else {
+ fb = &ksurf->back_fb;
+ natt = NATIVE_ATTACHMENT_BACK_LEFT;
+ }
+
+ if (!fb->texture) {
+ /* make sure the texture has been allocated */
+ resource_surface_add_resources(ksurf->rsurf, 1 << natt);
+ fb->texture =
+ resource_surface_get_single_resource(ksurf->rsurf, natt);
+ if (!fb->texture)
+ return FALSE;
+ }
+
+ /* already initialized */
+ if (fb->buffer_id)
+ continue;
+
+ /* TODO detect the real value */
+ fb->is_passive = TRUE;
+
+ memset(&whandle, 0, sizeof(whandle));
+ whandle.type = DRM_API_HANDLE_TYPE_KMS;
+
+ if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
+ fb->texture, &whandle))
+ return FALSE;
+
+ block_bits = util_format_get_blocksizebits(ksurf->color_format);
+ err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height,
+ block_bits, block_bits, whandle.stride, whandle.handle,
+ &fb->buffer_id);
+ if (err) {
+ fb->buffer_id = 0;
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static boolean
+kms_surface_flush_frontbuffer(struct native_surface *nsurf)
+{
+#ifdef DRM_MODE_FEATURE_DIRTYFB
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ struct kms_display *kdpy = ksurf->kdpy;
+
+ if (ksurf->front_fb.is_passive)
+ drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0);
+#endif
+
+ return TRUE;
+}
+
+static boolean
+kms_surface_swap_buffers(struct native_surface *nsurf)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ struct kms_crtc *kcrtc = &ksurf->current_crtc;
+ struct kms_display *kdpy = ksurf->kdpy;
+ struct kms_framebuffer tmp_fb;
+ int err;
+
+ if (!ksurf->back_fb.buffer_id) {
+ if (!kms_surface_init_framebuffers(&ksurf->base, TRUE))
+ return FALSE;
+ }
+
+ if (ksurf->is_shown && kcrtc->crtc) {
+ err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
+ ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
+ kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode);
+ if (err)
+ return FALSE;
+ }
+
+ /* swap the buffers */
+ tmp_fb = ksurf->front_fb;
+ ksurf->front_fb = ksurf->back_fb;
+ ksurf->back_fb = tmp_fb;
+
+ resource_surface_swap_buffers(ksurf->rsurf,
+ NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, FALSE);
+ /* the front/back textures are swapped */
+ ksurf->sequence_number++;
+ kdpy->event_handler->invalid_surface(&kdpy->base,
+ &ksurf->base, ksurf->sequence_number);
+
+ return TRUE;
+}
+
+static void
+kms_surface_wait(struct native_surface *nsurf)
+{
+ /* no-op */
+}
+
+static void
+kms_surface_destroy(struct native_surface *nsurf)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+
+ if (ksurf->current_crtc.crtc)
+ drmModeFreeCrtc(ksurf->current_crtc.crtc);
+
+ if (ksurf->front_fb.buffer_id)
+ drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
+ pipe_resource_reference(&ksurf->front_fb.texture, NULL);
+
+ if (ksurf->back_fb.buffer_id)
+ drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
+ pipe_resource_reference(&ksurf->back_fb.texture, NULL);
+
+ resource_surface_destroy(ksurf->rsurf);
+ FREE(ksurf);
+}
+
+static struct kms_surface *
+kms_display_create_surface(struct native_display *ndpy,
+ const struct native_config *nconf,
+ uint width, uint height)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_config *kconf = kms_config(nconf);
+ struct kms_surface *ksurf;
+
+ ksurf = CALLOC_STRUCT(kms_surface);
+ if (!ksurf)
+ return NULL;
+
+ ksurf->kdpy = kdpy;
+ ksurf->color_format = kconf->base.color_format;
+ ksurf->width = width;
+ ksurf->height = height;
+
+ ksurf->rsurf = resource_surface_create(kdpy->base.screen,
+ ksurf->color_format,
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_SAMPLER_VIEW |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT);
+ if (!ksurf->rsurf) {
+ FREE(ksurf);
+ return NULL;
+ }
+
+ resource_surface_set_size(ksurf->rsurf, ksurf->width, ksurf->height);
+
+ ksurf->base.destroy = kms_surface_destroy;
+ ksurf->base.swap_buffers = kms_surface_swap_buffers;
+ ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer;
+ ksurf->base.validate = kms_surface_validate;
+ ksurf->base.wait = kms_surface_wait;
+
+ return ksurf;
+}
+
+/**
+ * Choose a CRTC that supports all given connectors.
+ */
+static uint32_t
+kms_display_choose_crtc(struct native_display *ndpy,
+ uint32_t *connectors, int num_connectors)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ int idx;
+
+ for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) {
+ boolean found_crtc = TRUE;
+ int i, j;
+
+ for (i = 0; i < num_connectors; i++) {
+ drmModeConnectorPtr connector;
+ int encoder_idx = -1;
+
+ connector = drmModeGetConnector(kdpy->fd, connectors[i]);
+ if (!connector) {
+ found_crtc = FALSE;
+ break;
+ }
+
+ /* find an encoder the CRTC supports */
+ for (j = 0; j < connector->count_encoders; j++) {
+ drmModeEncoderPtr encoder =
+ drmModeGetEncoder(kdpy->fd, connector->encoders[j]);
+ if (encoder->possible_crtcs & (1 << idx)) {
+ encoder_idx = j;
+ break;
+ }
+ drmModeFreeEncoder(encoder);
+ }
+
+ drmModeFreeConnector(connector);
+ if (encoder_idx < 0) {
+ found_crtc = FALSE;
+ break;
+ }
+ }
+
+ if (found_crtc)
+ break;
+ }
+
+ if (idx >= kdpy->resources->count_crtcs) {
+ _eglLog(_EGL_WARNING,
+ "failed to find a CRTC that supports the given %d connectors",
+ num_connectors);
+ return 0;
+ }
+
+ return kdpy->resources->crtcs[idx];
+}
+
+/**
+ * Remember the original CRTC status and set the CRTC
+ */
+static boolean
+kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
+ uint32_t buffer_id, uint32_t x, uint32_t y,
+ uint32_t *connectors, int num_connectors,
+ drmModeModeInfoPtr mode)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx];
+ uint32_t crtc_id;
+ int err;
+
+ if (kcrtc->crtc) {
+ crtc_id = kcrtc->crtc->crtc_id;
+ }
+ else {
+ int count = 0, i;
+
+ /*
+ * Choose the CRTC once. It could be more dynamic, but let's keep it
+ * simple for now.
+ */
+ crtc_id = kms_display_choose_crtc(&kdpy->base,
+ connectors, num_connectors);
+
+ /* save the original CRTC status */
+ kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
+ if (!kcrtc->crtc)
+ return FALSE;
+
+ for (i = 0; i < kdpy->num_connectors; i++) {
+ struct kms_connector *kconn = &kdpy->connectors[i];
+ drmModeConnectorPtr connector = kconn->connector;
+ drmModeEncoderPtr encoder;
+
+ encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id);
+ if (encoder) {
+ if (encoder->crtc_id == crtc_id) {
+ kcrtc->connectors[count++] = connector->connector_id;
+ if (count >= Elements(kcrtc->connectors))
+ break;
+ }
+ drmModeFreeEncoder(encoder);
+ }
+ }
+
+ kcrtc->num_connectors = count;
+ }
+
+ err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y,
+ connectors, num_connectors, mode);
+ if (err) {
+ drmModeFreeCrtc(kcrtc->crtc);
+ kcrtc->crtc = NULL;
+ kcrtc->num_connectors = 0;
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static boolean
+kms_display_program(struct native_display *ndpy, int crtc_idx,
+ struct native_surface *nsurf, uint x, uint y,
+ const struct native_connector **nconns, int num_nconns,
+ const struct native_mode *nmode)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ const struct kms_mode *kmode = kms_mode(nmode);
+ uint32_t connector_ids[32];
+ uint32_t buffer_id;
+ drmModeModeInfo mode_tmp, *mode;
+ int i;
+
+ if (num_nconns > Elements(connector_ids)) {
+ _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns);
+ num_nconns = Elements(connector_ids);
+ }
+
+ if (ksurf) {
+ if (!kms_surface_init_framebuffers(&ksurf->base, FALSE))
+ return FALSE;
+
+ buffer_id = ksurf->front_fb.buffer_id;
+ /* the mode argument of drmModeSetCrtc is not constified */
+ mode_tmp = kmode->mode;
+ mode = &mode_tmp;
+ }
+ else {
+ /* disable the CRTC */
+ buffer_id = 0;
+ mode = NULL;
+ num_nconns = 0;
+ }
+
+ for (i = 0; i < num_nconns; i++) {
+ struct kms_connector *kconn = kms_connector(nconns[i]);
+ connector_ids[i] = kconn->connector->connector_id;
+ }
+
+ if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y,
+ connector_ids, num_nconns, mode)) {
+ _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
+
+ return FALSE;
+ }
+
+ if (kdpy->shown_surfaces[crtc_idx])
+ kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
+ kdpy->shown_surfaces[crtc_idx] = ksurf;
+
+ /* remember the settings for buffer swapping */
+ if (ksurf) {
+ uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
+ struct kms_crtc *kcrtc = &ksurf->current_crtc;
+
+ if (kcrtc->crtc)
+ drmModeFreeCrtc(kcrtc->crtc);
+ kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
+
+ assert(num_nconns < Elements(kcrtc->connectors));
+ memcpy(kcrtc->connectors, connector_ids,
+ sizeof(*connector_ids) * num_nconns);
+ kcrtc->num_connectors = num_nconns;
+
+ ksurf->is_shown = TRUE;
+ }
+
+ return TRUE;
+}
+
+static const struct native_mode **
+kms_display_get_modes(struct native_display *ndpy,
+ const struct native_connector *nconn,
+ int *num_modes)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_connector *kconn = kms_connector(nconn);
+ const struct native_mode **nmodes_return;
+ int count, i;
+
+ /* delete old data */
+ if (kconn->connector) {
+ drmModeFreeConnector(kconn->connector);
+ FREE(kconn->kms_modes);
+
+ kconn->connector = NULL;
+ kconn->kms_modes = NULL;
+ kconn->num_modes = 0;
+ }
+
+ /* detect again */
+ kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id);
+ if (!kconn->connector)
+ return NULL;
+
+ count = kconn->connector->count_modes;
+ kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
+ if (!kconn->kms_modes) {
+ drmModeFreeConnector(kconn->connector);
+ kconn->connector = NULL;
+
+ return NULL;
+ }
+
+ for (i = 0; i < count; i++) {
+ struct kms_mode *kmode = &kconn->kms_modes[i];
+ drmModeModeInfoPtr mode = &kconn->connector->modes[i];
+
+ kmode->mode = *mode;
+
+ kmode->base.desc = kmode->mode.name;
+ kmode->base.width = kmode->mode.hdisplay;
+ kmode->base.height = kmode->mode.vdisplay;
+ kmode->base.refresh_rate = kmode->mode.vrefresh;
+ /* not all kernels have vrefresh = refresh_rate * 1000 */
+ if (kmode->base.refresh_rate > 1000)
+ kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
+ }
+
+ nmodes_return = MALLOC(count * sizeof(*nmodes_return));
+ if (nmodes_return) {
+ for (i = 0; i < count; i++)
+ nmodes_return[i] = &kconn->kms_modes[i].base;
+ if (num_modes)
+ *num_modes = count;
+ }
+
+ return nmodes_return;
+}
+
+static const struct native_connector **
+kms_display_get_connectors(struct native_display *ndpy, int *num_connectors,
+ int *num_crtc)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ const struct native_connector **connectors;
+ int i;
+
+ if (!kdpy->connectors) {
+ kdpy->connectors =
+ CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
+ if (!kdpy->connectors)
+ return NULL;
+
+ for (i = 0; i < kdpy->resources->count_connectors; i++) {
+ struct kms_connector *kconn = &kdpy->connectors[i];
+
+ kconn->connector_id = kdpy->resources->connectors[i];
+ /* kconn->connector is allocated when the modes are asked */
+ }
+
+ kdpy->num_connectors = kdpy->resources->count_connectors;
+ }
+
+ connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
+ if (connectors) {
+ for (i = 0; i < kdpy->num_connectors; i++)
+ connectors[i] = &kdpy->connectors[i].base;
+ if (num_connectors)
+ *num_connectors = kdpy->num_connectors;
+ }
+
+ if (num_crtc)
+ *num_crtc = kdpy->resources->count_crtcs;
+
+ return connectors;
+}
+
+static struct native_surface *
+kms_display_create_scanout_surface(struct native_display *ndpy,
+ const struct native_config *nconf,
+ uint width, uint height)
+{
+ struct kms_surface *ksurf;
+
+ ksurf = kms_display_create_surface(ndpy, nconf, width, height);
+ return &ksurf->base;
+}
+
+static struct native_display_modeset kms_display_modeset = {
+ .get_connectors = kms_display_get_connectors,
+ .get_modes = kms_display_get_modes,
+ .create_scanout_surface = kms_display_create_scanout_surface,
+ .program = kms_display_program
+};
+
+void
+kms_display_fini_modeset(struct native_display *ndpy)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ int i;
+
+ if (kdpy->connectors) {
+ for (i = 0; i < kdpy->num_connectors; i++) {
+ struct kms_connector *kconn = &kdpy->connectors[i];
+ if (kconn->connector) {
+ drmModeFreeConnector(kconn->connector);
+ FREE(kconn->kms_modes);
+ }
+ }
+ FREE(kdpy->connectors);
+ }
+
+ if (kdpy->shown_surfaces) {
+ FREE(kdpy->shown_surfaces);
+ kdpy->shown_surfaces = NULL;
+ }
+
+ if (kdpy->saved_crtcs) {
+ for (i = 0; i < kdpy->resources->count_crtcs; i++) {
+ struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i];
+
+ if (kcrtc->crtc) {
+ /* restore crtc */
+ drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
+ kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
+ kcrtc->connectors, kcrtc->num_connectors,
+ &kcrtc->crtc->mode);
+
+ drmModeFreeCrtc(kcrtc->crtc);
+ }
+ }
+ FREE(kdpy->saved_crtcs);
+ }
+
+ if (kdpy->resources) {
+ drmModeFreeResources(kdpy->resources);
+ kdpy->resources = NULL;
+ }
+
+ kdpy->base.modeset = NULL;
+}
+
+boolean
+kms_display_init_modeset(struct native_display *ndpy)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+
+ /* resources are fixed, unlike crtc, connector, or encoder */
+ kdpy->resources = drmModeGetResources(kdpy->fd);
+ if (!kdpy->resources) {
+ _eglLog(_EGL_DEBUG, "Failed to get KMS resources. Disable modeset.");
+ return FALSE;
+ }
+
+ kdpy->saved_crtcs =
+ CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
+ if (!kdpy->saved_crtcs) {
+ kms_display_fini_modeset(&kdpy->base);
+ return FALSE;
+ }
+
+ kdpy->shown_surfaces =
+ CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
+ if (!kdpy->shown_surfaces) {
+ kms_display_fini_modeset(&kdpy->base);
+ return FALSE;
+ }
+
+ kdpy->base.modeset = &kms_display_modeset;
+
+ return TRUE;
+}
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c
index 208f73306c..94880c3696 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.c
+++ b/src/gallium/state_trackers/egl/kms/native_kms.c
@@ -27,13 +27,7 @@
#include
#include
-#include "pipe/p_screen.h"
-#include "pipe/p_context.h"
-#include "util/u_debug.h"
#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "util/u_pointer.h"
-#include "util/u_string.h"
#include "egllog.h"
#include "native_kms.h"
@@ -42,507 +36,6 @@
#include
#include "radeon/drm/radeon_drm.h"
-static boolean
-kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
- unsigned int *seq_num, struct pipe_resource **textures,
- int *width, int *height)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
-
- if (!resource_surface_add_resources(ksurf->rsurf, attachment_mask))
- return FALSE;
- if (textures)
- resource_surface_get_resources(ksurf->rsurf, textures, attachment_mask);
-
- if (seq_num)
- *seq_num = ksurf->sequence_number;
- if (width)
- *width = ksurf->width;
- if (height)
- *height = ksurf->height;
-
- return TRUE;
-}
-
-/**
- * Add textures as DRM framebuffers.
- */
-static boolean
-kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
- int num_framebuffers = (need_back) ? 2 : 1;
- int i, err;
-
- for (i = 0; i < num_framebuffers; i++) {
- struct kms_framebuffer *fb;
- enum native_attachment natt;
- struct winsys_handle whandle;
- uint block_bits;
-
- if (i == 0) {
- fb = &ksurf->front_fb;
- natt = NATIVE_ATTACHMENT_FRONT_LEFT;
- }
- else {
- fb = &ksurf->back_fb;
- natt = NATIVE_ATTACHMENT_BACK_LEFT;
- }
-
- if (!fb->texture) {
- /* make sure the texture has been allocated */
- resource_surface_add_resources(ksurf->rsurf, 1 << natt);
- fb->texture =
- resource_surface_get_single_resource(ksurf->rsurf, natt);
- if (!fb->texture)
- return FALSE;
- }
-
- /* already initialized */
- if (fb->buffer_id)
- continue;
-
- /* TODO detect the real value */
- fb->is_passive = TRUE;
-
- memset(&whandle, 0, sizeof(whandle));
- whandle.type = DRM_API_HANDLE_TYPE_KMS;
-
- if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
- fb->texture, &whandle))
- return FALSE;
-
- block_bits = util_format_get_blocksizebits(ksurf->color_format);
- err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height,
- block_bits, block_bits, whandle.stride, whandle.handle,
- &fb->buffer_id);
- if (err) {
- fb->buffer_id = 0;
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static boolean
-kms_surface_flush_frontbuffer(struct native_surface *nsurf)
-{
-#ifdef DRM_MODE_FEATURE_DIRTYFB
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
-
- if (ksurf->front_fb.is_passive)
- drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0);
-#endif
-
- return TRUE;
-}
-
-static boolean
-kms_surface_swap_buffers(struct native_surface *nsurf)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
- struct kms_display *kdpy = ksurf->kdpy;
- struct kms_framebuffer tmp_fb;
- int err;
-
- if (!ksurf->back_fb.buffer_id) {
- if (!kms_surface_init_framebuffers(&ksurf->base, TRUE))
- return FALSE;
- }
-
- if (ksurf->is_shown && kcrtc->crtc) {
- err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode);
- if (err)
- return FALSE;
- }
-
- /* swap the buffers */
- tmp_fb = ksurf->front_fb;
- ksurf->front_fb = ksurf->back_fb;
- ksurf->back_fb = tmp_fb;
-
- resource_surface_swap_buffers(ksurf->rsurf,
- NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, FALSE);
- /* the front/back textures are swapped */
- ksurf->sequence_number++;
- kdpy->event_handler->invalid_surface(&kdpy->base,
- &ksurf->base, ksurf->sequence_number);
-
- return TRUE;
-}
-
-static void
-kms_surface_wait(struct native_surface *nsurf)
-{
- /* no-op */
-}
-
-static void
-kms_surface_destroy(struct native_surface *nsurf)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
-
- if (ksurf->current_crtc.crtc)
- drmModeFreeCrtc(ksurf->current_crtc.crtc);
-
- if (ksurf->front_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
- pipe_resource_reference(&ksurf->front_fb.texture, NULL);
-
- if (ksurf->back_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
- pipe_resource_reference(&ksurf->back_fb.texture, NULL);
-
- resource_surface_destroy(ksurf->rsurf);
- FREE(ksurf);
-}
-
-static struct kms_surface *
-kms_display_create_surface(struct native_display *ndpy,
- const struct native_config *nconf,
- uint width, uint height)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_config *kconf = kms_config(nconf);
- struct kms_surface *ksurf;
-
- ksurf = CALLOC_STRUCT(kms_surface);
- if (!ksurf)
- return NULL;
-
- ksurf->kdpy = kdpy;
- ksurf->color_format = kconf->base.color_format;
- ksurf->width = width;
- ksurf->height = height;
-
- ksurf->rsurf = resource_surface_create(kdpy->base.screen,
- ksurf->color_format,
- PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_SAMPLER_VIEW |
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SCANOUT);
- if (!ksurf->rsurf) {
- FREE(ksurf);
- return NULL;
- }
-
- resource_surface_set_size(ksurf->rsurf, ksurf->width, ksurf->height);
-
- ksurf->base.destroy = kms_surface_destroy;
- ksurf->base.swap_buffers = kms_surface_swap_buffers;
- ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer;
- ksurf->base.validate = kms_surface_validate;
- ksurf->base.wait = kms_surface_wait;
-
- return ksurf;
-}
-
-/**
- * Choose a CRTC that supports all given connectors.
- */
-static uint32_t
-kms_display_choose_crtc(struct native_display *ndpy,
- uint32_t *connectors, int num_connectors)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- int idx;
-
- for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) {
- boolean found_crtc = TRUE;
- int i, j;
-
- for (i = 0; i < num_connectors; i++) {
- drmModeConnectorPtr connector;
- int encoder_idx = -1;
-
- connector = drmModeGetConnector(kdpy->fd, connectors[i]);
- if (!connector) {
- found_crtc = FALSE;
- break;
- }
-
- /* find an encoder the CRTC supports */
- for (j = 0; j < connector->count_encoders; j++) {
- drmModeEncoderPtr encoder =
- drmModeGetEncoder(kdpy->fd, connector->encoders[j]);
- if (encoder->possible_crtcs & (1 << idx)) {
- encoder_idx = j;
- break;
- }
- drmModeFreeEncoder(encoder);
- }
-
- drmModeFreeConnector(connector);
- if (encoder_idx < 0) {
- found_crtc = FALSE;
- break;
- }
- }
-
- if (found_crtc)
- break;
- }
-
- if (idx >= kdpy->resources->count_crtcs) {
- _eglLog(_EGL_WARNING,
- "failed to find a CRTC that supports the given %d connectors",
- num_connectors);
- return 0;
- }
-
- return kdpy->resources->crtcs[idx];
-}
-
-/**
- * Remember the original CRTC status and set the CRTC
- */
-static boolean
-kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
- uint32_t buffer_id, uint32_t x, uint32_t y,
- uint32_t *connectors, int num_connectors,
- drmModeModeInfoPtr mode)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx];
- uint32_t crtc_id;
- int err;
-
- if (kcrtc->crtc) {
- crtc_id = kcrtc->crtc->crtc_id;
- }
- else {
- int count = 0, i;
-
- /*
- * Choose the CRTC once. It could be more dynamic, but let's keep it
- * simple for now.
- */
- crtc_id = kms_display_choose_crtc(&kdpy->base,
- connectors, num_connectors);
-
- /* save the original CRTC status */
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
- if (!kcrtc->crtc)
- return FALSE;
-
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- drmModeConnectorPtr connector = kconn->connector;
- drmModeEncoderPtr encoder;
-
- encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id);
- if (encoder) {
- if (encoder->crtc_id == crtc_id) {
- kcrtc->connectors[count++] = connector->connector_id;
- if (count >= Elements(kcrtc->connectors))
- break;
- }
- drmModeFreeEncoder(encoder);
- }
- }
-
- kcrtc->num_connectors = count;
- }
-
- err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y,
- connectors, num_connectors, mode);
- if (err) {
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = NULL;
- kcrtc->num_connectors = 0;
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-static boolean
-kms_display_program(struct native_display *ndpy, int crtc_idx,
- struct native_surface *nsurf, uint x, uint y,
- const struct native_connector **nconns, int num_nconns,
- const struct native_mode *nmode)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_surface *ksurf = kms_surface(nsurf);
- const struct kms_mode *kmode = kms_mode(nmode);
- uint32_t connector_ids[32];
- uint32_t buffer_id;
- drmModeModeInfo mode_tmp, *mode;
- int i;
-
- if (num_nconns > Elements(connector_ids)) {
- _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns);
- num_nconns = Elements(connector_ids);
- }
-
- if (ksurf) {
- if (!kms_surface_init_framebuffers(&ksurf->base, FALSE))
- return FALSE;
-
- buffer_id = ksurf->front_fb.buffer_id;
- /* the mode argument of drmModeSetCrtc is not constified */
- mode_tmp = kmode->mode;
- mode = &mode_tmp;
- }
- else {
- /* disable the CRTC */
- buffer_id = 0;
- mode = NULL;
- num_nconns = 0;
- }
-
- for (i = 0; i < num_nconns; i++) {
- struct kms_connector *kconn = kms_connector(nconns[i]);
- connector_ids[i] = kconn->connector->connector_id;
- }
-
- if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y,
- connector_ids, num_nconns, mode)) {
- _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
-
- return FALSE;
- }
-
- if (kdpy->shown_surfaces[crtc_idx])
- kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
- kdpy->shown_surfaces[crtc_idx] = ksurf;
-
- /* remember the settings for buffer swapping */
- if (ksurf) {
- uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
-
- if (kcrtc->crtc)
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
-
- assert(num_nconns < Elements(kcrtc->connectors));
- memcpy(kcrtc->connectors, connector_ids,
- sizeof(*connector_ids) * num_nconns);
- kcrtc->num_connectors = num_nconns;
-
- ksurf->is_shown = TRUE;
- }
-
- return TRUE;
-}
-
-static const struct native_mode **
-kms_display_get_modes(struct native_display *ndpy,
- const struct native_connector *nconn,
- int *num_modes)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_connector *kconn = kms_connector(nconn);
- const struct native_mode **nmodes_return;
- int count, i;
-
- /* delete old data */
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
-
- kconn->connector = NULL;
- kconn->kms_modes = NULL;
- kconn->num_modes = 0;
- }
-
- /* detect again */
- kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id);
- if (!kconn->connector)
- return NULL;
-
- count = kconn->connector->count_modes;
- kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
- if (!kconn->kms_modes) {
- drmModeFreeConnector(kconn->connector);
- kconn->connector = NULL;
-
- return NULL;
- }
-
- for (i = 0; i < count; i++) {
- struct kms_mode *kmode = &kconn->kms_modes[i];
- drmModeModeInfoPtr mode = &kconn->connector->modes[i];
-
- kmode->mode = *mode;
-
- kmode->base.desc = kmode->mode.name;
- kmode->base.width = kmode->mode.hdisplay;
- kmode->base.height = kmode->mode.vdisplay;
- kmode->base.refresh_rate = kmode->mode.vrefresh;
- /* not all kernels have vrefresh = refresh_rate * 1000 */
- if (kmode->base.refresh_rate > 1000)
- kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
- }
-
- nmodes_return = MALLOC(count * sizeof(*nmodes_return));
- if (nmodes_return) {
- for (i = 0; i < count; i++)
- nmodes_return[i] = &kconn->kms_modes[i].base;
- if (num_modes)
- *num_modes = count;
- }
-
- return nmodes_return;
-}
-
-static const struct native_connector **
-kms_display_get_connectors(struct native_display *ndpy, int *num_connectors,
- int *num_crtc)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- const struct native_connector **connectors;
- int i;
-
- if (!kdpy->connectors) {
- kdpy->connectors =
- CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
- if (!kdpy->connectors)
- return NULL;
-
- for (i = 0; i < kdpy->resources->count_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
-
- kconn->connector_id = kdpy->resources->connectors[i];
- /* kconn->connector is allocated when the modes are asked */
- }
-
- kdpy->num_connectors = kdpy->resources->count_connectors;
- }
-
- connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
- if (connectors) {
- for (i = 0; i < kdpy->num_connectors; i++)
- connectors[i] = &kdpy->connectors[i].base;
- if (num_connectors)
- *num_connectors = kdpy->num_connectors;
- }
-
- if (num_crtc)
- *num_crtc = kdpy->resources->count_crtcs;
-
- return connectors;
-}
-
-static struct native_surface *
-kms_display_create_scanout_surface(struct native_display *ndpy,
- const struct native_config *nconf,
- uint width, uint height)
-{
- struct kms_surface *ksurf;
-
- ksurf = kms_display_create_surface(ndpy, nconf, width, height);
- return &ksurf->base;
-}
-
static boolean
kms_display_is_format_supported(struct native_display *ndpy,
enum pipe_format fmt, boolean is_color)
@@ -622,44 +115,11 @@ static void
kms_display_destroy(struct native_display *ndpy)
{
struct kms_display *kdpy = kms_display(ndpy);
- int i;
if (kdpy->config)
FREE(kdpy->config);
- if (kdpy->connectors) {
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
- }
- }
- FREE(kdpy->connectors);
- }
-
- if (kdpy->shown_surfaces)
- FREE(kdpy->shown_surfaces);
-
- if (kdpy->saved_crtcs) {
- for (i = 0; i < kdpy->resources->count_crtcs; i++) {
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i];
-
- if (kcrtc->crtc) {
- /* restore crtc */
- drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors,
- &kcrtc->crtc->mode);
-
- drmModeFreeCrtc(kcrtc->crtc);
- }
- }
- FREE(kdpy->saved_crtcs);
- }
-
- if (kdpy->resources)
- drmModeFreeResources(kdpy->resources);
+ kms_display_fini_modeset(&kdpy->base);
if (kdpy->base.screen)
kdpy->base.screen->destroy(kdpy->base.screen);
@@ -722,13 +182,6 @@ kms_display_init_screen(struct native_display *ndpy)
return TRUE;
}
-static struct native_display_modeset kms_display_modeset = {
- .get_connectors = kms_display_get_connectors,
- .get_modes = kms_display_get_modes,
- .create_scanout_surface = kms_display_create_scanout_surface,
- .program = kms_display_program
-};
-
static struct native_display *
kms_create_display(int fd, struct native_event_handler *event_handler,
void *user_data)
@@ -752,28 +205,7 @@ kms_create_display(int fd, struct native_event_handler *event_handler,
kdpy->base.get_param = kms_display_get_param;
kdpy->base.get_configs = kms_display_get_configs;
- /* resources are fixed, unlike crtc, connector, or encoder */
- kdpy->resources = drmModeGetResources(kdpy->fd);
- if (kdpy->resources) {
- kdpy->saved_crtcs =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
- if (!kdpy->saved_crtcs) {
- kms_display_destroy(&kdpy->base);
- return NULL;
- }
-
- kdpy->shown_surfaces =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
- if (!kdpy->shown_surfaces) {
- kms_display_destroy(&kdpy->base);
- return NULL;
- }
-
- kdpy->base.modeset = &kms_display_modeset;
- }
- else {
- _eglLog(_EGL_DEBUG, "Failed to get KMS resources. Disable modeset.");
- }
+ kms_display_init_modeset(&kdpy->base);
return &kdpy->base;
}
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h
index cd8e4ff0b2..3a9b1a6788 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.h
+++ b/src/gallium/state_trackers/egl/kms/native_kms.h
@@ -38,14 +38,10 @@
#include "common/native_helper.h"
struct kms_config;
+struct kms_crtc;
struct kms_connector;
struct kms_mode;
-
-struct kms_crtc {
- drmModeCrtcPtr crtc;
- uint32_t connectors[32];
- int num_connectors;
-};
+struct kms_surface;
struct kms_display {
struct native_display base;
@@ -53,9 +49,10 @@ struct kms_display {
struct native_event_handler *event_handler;
int fd;
- drmModeResPtr resources;
struct kms_config *config;
+ /* for modesetting */
+ drmModeResPtr resources;
struct kms_connector *connectors;
int num_connectors;
@@ -64,6 +61,16 @@ struct kms_display {
struct kms_crtc *saved_crtcs;
};
+struct kms_config {
+ struct native_config base;
+};
+
+struct kms_crtc {
+ drmModeCrtcPtr crtc;
+ uint32_t connectors[32];
+ int num_connectors;
+};
+
struct kms_framebuffer {
struct pipe_resource *texture;
boolean is_passive;
@@ -86,10 +93,6 @@ struct kms_surface {
struct kms_crtc current_crtc;
};
-struct kms_config {
- struct native_config base;
-};
-
struct kms_connector {
struct native_connector base;
@@ -110,18 +113,18 @@ kms_display(const struct native_display *ndpy)
return (struct kms_display *) ndpy;
}
-static INLINE struct kms_surface *
-kms_surface(const struct native_surface *nsurf)
-{
- return (struct kms_surface *) nsurf;
-}
-
static INLINE struct kms_config *
kms_config(const struct native_config *nconf)
{
return (struct kms_config *) nconf;
}
+static INLINE struct kms_surface *
+kms_surface(const struct native_surface *nsurf)
+{
+ return (struct kms_surface *) nsurf;
+}
+
static INLINE struct kms_connector *
kms_connector(const struct native_connector *nconn)
{
@@ -134,4 +137,10 @@ kms_mode(const struct native_mode *nmode)
return (struct kms_mode *) nmode;
}
+boolean
+kms_display_init_modeset(struct native_display *ndpy);
+
+void
+kms_display_fini_modeset(struct native_display *ndpy);
+
#endif /* _NATIVE_KMS_H_ */
--
cgit v1.2.3
From e7424d72405a1cb1fb5ac625b340043aaa9f88be Mon Sep 17 00:00:00 2001
From: Chia-I Wu
Date: Sun, 19 Sep 2010 16:54:39 +0800
Subject: st/egl: Rename kms backend to drm.
The main use of the backend is to support EGL_MESA_drm_display. drm
should be a better name.
---
configure.ac | 2 +-
docs/egl.html | 4 +-
src/egl/main/Makefile | 2 +-
src/egl/main/egldisplay.c | 2 +-
src/gallium/state_trackers/egl/Makefile | 20 +-
src/gallium/state_trackers/egl/common/egl_g3d.c | 4 +-
src/gallium/state_trackers/egl/common/native.h | 2 +-
src/gallium/state_trackers/egl/drm/modeset.c | 619 ++++++++++++++++++++++++
src/gallium/state_trackers/egl/drm/native_drm.c | 240 +++++++++
src/gallium/state_trackers/egl/drm/native_drm.h | 146 ++++++
src/gallium/state_trackers/egl/kms/modeset.c | 619 ------------------------
src/gallium/state_trackers/egl/kms/native_kms.c | 240 ---------
src/gallium/state_trackers/egl/kms/native_kms.h | 146 ------
13 files changed, 1023 insertions(+), 1023 deletions(-)
create mode 100644 src/gallium/state_trackers/egl/drm/modeset.c
create mode 100644 src/gallium/state_trackers/egl/drm/native_drm.c
create mode 100644 src/gallium/state_trackers/egl/drm/native_drm.h
delete mode 100644 src/gallium/state_trackers/egl/kms/modeset.c
delete mode 100644 src/gallium/state_trackers/egl/kms/native_kms.c
delete mode 100644 src/gallium/state_trackers/egl/kms/native_kms.h
(limited to 'src/gallium')
diff --git a/configure.ac b/configure.ac
index bf8feb6352..b19bf8fdf2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1363,7 +1363,7 @@ fi
AC_ARG_WITH([egl-platforms],
[AS_HELP_STRING([--with-egl-platforms@<:@=DIRS...@:>@],
[comma delimited native platforms libEGL supports, e.g.
- "x11,kms" @<:@default=auto@:>@])],
+ "x11,drm" @<:@default=auto@:>@])],
[with_egl_platforms="$withval"],
[with_egl_platforms=yes])
AC_ARG_WITH([egl-displays],
diff --git a/docs/egl.html b/docs/egl.html
index 4758267294..d38f2dd7b7 100644
--- a/docs/egl.html
+++ b/docs/egl.html
@@ -72,13 +72,13 @@ drivers will be installed to ${libdir}/egl
.
--with-egl-platforms
List the platforms (window systems) to support. Its argument is a comma
-seprated string such as --with-egl-platforms=x11,kms
. It decides
+seprated string such as --with-egl-platforms=x11,drm
. It decides
the platforms a driver may support. The first listed platform is also used by
the main library to decide the native platform: the platform the EGL native
types such as EGLNativeDisplayType
or
EGLNativeWindowType
defined for.
-The available platforms are x11
, kms
,
+
The available platforms are x11
, drm
,
fbdev
, and gdi
. The gdi
platform can
only be built with SCons.
diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile
index baee1a2f9d..19085a31f1 100644
--- a/src/egl/main/Makefile
+++ b/src/egl/main/Makefile
@@ -57,7 +57,7 @@ EGL_NATIVE_PLATFORM=_EGL_INVALID_PLATFORM
ifeq ($(firstword $(EGL_PLATFORMS)),x11)
EGL_NATIVE_PLATFORM=_EGL_PLATFORM_X11
endif
-ifeq ($(firstword $(EGL_PLATFORMS)),kms)
+ifeq ($(firstword $(EGL_PLATFORMS)),drm)
EGL_NATIVE_PLATFORM=_EGL_PLATFORM_DRM
endif
ifeq ($(firstword $(EGL_PLATFORMS)),fbdev)
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 31ff090484..cc0f03e01b 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -27,7 +27,7 @@ _eglGetNativePlatformFromEnv(void)
} egl_platforms[_EGL_NUM_PLATFORMS] = {
{ _EGL_PLATFORM_WINDOWS, "gdi" },
{ _EGL_PLATFORM_X11, "x11" },
- { _EGL_PLATFORM_DRM, "kms" },
+ { _EGL_PLATFORM_DRM, "drm" },
{ _EGL_PLATFORM_FBDEV, "fbdev" }
};
_EGLPlatformType plat = _EGL_INVALID_PLATFORM;
diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile
index 4199d7c6ba..8dbfc5b8e5 100644
--- a/src/gallium/state_trackers/egl/Makefile
+++ b/src/gallium/state_trackers/egl/Makefile
@@ -24,9 +24,9 @@ x11_SOURCES = $(wildcard x11/*.c) \
x11_OBJECTS = $(x11_SOURCES:.c=.o)
-kms_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm)
-kms_SOURCES = $(wildcard kms/*.c)
-kms_OBJECTS = $(kms_SOURCES:.c=.o)
+drm_INCLUDES = -I$(TOP)/src/gallium/winsys $(shell pkg-config --cflags-only-I libdrm)
+drm_SOURCES = $(wildcard drm/*.c)
+drm_OBJECTS = $(drm_SOURCES:.c=.o)
fbdev_INCLUDES = -I$(TOP)/src/gallium/winsys/sw
@@ -34,8 +34,8 @@ fbdev_SOURCES = $(wildcard fbdev/*.c)
fbdev_OBJECTS = $(fbdev_SOURCES:.c=.o)
-ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(kms_INCLUDES) $(fbdev_INCLUDES)
-ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(kms_SOURCES) $(fbdev_SOURCES)
+ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(drm_INCLUDES) $(fbdev_INCLUDES)
+ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(drm_SOURCES) $(fbdev_SOURCES)
EGL_OBJECTS = $(common_OBJECTS)
EGL_CPPFLAGS = $(common_INCLUDES)
@@ -45,9 +45,9 @@ ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
EGL_OBJECTS += $(x11_OBJECTS)
EGL_CPPFLAGS += -DHAVE_X11_BACKEND
endif
-ifneq ($(findstring kms, $(EGL_PLATFORMS)),)
-EGL_OBJECTS += $(kms_OBJECTS)
-EGL_CPPFLAGS += -DHAVE_KMS_BACKEND
+ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
+EGL_OBJECTS += $(drm_OBJECTS)
+EGL_CPPFLAGS += -DHAVE_DRM_BACKEND
endif
ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
EGL_OBJECTS += $(fbdev_OBJECTS)
@@ -87,8 +87,8 @@ $(common_OBJECTS): %.o: %.c
$(x11_OBJECTS): %.o: %.c
$(call egl-cc,x11)
-$(kms_OBJECTS): %.o: %.c
- $(call egl-cc,kms)
+$(drm_OBJECTS): %.o: %.c
+ $(call egl-cc,drm)
$(fbdev_OBJECTS): %.o: %.c
$(call egl-cc,fbdev)
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 33a838fb79..ce2b1f7bb9 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -65,8 +65,8 @@ egl_g3d_get_platform(_EGLDriver *drv, _EGLPlatformType plat)
break;
case _EGL_PLATFORM_DRM:
plat_name = "DRM";
-#ifdef HAVE_KMS_BACKEND
- nplat = native_get_kms_platform();
+#ifdef HAVE_DRM_BACKEND
+ nplat = native_get_drm_platform();
#endif
break;
case _EGL_PLATFORM_FBDEV:
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 9f34c517ef..3c3f57e267 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -227,7 +227,7 @@ const struct native_platform *
native_get_x11_platform(void);
const struct native_platform *
-native_get_kms_platform(void);
+native_get_drm_platform(void);
const struct native_platform *
native_get_fbdev_platform(void);
diff --git a/src/gallium/state_trackers/egl/drm/modeset.c b/src/gallium/state_trackers/egl/drm/modeset.c
new file mode 100644
index 0000000000..5d6a07e2fd
--- /dev/null
+++ b/src/gallium/state_trackers/egl/drm/modeset.c
@@ -0,0 +1,619 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ * Chia-I Wu
+ */
+
+#include "util/u_memory.h"
+#include "util/u_inlines.h"
+#include "egllog.h"
+
+#include "native_drm.h"
+
+static boolean
+kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+ unsigned int *seq_num, struct pipe_resource **textures,
+ int *width, int *height)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+
+ if (!resource_surface_add_resources(ksurf->rsurf, attachment_mask))
+ return FALSE;
+ if (textures)
+ resource_surface_get_resources(ksurf->rsurf, textures, attachment_mask);
+
+ if (seq_num)
+ *seq_num = ksurf->sequence_number;
+ if (width)
+ *width = ksurf->width;
+ if (height)
+ *height = ksurf->height;
+
+ return TRUE;
+}
+
+/**
+ * Add textures as DRM framebuffers.
+ */
+static boolean
+kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ struct kms_display *kdpy = ksurf->kdpy;
+ int num_framebuffers = (need_back) ? 2 : 1;
+ int i, err;
+
+ for (i = 0; i < num_framebuffers; i++) {
+ struct kms_framebuffer *fb;
+ enum native_attachment natt;
+ struct winsys_handle whandle;
+ uint block_bits;
+
+ if (i == 0) {
+ fb = &ksurf->front_fb;
+ natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+ }
+ else {
+ fb = &ksurf->back_fb;
+ natt = NATIVE_ATTACHMENT_BACK_LEFT;
+ }
+
+ if (!fb->texture) {
+ /* make sure the texture has been allocated */
+ resource_surface_add_resources(ksurf->rsurf, 1 << natt);
+ fb->texture =
+ resource_surface_get_single_resource(ksurf->rsurf, natt);
+ if (!fb->texture)
+ return FALSE;
+ }
+
+ /* already initialized */
+ if (fb->buffer_id)
+ continue;
+
+ /* TODO detect the real value */
+ fb->is_passive = TRUE;
+
+ memset(&whandle, 0, sizeof(whandle));
+ whandle.type = DRM_API_HANDLE_TYPE_KMS;
+
+ if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
+ fb->texture, &whandle))
+ return FALSE;
+
+ block_bits = util_format_get_blocksizebits(ksurf->color_format);
+ err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height,
+ block_bits, block_bits, whandle.stride, whandle.handle,
+ &fb->buffer_id);
+ if (err) {
+ fb->buffer_id = 0;
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static boolean
+kms_surface_flush_frontbuffer(struct native_surface *nsurf)
+{
+#ifdef DRM_MODE_FEATURE_DIRTYFB
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ struct kms_display *kdpy = ksurf->kdpy;
+
+ if (ksurf->front_fb.is_passive)
+ drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0);
+#endif
+
+ return TRUE;
+}
+
+static boolean
+kms_surface_swap_buffers(struct native_surface *nsurf)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ struct kms_crtc *kcrtc = &ksurf->current_crtc;
+ struct kms_display *kdpy = ksurf->kdpy;
+ struct kms_framebuffer tmp_fb;
+ int err;
+
+ if (!ksurf->back_fb.buffer_id) {
+ if (!kms_surface_init_framebuffers(&ksurf->base, TRUE))
+ return FALSE;
+ }
+
+ if (ksurf->is_shown && kcrtc->crtc) {
+ err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
+ ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
+ kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode);
+ if (err)
+ return FALSE;
+ }
+
+ /* swap the buffers */
+ tmp_fb = ksurf->front_fb;
+ ksurf->front_fb = ksurf->back_fb;
+ ksurf->back_fb = tmp_fb;
+
+ resource_surface_swap_buffers(ksurf->rsurf,
+ NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, FALSE);
+ /* the front/back textures are swapped */
+ ksurf->sequence_number++;
+ kdpy->event_handler->invalid_surface(&kdpy->base,
+ &ksurf->base, ksurf->sequence_number);
+
+ return TRUE;
+}
+
+static void
+kms_surface_wait(struct native_surface *nsurf)
+{
+ /* no-op */
+}
+
+static void
+kms_surface_destroy(struct native_surface *nsurf)
+{
+ struct kms_surface *ksurf = kms_surface(nsurf);
+
+ if (ksurf->current_crtc.crtc)
+ drmModeFreeCrtc(ksurf->current_crtc.crtc);
+
+ if (ksurf->front_fb.buffer_id)
+ drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
+ pipe_resource_reference(&ksurf->front_fb.texture, NULL);
+
+ if (ksurf->back_fb.buffer_id)
+ drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
+ pipe_resource_reference(&ksurf->back_fb.texture, NULL);
+
+ resource_surface_destroy(ksurf->rsurf);
+ FREE(ksurf);
+}
+
+static struct kms_surface *
+kms_display_create_surface(struct native_display *ndpy,
+ const struct native_config *nconf,
+ uint width, uint height)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_config *kconf = kms_config(nconf);
+ struct kms_surface *ksurf;
+
+ ksurf = CALLOC_STRUCT(kms_surface);
+ if (!ksurf)
+ return NULL;
+
+ ksurf->kdpy = kdpy;
+ ksurf->color_format = kconf->base.color_format;
+ ksurf->width = width;
+ ksurf->height = height;
+
+ ksurf->rsurf = resource_surface_create(kdpy->base.screen,
+ ksurf->color_format,
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_SAMPLER_VIEW |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT);
+ if (!ksurf->rsurf) {
+ FREE(ksurf);
+ return NULL;
+ }
+
+ resource_surface_set_size(ksurf->rsurf, ksurf->width, ksurf->height);
+
+ ksurf->base.destroy = kms_surface_destroy;
+ ksurf->base.swap_buffers = kms_surface_swap_buffers;
+ ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer;
+ ksurf->base.validate = kms_surface_validate;
+ ksurf->base.wait = kms_surface_wait;
+
+ return ksurf;
+}
+
+/**
+ * Choose a CRTC that supports all given connectors.
+ */
+static uint32_t
+kms_display_choose_crtc(struct native_display *ndpy,
+ uint32_t *connectors, int num_connectors)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ int idx;
+
+ for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) {
+ boolean found_crtc = TRUE;
+ int i, j;
+
+ for (i = 0; i < num_connectors; i++) {
+ drmModeConnectorPtr connector;
+ int encoder_idx = -1;
+
+ connector = drmModeGetConnector(kdpy->fd, connectors[i]);
+ if (!connector) {
+ found_crtc = FALSE;
+ break;
+ }
+
+ /* find an encoder the CRTC supports */
+ for (j = 0; j < connector->count_encoders; j++) {
+ drmModeEncoderPtr encoder =
+ drmModeGetEncoder(kdpy->fd, connector->encoders[j]);
+ if (encoder->possible_crtcs & (1 << idx)) {
+ encoder_idx = j;
+ break;
+ }
+ drmModeFreeEncoder(encoder);
+ }
+
+ drmModeFreeConnector(connector);
+ if (encoder_idx < 0) {
+ found_crtc = FALSE;
+ break;
+ }
+ }
+
+ if (found_crtc)
+ break;
+ }
+
+ if (idx >= kdpy->resources->count_crtcs) {
+ _eglLog(_EGL_WARNING,
+ "failed to find a CRTC that supports the given %d connectors",
+ num_connectors);
+ return 0;
+ }
+
+ return kdpy->resources->crtcs[idx];
+}
+
+/**
+ * Remember the original CRTC status and set the CRTC
+ */
+static boolean
+kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
+ uint32_t buffer_id, uint32_t x, uint32_t y,
+ uint32_t *connectors, int num_connectors,
+ drmModeModeInfoPtr mode)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx];
+ uint32_t crtc_id;
+ int err;
+
+ if (kcrtc->crtc) {
+ crtc_id = kcrtc->crtc->crtc_id;
+ }
+ else {
+ int count = 0, i;
+
+ /*
+ * Choose the CRTC once. It could be more dynamic, but let's keep it
+ * simple for now.
+ */
+ crtc_id = kms_display_choose_crtc(&kdpy->base,
+ connectors, num_connectors);
+
+ /* save the original CRTC status */
+ kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
+ if (!kcrtc->crtc)
+ return FALSE;
+
+ for (i = 0; i < kdpy->num_connectors; i++) {
+ struct kms_connector *kconn = &kdpy->connectors[i];
+ drmModeConnectorPtr connector = kconn->connector;
+ drmModeEncoderPtr encoder;
+
+ encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id);
+ if (encoder) {
+ if (encoder->crtc_id == crtc_id) {
+ kcrtc->connectors[count++] = connector->connector_id;
+ if (count >= Elements(kcrtc->connectors))
+ break;
+ }
+ drmModeFreeEncoder(encoder);
+ }
+ }
+
+ kcrtc->num_connectors = count;
+ }
+
+ err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y,
+ connectors, num_connectors, mode);
+ if (err) {
+ drmModeFreeCrtc(kcrtc->crtc);
+ kcrtc->crtc = NULL;
+ kcrtc->num_connectors = 0;
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static boolean
+kms_display_program(struct native_display *ndpy, int crtc_idx,
+ struct native_surface *nsurf, uint x, uint y,
+ const struct native_connector **nconns, int num_nconns,
+ const struct native_mode *nmode)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_surface *ksurf = kms_surface(nsurf);
+ const struct kms_mode *kmode = kms_mode(nmode);
+ uint32_t connector_ids[32];
+ uint32_t buffer_id;
+ drmModeModeInfo mode_tmp, *mode;
+ int i;
+
+ if (num_nconns > Elements(connector_ids)) {
+ _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns);
+ num_nconns = Elements(connector_ids);
+ }
+
+ if (ksurf) {
+ if (!kms_surface_init_framebuffers(&ksurf->base, FALSE))
+ return FALSE;
+
+ buffer_id = ksurf->front_fb.buffer_id;
+ /* the mode argument of drmModeSetCrtc is not constified */
+ mode_tmp = kmode->mode;
+ mode = &mode_tmp;
+ }
+ else {
+ /* disable the CRTC */
+ buffer_id = 0;
+ mode = NULL;
+ num_nconns = 0;
+ }
+
+ for (i = 0; i < num_nconns; i++) {
+ struct kms_connector *kconn = kms_connector(nconns[i]);
+ connector_ids[i] = kconn->connector->connector_id;
+ }
+
+ if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y,
+ connector_ids, num_nconns, mode)) {
+ _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
+
+ return FALSE;
+ }
+
+ if (kdpy->shown_surfaces[crtc_idx])
+ kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
+ kdpy->shown_surfaces[crtc_idx] = ksurf;
+
+ /* remember the settings for buffer swapping */
+ if (ksurf) {
+ uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
+ struct kms_crtc *kcrtc = &ksurf->current_crtc;
+
+ if (kcrtc->crtc)
+ drmModeFreeCrtc(kcrtc->crtc);
+ kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
+
+ assert(num_nconns < Elements(kcrtc->connectors));
+ memcpy(kcrtc->connectors, connector_ids,
+ sizeof(*connector_ids) * num_nconns);
+ kcrtc->num_connectors = num_nconns;
+
+ ksurf->is_shown = TRUE;
+ }
+
+ return TRUE;
+}
+
+static const struct native_mode **
+kms_display_get_modes(struct native_display *ndpy,
+ const struct native_connector *nconn,
+ int *num_modes)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ struct kms_connector *kconn = kms_connector(nconn);
+ const struct native_mode **nmodes_return;
+ int count, i;
+
+ /* delete old data */
+ if (kconn->connector) {
+ drmModeFreeConnector(kconn->connector);
+ FREE(kconn->kms_modes);
+
+ kconn->connector = NULL;
+ kconn->kms_modes = NULL;
+ kconn->num_modes = 0;
+ }
+
+ /* detect again */
+ kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id);
+ if (!kconn->connector)
+ return NULL;
+
+ count = kconn->connector->count_modes;
+ kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
+ if (!kconn->kms_modes) {
+ drmModeFreeConnector(kconn->connector);
+ kconn->connector = NULL;
+
+ return NULL;
+ }
+
+ for (i = 0; i < count; i++) {
+ struct kms_mode *kmode = &kconn->kms_modes[i];
+ drmModeModeInfoPtr mode = &kconn->connector->modes[i];
+
+ kmode->mode = *mode;
+
+ kmode->base.desc = kmode->mode.name;
+ kmode->base.width = kmode->mode.hdisplay;
+ kmode->base.height = kmode->mode.vdisplay;
+ kmode->base.refresh_rate = kmode->mode.vrefresh;
+ /* not all kernels have vrefresh = refresh_rate * 1000 */
+ if (kmode->base.refresh_rate > 1000)
+ kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
+ }
+
+ nmodes_return = MALLOC(count * sizeof(*nmodes_return));
+ if (nmodes_return) {
+ for (i = 0; i < count; i++)
+ nmodes_return[i] = &kconn->kms_modes[i].base;
+ if (num_modes)
+ *num_modes = count;
+ }
+
+ return nmodes_return;
+}
+
+static const struct native_connector **
+kms_display_get_connectors(struct native_display *ndpy, int *num_connectors,
+ int *num_crtc)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ const struct native_connector **connectors;
+ int i;
+
+ if (!kdpy->connectors) {
+ kdpy->connectors =
+ CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
+ if (!kdpy->connectors)
+ return NULL;
+
+ for (i = 0; i < kdpy->resources->count_connectors; i++) {
+ struct kms_connector *kconn = &kdpy->connectors[i];
+
+ kconn->connector_id = kdpy->resources->connectors[i];
+ /* kconn->connector is allocated when the modes are asked */
+ }
+
+ kdpy->num_connectors = kdpy->resources->count_connectors;
+ }
+
+ connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
+ if (connectors) {
+ for (i = 0; i < kdpy->num_connectors; i++)
+ connectors[i] = &kdpy->connectors[i].base;
+ if (num_connectors)
+ *num_connectors = kdpy->num_connectors;
+ }
+
+ if (num_crtc)
+ *num_crtc = kdpy->resources->count_crtcs;
+
+ return connectors;
+}
+
+static struct native_surface *
+kms_display_create_scanout_surface(struct native_display *ndpy,
+ const struct native_config *nconf,
+ uint width, uint height)
+{
+ struct kms_surface *ksurf;
+
+ ksurf = kms_display_create_surface(ndpy, nconf, width, height);
+ return &ksurf->base;
+}
+
+static struct native_display_modeset kms_display_modeset = {
+ .get_connectors = kms_display_get_connectors,
+ .get_modes = kms_display_get_modes,
+ .create_scanout_surface = kms_display_create_scanout_surface,
+ .program = kms_display_program
+};
+
+void
+kms_display_fini_modeset(struct native_display *ndpy)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ int i;
+
+ if (kdpy->connectors) {
+ for (i = 0; i < kdpy->num_connectors; i++) {
+ struct kms_connector *kconn = &kdpy->connectors[i];
+ if (kconn->connector) {
+ drmModeFreeConnector(kconn->connector);
+ FREE(kconn->kms_modes);
+ }
+ }
+ FREE(kdpy->connectors);
+ }
+
+ if (kdpy->shown_surfaces) {
+ FREE(kdpy->shown_surfaces);
+ kdpy->shown_surfaces = NULL;
+ }
+
+ if (kdpy->saved_crtcs) {
+ for (i = 0; i < kdpy->resources->count_crtcs; i++) {
+ struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i];
+
+ if (kcrtc->crtc) {
+ /* restore crtc */
+ drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
+ kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
+ kcrtc->connectors, kcrtc->num_connectors,
+ &kcrtc->crtc->mode);
+
+ drmModeFreeCrtc(kcrtc->crtc);
+ }
+ }
+ FREE(kdpy->saved_crtcs);
+ }
+
+ if (kdpy->resources) {
+ drmModeFreeResources(kdpy->resources);
+ kdpy->resources = NULL;
+ }
+
+ kdpy->base.modeset = NULL;
+}
+
+boolean
+kms_display_init_modeset(struct native_display *ndpy)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+
+ /* resources are fixed, unlike crtc, connector, or encoder */
+ kdpy->resources = drmModeGetResources(kdpy->fd);
+ if (!kdpy->resources) {
+ _eglLog(_EGL_DEBUG, "Failed to get KMS resources. Disable modeset.");
+ return FALSE;
+ }
+
+ kdpy->saved_crtcs =
+ CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
+ if (!kdpy->saved_crtcs) {
+ kms_display_fini_modeset(&kdpy->base);
+ return FALSE;
+ }
+
+ kdpy->shown_surfaces =
+ CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
+ if (!kdpy->shown_surfaces) {
+ kms_display_fini_modeset(&kdpy->base);
+ return FALSE;
+ }
+
+ kdpy->base.modeset = &kms_display_modeset;
+
+ return TRUE;
+}
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
new file mode 100644
index 0000000000..8ffdde66ba
--- /dev/null
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -0,0 +1,240 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.8
+ *
+ * Copyright (C) 2010 Chia-I Wu
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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
+#include
+#include
+
+#include "util/u_memory.h"
+#include "egllog.h"
+
+#include "native_drm.h"
+
+/* see get_drm_screen_name */
+#include
+#include "radeon/drm/radeon_drm.h"
+
+static boolean
+kms_display_is_format_supported(struct native_display *ndpy,
+ enum pipe_format fmt, boolean is_color)
+{
+ return ndpy->screen->is_format_supported(ndpy->screen,
+ fmt, PIPE_TEXTURE_2D, 0,
+ (is_color) ? PIPE_BIND_RENDER_TARGET :
+ PIPE_BIND_DEPTH_STENCIL, 0);
+}
+
+static const struct native_config **
+kms_display_get_configs(struct native_display *ndpy, int *num_configs)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ const struct native_config **configs;
+
+ /* first time */
+ if (!kdpy->config) {
+ struct native_config *nconf;
+ enum pipe_format format;
+
+ kdpy->config = CALLOC(1, sizeof(*kdpy->config));
+ if (!kdpy->config)
+ return NULL;
+
+ nconf = &kdpy->config->base;
+
+ nconf->buffer_mask =
+ (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
+ (1 << NATIVE_ATTACHMENT_BACK_LEFT);
+
+ format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) {
+ format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ if (!kms_display_is_format_supported(&kdpy->base, format, TRUE))
+ format = PIPE_FORMAT_NONE;
+ }
+ if (format == PIPE_FORMAT_NONE) {
+ FREE(kdpy->config);
+ kdpy->config = NULL;
+ return NULL;
+ }
+
+ nconf->color_format = format;
+
+ /* support KMS */
+ if (kdpy->resources)
+ nconf->scanout_bit = TRUE;
+ }
+
+ configs = MALLOC(sizeof(*configs));
+ if (configs) {
+ configs[0] = &kdpy->config->base;
+ if (num_configs)
+ *num_configs = 1;
+ }
+
+ return configs;
+}
+
+static int
+kms_display_get_param(struct native_display *ndpy,
+ enum native_param_type param)
+{
+ int val;
+
+ switch (param) {
+ default:
+ val = 0;
+ break;
+ }
+
+ return val;
+}
+
+static void
+kms_display_destroy(struct native_display *ndpy)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+
+ if (kdpy->config)
+ FREE(kdpy->config);
+
+ kms_display_fini_modeset(&kdpy->base);
+
+ if (kdpy->base.screen)
+ kdpy->base.screen->destroy(kdpy->base.screen);
+
+ if (kdpy->fd >= 0)
+ close(kdpy->fd);
+
+ FREE(kdpy);
+}
+
+static const char *
+get_drm_screen_name(int fd, drmVersionPtr version)
+{
+ const char *name = version->name;
+
+ if (name && !strcmp(name, "radeon")) {
+ int chip_id;
+ struct drm_radeon_info info;
+
+ memset(&info, 0, sizeof(info));
+ info.request = RADEON_INFO_DEVICE_ID;
+ info.value = pointer_to_intptr(&chip_id);
+ if (drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)) != 0)
+ return NULL;
+
+ name = is_r3xx(chip_id) ? "r300" : "r600";
+ }
+
+ return name;
+}
+
+/**
+ * Initialize KMS and pipe screen.
+ */
+static boolean
+kms_display_init_screen(struct native_display *ndpy)
+{
+ struct kms_display *kdpy = kms_display(ndpy);
+ drmVersionPtr version;
+ const char *name;
+
+ version = drmGetVersion(kdpy->fd);
+ if (!version) {
+ _eglLog(_EGL_WARNING, "invalid fd %d", kdpy->fd);
+ return FALSE;
+ }
+
+ name = get_drm_screen_name(kdpy->fd, version);
+ if (name) {
+ kdpy->base.screen =
+ kdpy->event_handler->new_drm_screen(&kdpy->base, name, kdpy->fd);
+ }
+ drmFreeVersion(version);
+
+ if (!kdpy->base.screen) {
+ _eglLog(_EGL_WARNING, "failed to create DRM screen");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static struct native_display *
+kms_create_display(int fd, struct native_event_handler *event_handler,
+ void *user_data)
+{
+ struct kms_display *kdpy;
+
+ kdpy = CALLOC_STRUCT(kms_display);
+ if (!kdpy)
+ return NULL;
+
+ kdpy->fd = fd;
+ kdpy->event_handler = event_handler;
+ kdpy->base.user_data = user_data;
+
+ if (!kms_display_init_screen(&kdpy->base)) {
+ kms_display_destroy(&kdpy->base);
+ return NULL;
+ }
+
+ kdpy->base.destroy = kms_display_destroy;
+ kdpy->base.get_param = kms_display_get_param;
+ kdpy->base.get_configs = kms_display_get_configs;
+
+ kms_display_init_modeset(&kdpy->base);
+
+ return &kdpy->base;
+}
+
+static struct native_display *
+native_create_display(void *dpy, struct native_event_handler *event_handler,
+ void *user_data)
+{
+ int fd;
+
+ if (dpy) {
+ fd = dup((int) pointer_to_intptr(dpy));
+ }
+ else {
+ fd = open("/dev/dri/card0", O_RDWR);
+ }
+ if (fd < 0)
+ return NULL;
+
+ return kms_create_display(fd, event_handler, user_data);
+}
+
+static const struct native_platform drm_platform = {
+ "DRM", /* name */
+ native_create_display
+};
+
+const struct native_platform *
+native_get_drm_platform(void)
+{
+ return &drm_platform;
+}
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.h b/src/gallium/state_trackers/egl/drm/native_drm.h
new file mode 100644
index 0000000000..3a9b1a6788
--- /dev/null
+++ b/src/gallium/state_trackers/egl/drm/native_drm.h
@@ -0,0 +1,146 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.8
+ *
+ * Copyright (C) 2010 Chia-I Wu
+ *
+ * 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+#ifndef _NATIVE_KMS_H_
+#define _NATIVE_KMS_H_
+
+#include
+#include
+
+#include "pipe/p_compiler.h"
+#include "util/u_format.h"
+#include "pipe/p_state.h"
+#include "state_tracker/drm_driver.h"
+
+#include "common/native.h"
+#include "common/native_helper.h"
+
+struct kms_config;
+struct kms_crtc;
+struct kms_connector;
+struct kms_mode;
+struct kms_surface;
+
+struct kms_display {
+ struct native_display base;
+
+ struct native_event_handler *event_handler;
+
+ int fd;
+ struct kms_config *config;
+
+ /* for modesetting */
+ drmModeResPtr resources;
+ struct kms_connector *connectors;
+ int num_connectors;
+
+ struct kms_surface **shown_surfaces;
+ /* save the original settings of the CRTCs */
+ struct kms_crtc *saved_crtcs;
+};
+
+struct kms_config {
+ struct native_config base;
+};
+
+struct kms_crtc {
+ drmModeCrtcPtr crtc;
+ uint32_t connectors[32];
+ int num_connectors;
+};
+
+struct kms_framebuffer {
+ struct pipe_resource *texture;
+ boolean is_passive;
+
+ uint32_t buffer_id;
+};
+
+struct kms_surface {
+ struct native_surface base;
+ struct kms_display *kdpy;
+
+ struct resource_surface *rsurf;
+ enum pipe_format color_format;
+ int width, height;
+
+ unsigned int sequence_number;
+ struct kms_framebuffer front_fb, back_fb;
+
+ boolean is_shown;
+ struct kms_crtc current_crtc;
+};
+
+struct kms_connector {
+ struct native_connector base;
+
+ uint32_t connector_id;
+ drmModeConnectorPtr connector;
+ struct kms_mode *kms_modes;
+ int num_modes;
+};
+
+struct kms_mode {
+ struct native_mode base;
+ drmModeModeInfo mode;
+};
+
+static INLINE struct kms_display *
+kms_display(const struct native_display *ndpy)
+{
+ return (struct kms_display *) ndpy;
+}
+
+static INLINE struct kms_config *
+kms_config(const struct native_config *nconf)
+{
+ return (struct kms_config *) nconf;
+}
+
+static INLINE struct kms_surface *
+kms_surface(const struct native_surface *nsurf)
+{
+ return (struct kms_surface *) nsurf;
+}
+
+static INLINE struct kms_connector *
+kms_connector(const struct native_connector *nconn)
+{
+ return (struct kms_connector *) nconn;
+}
+
+static INLINE struct kms_mode *
+kms_mode(const struct native_mode *nmode)
+{
+ return (struct kms_mode *) nmode;
+}
+
+boolean
+kms_display_init_modeset(struct native_display *ndpy);
+
+void
+kms_display_fini_modeset(struct native_display *ndpy);
+
+#endif /* _NATIVE_KMS_H_ */
diff --git a/src/gallium/state_trackers/egl/kms/modeset.c b/src/gallium/state_trackers/egl/kms/modeset.c
deleted file mode 100644
index 9473a0e5f4..0000000000
--- a/src/gallium/state_trackers/egl/kms/modeset.c
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * 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
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Chia-I Wu
- */
-
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "egllog.h"
-
-#include "native_kms.h"
-
-static boolean
-kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
- unsigned int *seq_num, struct pipe_resource **textures,
- int *width, int *height)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
-
- if (!resource_surface_add_resources(ksurf->rsurf, attachment_mask))
- return FALSE;
- if (textures)
- resource_surface_get_resources(ksurf->rsurf, textures, attachment_mask);
-
- if (seq_num)
- *seq_num = ksurf->sequence_number;
- if (width)
- *width = ksurf->width;
- if (height)
- *height = ksurf->height;
-
- return TRUE;
-}
-
-/**
- * Add textures as DRM framebuffers.
- */
-static boolean
-kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
- int num_framebuffers = (need_back) ? 2 : 1;
- int i, err;
-
- for (i = 0; i < num_framebuffers; i++) {
- struct kms_framebuffer *fb;
- enum native_attachment natt;
- struct winsys_handle whandle;
- uint block_bits;
-
- if (i == 0) {
- fb = &ksurf->front_fb;
- natt = NATIVE_ATTACHMENT_FRONT_LEFT;
- }
- else {
- fb = &ksurf->back_fb;
- natt = NATIVE_ATTACHMENT_BACK_LEFT;
- }
-
- if (!fb->texture) {
- /* make sure the texture has been allocated */
- resource_surface_add_resources(ksurf->rsurf, 1 << natt);
- fb->texture =
- resource_surface_get_single_resource(ksurf->rsurf, natt);
- if (!fb->texture)
- return FALSE;
- }
-
- /* already initialized */
- if (fb->buffer_id)
- continue;
-
- /* TODO detect the real value */
- fb->is_passive = TRUE;
-
- memset(&whandle, 0, sizeof(whandle));
- whandle.type = DRM_API_HANDLE_TYPE_KMS;
-
- if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
- fb->texture, &whandle))
- return FALSE;
-
- block_bits = util_format_get_blocksizebits(ksurf->color_format);
- err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height,
- block_bits, block_bits, whandle.stride, whandle.handle,
- &fb->buffer_id);
- if (err) {
- fb->buffer_id = 0;
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static boolean
-kms_surface_flush_frontbuffer(struct native_surface *nsurf)
-{
-#ifdef DRM_MODE_FEATURE_DIRTYFB
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
-
- if (ksurf->front_fb.is_passive)
- drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0);
-#endif
-
- return TRUE;
-}
-
-static boolean
-kms_surface_swap_buffers(struct native_surface *nsurf)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
- struct kms_display *kdpy = ksurf->kdpy;
- struct kms_framebuffer tmp_fb;
- int err;
-
- if (!ksurf->back_fb.buffer_id) {
- if (!kms_surface_init_framebuffers(&ksurf->base, TRUE))
- return FALSE;
- }
-
- if (ksurf->is_shown && kcrtc->crtc) {
- err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode);
- if (err)
- return FALSE;
- }
-
- /* swap the buffers */
- tmp_fb = ksurf->front_fb;
- ksurf->front_fb = ksurf->back_fb;
- ksurf->back_fb = tmp_fb;
-
- resource_surface_swap_buffers(ksurf->rsurf,
- NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, FALSE);
- /* the front/back textures are swapped */
- ksurf->sequence_number++;
- kdpy->event_handler->invalid_surface(&kdpy->base,
- &ksurf->base, ksurf->sequence_number);
-
- return TRUE;
-}
-
-static void
-kms_surface_wait(struct native_surface *nsurf)
-{
- /* no-op */
-}
-
-static void
-kms_surface_destroy(struct native_surface *nsurf)
-{
- struct kms_surface *ksurf = kms_surface(nsurf);
-
- if (ksurf->current_crtc.crtc)
- drmModeFreeCrtc(ksurf->current_crtc.crtc);
-
- if (ksurf->front_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
- pipe_resource_reference(&ksurf->front_fb.texture, NULL);
-
- if (ksurf->back_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
- pipe_resource_reference(&ksurf->back_fb.texture, NULL);
-
- resource_surface_destroy(ksurf->rsurf);
- FREE(ksurf);
-}
-
-static struct kms_surface *
-kms_display_create_surface(struct native_display *ndpy,
- const struct native_config *nconf,
- uint width, uint height)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_config *kconf = kms_config(nconf);
- struct kms_surface *ksurf;
-
- ksurf = CALLOC_STRUCT(kms_surface);
- if (!ksurf)
- return NULL;
-
- ksurf->kdpy = kdpy;
- ksurf->color_format = kconf->base.color_format;
- ksurf->width = width;
- ksurf->height = height;
-
- ksurf->rsurf = resource_surface_create(kdpy->base.screen,
- ksurf->color_format,
- PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_SAMPLER_VIEW |
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SCANOUT);
- if (!ksurf->rsurf) {
- FREE(ksurf);
- return NULL;
- }
-
- resource_surface_set_size(ksurf->rsurf, ksurf->width, ksurf->height);
-
- ksurf->base.destroy = kms_surface_destroy;
- ksurf->base.swap_buffers = kms_surface_swap_buffers;
- ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer;
- ksurf->base.validate = kms_surface_validate;
- ksurf->base.wait = kms_surface_wait;
-
- return ksurf;
-}
-
-/**
- * Choose a CRTC that supports all given connectors.
- */
-static uint32_t
-kms_display_choose_crtc(struct native_display *ndpy,
- uint32_t *connectors, int num_connectors)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- int idx;
-
- for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) {
- boolean found_crtc = TRUE;
- int i, j;
-
- for (i = 0; i < num_connectors; i++) {
- drmModeConnectorPtr connector;
- int encoder_idx = -1;
-
- connector = drmModeGetConnector(kdpy->fd, connectors[i]);
- if (!connector) {
- found_crtc = FALSE;
- break;
- }
-
- /* find an encoder the CRTC supports */
- for (j = 0; j < connector->count_encoders; j++) {
- drmModeEncoderPtr encoder =
- drmModeGetEncoder(kdpy->fd, connector->encoders[j]);
- if (encoder->possible_crtcs & (1 << idx)) {
- encoder_idx = j;
- break;
- }
- drmModeFreeEncoder(encoder);
- }
-
- drmModeFreeConnector(connector);
- if (encoder_idx < 0) {
- found_crtc = FALSE;
- break;
- }
- }
-
- if (found_crtc)
- break;
- }
-
- if (idx >= kdpy->resources->count_crtcs) {
- _eglLog(_EGL_WARNING,
- "failed to find a CRTC that supports the given %d connectors",
- num_connectors);
- return 0;
- }
-
- return kdpy->resources->crtcs[idx];
-}
-
-/**
- * Remember the original CRTC status and set the CRTC
- */
-static boolean
-kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
- uint32_t buffer_id, uint32_t x, uint32_t y,
- uint32_t *connectors, int num_connectors,
- drmModeModeInfoPtr mode)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx];
- uint32_t crtc_id;
- int err;
-
- if (kcrtc->crtc) {
- crtc_id = kcrtc->crtc->crtc_id;
- }
- else {
- int count = 0, i;
-
- /*
- * Choose the CRTC once. It could be more dynamic, but let's keep it
- * simple for now.
- */
- crtc_id = kms_display_choose_crtc(&kdpy->base,
- connectors, num_connectors);
-
- /* save the original CRTC status */
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
- if (!kcrtc->crtc)
- return FALSE;
-
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- drmModeConnectorPtr connector = kconn->connector;
- drmModeEncoderPtr encoder;
-
- encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id);
- if (encoder) {
- if (encoder->crtc_id == crtc_id) {
- kcrtc->connectors[count++] = connector->connector_id;
- if (count >= Elements(kcrtc->connectors))
- break;
- }
- drmModeFreeEncoder(encoder);
- }
- }
-
- kcrtc->num_connectors = count;
- }
-
- err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y,
- connectors, num_connectors, mode);
- if (err) {
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = NULL;
- kcrtc->num_connectors = 0;
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-static boolean
-kms_display_program(struct native_display *ndpy, int crtc_idx,
- struct native_surface *nsurf, uint x, uint y,
- const struct native_connector **nconns, int num_nconns,
- const struct native_mode *nmode)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_surface *ksurf = kms_surface(nsurf);
- const struct kms_mode *kmode = kms_mode(nmode);
- uint32_t connector_ids[32];
- uint32_t buffer_id;
- drmModeModeInfo mode_tmp, *mode;
- int i;
-
- if (num_nconns > Elements(connector_ids)) {
- _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns);
- num_nconns = Elements(connector_ids);
- }
-
- if (ksurf) {
- if (!kms_surface_init_framebuffers(&ksurf->base, FALSE))
- return FALSE;
-
- buffer_id = ksurf->front_fb.buffer_id;
- /* the mode argument of drmModeSetCrtc is not constified */
- mode_tmp = kmode->mode;
- mode = &mode_tmp;
- }
- else {
- /* disable the CRTC */
- buffer_id = 0;
- mode = NULL;
- num_nconns = 0;
- }
-
- for (i = 0; i < num_nconns; i++) {
- struct kms_connector *kconn = kms_connector(nconns[i]);
- connector_ids[i] = kconn->connector->connector_id;
- }
-
- if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y,
- connector_ids, num_nconns, mode)) {
- _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
-
- return FALSE;
- }
-
- if (kdpy->shown_surfaces[crtc_idx])
- kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
- kdpy->shown_surfaces[crtc_idx] = ksurf;
-
- /* remember the settings for buffer swapping */
- if (ksurf) {
- uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
-
- if (kcrtc->crtc)
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
-
- assert(num_nconns < Elements(kcrtc->connectors));
- memcpy(kcrtc->connectors, connector_ids,
- sizeof(*connector_ids) * num_nconns);
- kcrtc->num_connectors = num_nconns;
-
- ksurf->is_shown = TRUE;
- }
-
- return TRUE;
-}
-
-static const struct native_mode **
-kms_display_get_modes(struct native_display *ndpy,
- const struct native_connector *nconn,
- int *num_modes)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_connector *kconn = kms_connector(nconn);
- const struct native_mode **nmodes_return;
- int count, i;
-
- /* delete old data */
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
-
- kconn->connector = NULL;
- kconn->kms_modes = NULL;
- kconn->num_modes = 0;
- }
-
- /* detect again */
- kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id);
- if (!kconn->connector)
- return NULL;
-
- count = kconn->connector->count_modes;
- kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
- if (!kconn->kms_modes) {
- drmModeFreeConnector(kconn->connector);
- kconn->connector = NULL;
-
- return NULL;
- }
-
- for (i = 0; i < count; i++) {
- struct kms_mode *kmode = &kconn->kms_modes[i];
- drmModeModeInfoPtr mode = &kconn->connector->modes[i];
-
- kmode->mode = *mode;
-
- kmode->base.desc = kmode->mode.name;
- kmode->base.width = kmode->mode.hdisplay;
- kmode->base.height = kmode->mode.vdisplay;
- kmode->base.refresh_rate = kmode->mode.vrefresh;
- /* not all kernels have vrefresh = refresh_rate * 1000 */
- if (kmode->base.refresh_rate > 1000)
- kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
- }
-
- nmodes_return = MALLOC(count * sizeof(*nmodes_return));
- if (nmodes_return) {
- for (i = 0; i < count; i++)
- nmodes_return[i] = &kconn->kms_modes[i].base;
- if (num_modes)
- *num_modes = count;
- }
-
- return nmodes_return;
-}
-
-static const struct native_connector **
-kms_display_get_connectors(struct native_display *ndpy, int *num_connectors,
- int *num_crtc)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- const struct native_connector **connectors;
- int i;
-
- if (!kdpy->connectors) {
- kdpy->connectors =
- CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
- if (!kdpy->connectors)
- return NULL;
-
- for (i = 0; i < kdpy->resources->count_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
-
- kconn->connector_id = kdpy->resources->connectors[i];
- /* kconn->connector is allocated when the modes are asked */
- }
-
- kdpy->num_connectors = kdpy->resources->count_connectors;
- }
-
- connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
- if (connectors) {
- for (i = 0; i < kdpy->num_connectors; i++)
- connectors[i] = &kdpy->connectors[i].base;
- if (num_connectors)
- *num_connectors = kdpy->num_connectors;
- }
-
- if (num_crtc)
- *num_crtc = kdpy->resources->count_crtcs;
-
- return connectors;
-}
-
-static struct native_surface *
-kms_display_create_scanout_surface(struct native_display *ndpy,
- const struct native_config *nconf,
- uint width, uint height)
-{
- struct kms_surface *ksurf;
-
- ksurf = kms_display_create_surface(ndpy, nconf, width, height);
- return &ksurf->base;
-}
-
-static struct native_display_modeset kms_display_modeset = {
- .get_connectors = kms_display_get_connectors,
- .get_modes = kms_display_get_modes,
- .create_scanout_surface = kms_display_create_scanout_surface,
- .program = kms_display_program
-};
-
-void
-kms_display_fini_modeset(struct native_display *ndpy)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- int i;
-
- if (kdpy->connectors) {
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
- }
- }
- FREE(kdpy->connectors);
- }
-
- if (kdpy->shown_surfaces) {
- FREE(kdpy->shown_surfaces);
- kdpy->shown_surfaces = NULL;
- }
-
- if (kdpy->saved_crtcs) {
- for (i = 0; i < kdpy->resources->count_crtcs; i++) {
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i];
-
- if (kcrtc->crtc) {
- /* restore crtc */
- drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors,
- &kcrtc->crtc->mode);
-
- drmModeFreeCrtc(kcrtc->crtc);
- }
- }
- FREE(kdpy->saved_crtcs);
- }
-
- if (kdpy->resources) {
- drmModeFreeResources(kdpy->resources);
- kdpy->resources = NULL;
- }
-
- kdpy->base.modeset = NULL;
-}
-
-boolean
-kms_display_init_modeset(struct native_display *ndpy)
-{
- struct kms_display *kdpy = kms_display(ndpy);
-
- /* resources are fixed, unlike crtc, connector, or encoder */
- kdpy->resources = drmModeGetResources(kdpy->fd);
- if (!kdpy->resources) {
- _eglLog(_EGL_DEBUG, "Failed to get KMS resources. Disable modeset.");
- return FALSE;
- }
-
- kdpy->saved_crtcs =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
- if (!kdpy->saved_crtcs) {
- kms_display_fini_modeset(&kdpy->base);
- return FALSE;
- }
-
- kdpy->shown_surfaces =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
- if (!kdpy->shown_surfaces) {
- kms_display_fini_modeset(&kdpy->base);
- return FALSE;
- }
-
- kdpy->base.modeset = &kms_display_modeset;
-
- return TRUE;
-}
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c
deleted file mode 100644
index 94880c3696..0000000000
--- a/src/gallium/state_trackers/egl/kms/native_kms.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.8
- *
- * Copyright (C) 2010 Chia-I Wu
- *
- * 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
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS 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
-#include
-#include
-
-#include "util/u_memory.h"
-#include "egllog.h"
-
-#include "native_kms.h"
-
-/* see get_drm_screen_name */
-#include
-#include "radeon/drm/radeon_drm.h"
-
-static boolean
-kms_display_is_format_supported(struct native_display *ndpy,
- enum pipe_format fmt, boolean is_color)
-{
- return ndpy->screen->is_format_supported(ndpy->screen,
- fmt, PIPE_TEXTURE_2D, 0,
- (is_color) ? PIPE_BIND_RENDER_TARGET :
- PIPE_BIND_DEPTH_STENCIL, 0);
-}
-
-static const struct native_config **
-kms_display_get_configs(struct native_display *ndpy, int *num_configs)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- const struct native_config **configs;
-
- /* first time */
- if (!kdpy->config) {
- struct native_config *nconf;
- enum pipe_format format;
-
- kdpy->config = CALLOC(1, sizeof(*kdpy->config));
- if (!kdpy->config)
- return NULL;
-
- nconf = &kdpy->config->base;
-
- nconf->buffer_mask =
- (1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
- (1 << NATIVE_ATTACHMENT_BACK_LEFT);
-
- format = PIPE_FORMAT_B8G8R8A8_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) {
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, TRUE))
- format = PIPE_FORMAT_NONE;
- }
- if (format == PIPE_FORMAT_NONE) {
- FREE(kdpy->config);
- kdpy->config = NULL;
- return NULL;
- }
-
- nconf->color_format = format;
-
- /* support KMS */
- if (kdpy->resources)
- nconf->scanout_bit = TRUE;
- }
-
- configs = MALLOC(sizeof(*configs));
- if (configs) {
- configs[0] = &kdpy->config->base;
- if (num_configs)
- *num_configs = 1;
- }
-
- return configs;
-}
-
-static int
-kms_display_get_param(struct native_display *ndpy,
- enum native_param_type param)
-{
- int val;
-
- switch (param) {
- default:
- val = 0;
- break;
- }
-
- return val;
-}
-
-static void
-kms_display_destroy(struct native_display *ndpy)
-{
- struct kms_display *kdpy = kms_display(ndpy);
-
- if (kdpy->config)
- FREE(kdpy->config);
-
- kms_display_fini_modeset(&kdpy->base);
-
- if (kdpy->base.screen)
- kdpy->base.screen->destroy(kdpy->base.screen);
-
- if (kdpy->fd >= 0)
- close(kdpy->fd);
-
- FREE(kdpy);
-}
-
-static const char *
-get_drm_screen_name(int fd, drmVersionPtr version)
-{
- const char *name = version->name;
-
- if (name && !strcmp(name, "radeon")) {
- int chip_id;
- struct drm_radeon_info info;
-
- memset(&info, 0, sizeof(info));
- info.request = RADEON_INFO_DEVICE_ID;
- info.value = pointer_to_intptr(&chip_id);
- if (drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)) != 0)
- return NULL;
-
- name = is_r3xx(chip_id) ? "r300" : "r600";
- }
-
- return name;
-}
-
-/**
- * Initialize KMS and pipe screen.
- */
-static boolean
-kms_display_init_screen(struct native_display *ndpy)
-{
- struct kms_display *kdpy = kms_display(ndpy);
- drmVersionPtr version;
- const char *name;
-
- version = drmGetVersion(kdpy->fd);
- if (!version) {
- _eglLog(_EGL_WARNING, "invalid fd %d", kdpy->fd);
- return FALSE;
- }
-
- name = get_drm_screen_name(kdpy->fd, version);
- if (name) {
- kdpy->base.screen =
- kdpy->event_handler->new_drm_screen(&kdpy->base, name, kdpy->fd);
- }
- drmFreeVersion(version);
-
- if (!kdpy->base.screen) {
- _eglLog(_EGL_WARNING, "failed to create DRM screen");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static struct native_display *
-kms_create_display(int fd, struct native_event_handler *event_handler,
- void *user_data)
-{
- struct kms_display *kdpy;
-
- kdpy = CALLOC_STRUCT(kms_display);
- if (!kdpy)
- return NULL;
-
- kdpy->fd = fd;
- kdpy->event_handler = event_handler;
- kdpy->base.user_data = user_data;
-
- if (!kms_display_init_screen(&kdpy->base)) {
- kms_display_destroy(&kdpy->base);
- return NULL;
- }
-
- kdpy->base.destroy = kms_display_destroy;
- kdpy->base.get_param = kms_display_get_param;
- kdpy->base.get_configs = kms_display_get_configs;
-
- kms_display_init_modeset(&kdpy->base);
-
- return &kdpy->base;
-}
-
-static struct native_display *
-native_create_display(void *dpy, struct native_event_handler *event_handler,
- void *user_data)
-{
- int fd;
-
- if (dpy) {
- fd = dup((int) pointer_to_intptr(dpy));
- }
- else {
- fd = open("/dev/dri/card0", O_RDWR);
- }
- if (fd < 0)
- return NULL;
-
- return kms_create_display(fd, event_handler, user_data);
-}
-
-static const struct native_platform kms_platform = {
- "KMS", /* name */
- native_create_display
-};
-
-const struct native_platform *
-native_get_kms_platform(void)
-{
- return &kms_platform;
-}
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h
deleted file mode 100644
index 3a9b1a6788..0000000000
--- a/src/gallium/state_trackers/egl/kms/native_kms.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.8
- *
- * Copyright (C) 2010 Chia-I Wu
- *
- * 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
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- */
-
-#ifndef _NATIVE_KMS_H_
-#define _NATIVE_KMS_H_
-
-#include
-#include
-
-#include "pipe/p_compiler.h"
-#include "util/u_format.h"
-#include "pipe/p_state.h"
-#include "state_tracker/drm_driver.h"
-
-#include "common/native.h"
-#include "common/native_helper.h"
-
-struct kms_config;
-struct kms_crtc;
-struct kms_connector;
-struct kms_mode;
-struct kms_surface;
-
-struct kms_display {
- struct native_display base;
-
- struct native_event_handler *event_handler;
-
- int fd;
- struct kms_config *config;
-
- /* for modesetting */
- drmModeResPtr resources;
- struct kms_connector *connectors;
- int num_connectors;
-
- struct kms_surface **shown_surfaces;
- /* save the original settings of the CRTCs */
- struct kms_crtc *saved_crtcs;
-};
-
-struct kms_config {
- struct native_config base;
-};
-
-struct kms_crtc {
- drmModeCrtcPtr crtc;
- uint32_t connectors[32];
- int num_connectors;
-};
-
-struct kms_framebuffer {
- struct pipe_resource *texture;
- boolean is_passive;
-
- uint32_t buffer_id;
-};
-
-struct kms_surface {
- struct native_surface base;
- struct kms_display *kdpy;
-
- struct resource_surface *rsurf;
- enum pipe_format color_format;
- int width, height;
-
- unsigned int sequence_number;
- struct kms_framebuffer front_fb, back_fb;
-
- boolean is_shown;
- struct kms_crtc current_crtc;
-};
-
-struct kms_connector {
- struct native_connector base;
-
- uint32_t connector_id;
- drmModeConnectorPtr connector;
- struct kms_mode *kms_modes;
- int num_modes;
-};
-
-struct kms_mode {
- struct native_mode base;
- drmModeModeInfo mode;
-};
-
-static INLINE struct kms_display *
-kms_display(const struct native_display *ndpy)
-{
- return (struct kms_display *) ndpy;
-}
-
-static INLINE struct kms_config *
-kms_config(const struct native_config *nconf)
-{
- return (struct kms_config *) nconf;
-}
-
-static INLINE struct kms_surface *
-kms_surface(const struct native_surface *nsurf)
-{
- return (struct kms_surface *) nsurf;
-}
-
-static INLINE struct kms_connector *
-kms_connector(const struct native_connector *nconn)
-{
- return (struct kms_connector *) nconn;
-}
-
-static INLINE struct kms_mode *
-kms_mode(const struct native_mode *nmode)
-{
- return (struct kms_mode *) nmode;
-}
-
-boolean
-kms_display_init_modeset(struct native_display *ndpy);
-
-void
-kms_display_fini_modeset(struct native_display *ndpy);
-
-#endif /* _NATIVE_KMS_H_ */
--
cgit v1.2.3
From e4513e7fb96c6336d8c7fcdadfaddb6b335a736e Mon Sep 17 00:00:00 2001
From: Chia-I Wu
Date: Sun, 19 Sep 2010 17:11:07 +0800
Subject: st/egl: s/kms/drm/ on the drm backend.
s/kms/drm/, s/kdpy/drmdpy/, and so forth.
---
src/gallium/state_trackers/egl/drm/modeset.c | 432 ++++++++++++------------
src/gallium/state_trackers/egl/drm/native_drm.c | 94 +++---
src/gallium/state_trackers/egl/drm/native_drm.h | 80 ++---
3 files changed, 303 insertions(+), 303 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/state_trackers/egl/drm/modeset.c b/src/gallium/state_trackers/egl/drm/modeset.c
index 5d6a07e2fd..06a6077053 100644
--- a/src/gallium/state_trackers/egl/drm/modeset.c
+++ b/src/gallium/state_trackers/egl/drm/modeset.c
@@ -33,23 +33,23 @@
#include "native_drm.h"
static boolean
-kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
+drm_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
+ struct drm_surface *drmsurf = drm_surface(nsurf);
- if (!resource_surface_add_resources(ksurf->rsurf, attachment_mask))
+ if (!resource_surface_add_resources(drmsurf->rsurf, attachment_mask))
return FALSE;
if (textures)
- resource_surface_get_resources(ksurf->rsurf, textures, attachment_mask);
+ resource_surface_get_resources(drmsurf->rsurf, textures, attachment_mask);
if (seq_num)
- *seq_num = ksurf->sequence_number;
+ *seq_num = drmsurf->sequence_number;
if (width)
- *width = ksurf->width;
+ *width = drmsurf->width;
if (height)
- *height = ksurf->height;
+ *height = drmsurf->height;
return TRUE;
}
@@ -58,33 +58,33 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
* Add textures as DRM framebuffers.
*/
static boolean
-kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
+drm_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ struct drm_display *drmdpy = drmsurf->drmdpy;
int num_framebuffers = (need_back) ? 2 : 1;
int i, err;
for (i = 0; i < num_framebuffers; i++) {
- struct kms_framebuffer *fb;
+ struct drm_framebuffer *fb;
enum native_attachment natt;
struct winsys_handle whandle;
uint block_bits;
if (i == 0) {
- fb = &ksurf->front_fb;
+ fb = &drmsurf->front_fb;
natt = NATIVE_ATTACHMENT_FRONT_LEFT;
}
else {
- fb = &ksurf->back_fb;
+ fb = &drmsurf->back_fb;
natt = NATIVE_ATTACHMENT_BACK_LEFT;
}
if (!fb->texture) {
/* make sure the texture has been allocated */
- resource_surface_add_resources(ksurf->rsurf, 1 << natt);
+ resource_surface_add_resources(drmsurf->rsurf, 1 << natt);
fb->texture =
- resource_surface_get_single_resource(ksurf->rsurf, natt);
+ resource_surface_get_single_resource(drmsurf->rsurf, natt);
if (!fb->texture)
return FALSE;
}
@@ -99,12 +99,12 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
+ if (!drmdpy->base.screen->resource_get_handle(drmdpy->base.screen,
fb->texture, &whandle))
return FALSE;
- block_bits = util_format_get_blocksizebits(ksurf->color_format);
- err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height,
+ block_bits = util_format_get_blocksizebits(drmsurf->color_format);
+ err = drmModeAddFB(drmdpy->fd, drmsurf->width, drmsurf->height,
block_bits, block_bits, whandle.stride, whandle.handle,
&fb->buffer_id);
if (err) {
@@ -117,133 +117,133 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
}
static boolean
-kms_surface_flush_frontbuffer(struct native_surface *nsurf)
+drm_surface_flush_frontbuffer(struct native_surface *nsurf)
{
#ifdef DRM_MODE_FEATURE_DIRTYFB
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_display *kdpy = ksurf->kdpy;
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ struct drm_display *drmdpy = drmsurf->drmdpy;
- if (ksurf->front_fb.is_passive)
- drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0);
+ if (drmsurf->front_fb.is_passive)
+ drmModeDirtyFB(drmdpy->fd, drmsurf->front_fb.buffer_id, NULL, 0);
#endif
return TRUE;
}
static boolean
-kms_surface_swap_buffers(struct native_surface *nsurf)
+drm_surface_swap_buffers(struct native_surface *nsurf)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
- struct kms_display *kdpy = ksurf->kdpy;
- struct kms_framebuffer tmp_fb;
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ struct drm_crtc *drmcrtc = &drmsurf->current_crtc;
+ struct drm_display *drmdpy = drmsurf->drmdpy;
+ struct drm_framebuffer tmp_fb;
int err;
- if (!ksurf->back_fb.buffer_id) {
- if (!kms_surface_init_framebuffers(&ksurf->base, TRUE))
+ if (!drmsurf->back_fb.buffer_id) {
+ if (!drm_surface_init_framebuffers(&drmsurf->base, TRUE))
return FALSE;
}
- if (ksurf->is_shown && kcrtc->crtc) {
- err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode);
+ if (drmsurf->is_shown && drmcrtc->crtc) {
+ err = drmModeSetCrtc(drmdpy->fd, drmcrtc->crtc->crtc_id,
+ drmsurf->back_fb.buffer_id, drmcrtc->crtc->x, drmcrtc->crtc->y,
+ drmcrtc->connectors, drmcrtc->num_connectors, &drmcrtc->crtc->mode);
if (err)
return FALSE;
}
/* swap the buffers */
- tmp_fb = ksurf->front_fb;
- ksurf->front_fb = ksurf->back_fb;
- ksurf->back_fb = tmp_fb;
+ tmp_fb = drmsurf->front_fb;
+ drmsurf->front_fb = drmsurf->back_fb;
+ drmsurf->back_fb = tmp_fb;
- resource_surface_swap_buffers(ksurf->rsurf,
+ resource_surface_swap_buffers(drmsurf->rsurf,
NATIVE_ATTACHMENT_FRONT_LEFT, NATIVE_ATTACHMENT_BACK_LEFT, FALSE);
/* the front/back textures are swapped */
- ksurf->sequence_number++;
- kdpy->event_handler->invalid_surface(&kdpy->base,
- &ksurf->base, ksurf->sequence_number);
+ drmsurf->sequence_number++;
+ drmdpy->event_handler->invalid_surface(&drmdpy->base,
+ &drmsurf->base, drmsurf->sequence_number);
return TRUE;
}
static void
-kms_surface_wait(struct native_surface *nsurf)
+drm_surface_wait(struct native_surface *nsurf)
{
/* no-op */
}
static void
-kms_surface_destroy(struct native_surface *nsurf)
+drm_surface_destroy(struct native_surface *nsurf)
{
- struct kms_surface *ksurf = kms_surface(nsurf);
+ struct drm_surface *drmsurf = drm_surface(nsurf);
- if (ksurf->current_crtc.crtc)
- drmModeFreeCrtc(ksurf->current_crtc.crtc);
+ if (drmsurf->current_crtc.crtc)
+ drmModeFreeCrtc(drmsurf->current_crtc.crtc);
- if (ksurf->front_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
- pipe_resource_reference(&ksurf->front_fb.texture, NULL);
+ if (drmsurf->front_fb.buffer_id)
+ drmModeRmFB(drmsurf->drmdpy->fd, drmsurf->front_fb.buffer_id);
+ pipe_resource_reference(&drmsurf->front_fb.texture, NULL);
- if (ksurf->back_fb.buffer_id)
- drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
- pipe_resource_reference(&ksurf->back_fb.texture, NULL);
+ if (drmsurf->back_fb.buffer_id)
+ drmModeRmFB(drmsurf->drmdpy->fd, drmsurf->back_fb.buffer_id);
+ pipe_resource_reference(&drmsurf->back_fb.texture, NULL);
- resource_surface_destroy(ksurf->rsurf);
- FREE(ksurf);
+ resource_surface_destroy(drmsurf->rsurf);
+ FREE(drmsurf);
}
-static struct kms_surface *
-kms_display_create_surface(struct native_display *ndpy,
+static struct drm_surface *
+drm_display_create_surface(struct native_display *ndpy,
const struct native_config *nconf,
uint width, uint height)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_config *kconf = kms_config(nconf);
- struct kms_surface *ksurf;
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_config *drmconf = drm_config(nconf);
+ struct drm_surface *drmsurf;
- ksurf = CALLOC_STRUCT(kms_surface);
- if (!ksurf)
+ drmsurf = CALLOC_STRUCT(drm_surface);
+ if (!drmsurf)
return NULL;
- ksurf->kdpy = kdpy;
- ksurf->color_format = kconf->base.color_format;
- ksurf->width = width;
- ksurf->height = height;
+ drmsurf->drmdpy = drmdpy;
+ drmsurf->color_format = drmconf->base.color_format;
+ drmsurf->width = width;
+ drmsurf->height = height;
- ksurf->rsurf = resource_surface_create(kdpy->base.screen,
- ksurf->color_format,
+ drmsurf->rsurf = resource_surface_create(drmdpy->base.screen,
+ drmsurf->color_format,
PIPE_BIND_RENDER_TARGET |
PIPE_BIND_SAMPLER_VIEW |
PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SCANOUT);
- if (!ksurf->rsurf) {
- FREE(ksurf);
+ if (!drmsurf->rsurf) {
+ FREE(drmsurf);
return NULL;
}
- resource_surface_set_size(ksurf->rsurf, ksurf->width, ksurf->height);
+ resource_surface_set_size(drmsurf->rsurf, drmsurf->width, drmsurf->height);
- ksurf->base.destroy = kms_surface_destroy;
- ksurf->base.swap_buffers = kms_surface_swap_buffers;
- ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer;
- ksurf->base.validate = kms_surface_validate;
- ksurf->base.wait = kms_surface_wait;
+ drmsurf->base.destroy = drm_surface_destroy;
+ drmsurf->base.swap_buffers = drm_surface_swap_buffers;
+ drmsurf->base.flush_frontbuffer = drm_surface_flush_frontbuffer;
+ drmsurf->base.validate = drm_surface_validate;
+ drmsurf->base.wait = drm_surface_wait;
- return ksurf;
+ return drmsurf;
}
/**
* Choose a CRTC that supports all given connectors.
*/
static uint32_t
-kms_display_choose_crtc(struct native_display *ndpy,
+drm_display_choose_crtc(struct native_display *ndpy,
uint32_t *connectors, int num_connectors)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
int idx;
- for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) {
+ for (idx = 0; idx < drmdpy->resources->count_crtcs; idx++) {
boolean found_crtc = TRUE;
int i, j;
@@ -251,7 +251,7 @@ kms_display_choose_crtc(struct native_display *ndpy,
drmModeConnectorPtr connector;
int encoder_idx = -1;
- connector = drmModeGetConnector(kdpy->fd, connectors[i]);
+ connector = drmModeGetConnector(drmdpy->fd, connectors[i]);
if (!connector) {
found_crtc = FALSE;
break;
@@ -260,7 +260,7 @@ kms_display_choose_crtc(struct native_display *ndpy,
/* find an encoder the CRTC supports */
for (j = 0; j < connector->count_encoders; j++) {
drmModeEncoderPtr encoder =
- drmModeGetEncoder(kdpy->fd, connector->encoders[j]);
+ drmModeGetEncoder(drmdpy->fd, connector->encoders[j]);
if (encoder->possible_crtcs & (1 << idx)) {
encoder_idx = j;
break;
@@ -279,32 +279,32 @@ kms_display_choose_crtc(struct native_display *ndpy,
break;
}
- if (idx >= kdpy->resources->count_crtcs) {
+ if (idx >= drmdpy->resources->count_crtcs) {
_eglLog(_EGL_WARNING,
"failed to find a CRTC that supports the given %d connectors",
num_connectors);
return 0;
}
- return kdpy->resources->crtcs[idx];
+ return drmdpy->resources->crtcs[idx];
}
/**
* Remember the original CRTC status and set the CRTC
*/
static boolean
-kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
+drm_display_set_crtc(struct native_display *ndpy, int crtc_idx,
uint32_t buffer_id, uint32_t x, uint32_t y,
uint32_t *connectors, int num_connectors,
drmModeModeInfoPtr mode)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx];
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_crtc *drmcrtc = &drmdpy->saved_crtcs[crtc_idx];
uint32_t crtc_id;
int err;
- if (kcrtc->crtc) {
- crtc_id = kcrtc->crtc->crtc_id;
+ if (drmcrtc->crtc) {
+ crtc_id = drmcrtc->crtc->crtc_id;
}
else {
int count = 0, i;
@@ -313,39 +313,39 @@ kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
* Choose the CRTC once. It could be more dynamic, but let's keep it
* simple for now.
*/
- crtc_id = kms_display_choose_crtc(&kdpy->base,
+ crtc_id = drm_display_choose_crtc(&drmdpy->base,
connectors, num_connectors);
/* save the original CRTC status */
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
- if (!kcrtc->crtc)
+ drmcrtc->crtc = drmModeGetCrtc(drmdpy->fd, crtc_id);
+ if (!drmcrtc->crtc)
return FALSE;
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- drmModeConnectorPtr connector = kconn->connector;
+ for (i = 0; i < drmdpy->num_connectors; i++) {
+ struct drm_connector *drmconn = &drmdpy->connectors[i];
+ drmModeConnectorPtr connector = drmconn->connector;
drmModeEncoderPtr encoder;
- encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id);
+ encoder = drmModeGetEncoder(drmdpy->fd, connector->encoder_id);
if (encoder) {
if (encoder->crtc_id == crtc_id) {
- kcrtc->connectors[count++] = connector->connector_id;
- if (count >= Elements(kcrtc->connectors))
+ drmcrtc->connectors[count++] = connector->connector_id;
+ if (count >= Elements(drmcrtc->connectors))
break;
}
drmModeFreeEncoder(encoder);
}
}
- kcrtc->num_connectors = count;
+ drmcrtc->num_connectors = count;
}
- err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y,
+ err = drmModeSetCrtc(drmdpy->fd, crtc_id, buffer_id, x, y,
connectors, num_connectors, mode);
if (err) {
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = NULL;
- kcrtc->num_connectors = 0;
+ drmModeFreeCrtc(drmcrtc->crtc);
+ drmcrtc->crtc = NULL;
+ drmcrtc->num_connectors = 0;
return FALSE;
}
@@ -354,14 +354,14 @@ kms_display_set_crtc(struct native_display *ndpy, int crtc_idx,
}
static boolean
-kms_display_program(struct native_display *ndpy, int crtc_idx,
+drm_display_program(struct native_display *ndpy, int crtc_idx,
struct native_surface *nsurf, uint x, uint y,
const struct native_connector **nconns, int num_nconns,
const struct native_mode *nmode)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_surface *ksurf = kms_surface(nsurf);
- const struct kms_mode *kmode = kms_mode(nmode);
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_surface *drmsurf = drm_surface(nsurf);
+ const struct drm_mode *drmmode = drm_mode(nmode);
uint32_t connector_ids[32];
uint32_t buffer_id;
drmModeModeInfo mode_tmp, *mode;
@@ -372,13 +372,13 @@ kms_display_program(struct native_display *ndpy, int crtc_idx,
num_nconns = Elements(connector_ids);
}
- if (ksurf) {
- if (!kms_surface_init_framebuffers(&ksurf->base, FALSE))
+ if (drmsurf) {
+ if (!drm_surface_init_framebuffers(&drmsurf->base, FALSE))
return FALSE;
- buffer_id = ksurf->front_fb.buffer_id;
+ buffer_id = drmsurf->front_fb.buffer_id;
/* the mode argument of drmModeSetCrtc is not constified */
- mode_tmp = kmode->mode;
+ mode_tmp = drmmode->mode;
mode = &mode_tmp;
}
else {
@@ -389,94 +389,94 @@ kms_display_program(struct native_display *ndpy, int crtc_idx,
}
for (i = 0; i < num_nconns; i++) {
- struct kms_connector *kconn = kms_connector(nconns[i]);
- connector_ids[i] = kconn->connector->connector_id;
+ struct drm_connector *drmconn = drm_connector(nconns[i]);
+ connector_ids[i] = drmconn->connector->connector_id;
}
- if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y,
+ if (!drm_display_set_crtc(&drmdpy->base, crtc_idx, buffer_id, x, y,
connector_ids, num_nconns, mode)) {
_eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
return FALSE;
}
- if (kdpy->shown_surfaces[crtc_idx])
- kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
- kdpy->shown_surfaces[crtc_idx] = ksurf;
+ if (drmdpy->shown_surfaces[crtc_idx])
+ drmdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
+ drmdpy->shown_surfaces[crtc_idx] = drmsurf;
/* remember the settings for buffer swapping */
- if (ksurf) {
- uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
- struct kms_crtc *kcrtc = &ksurf->current_crtc;
+ if (drmsurf) {
+ uint32_t crtc_id = drmdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
+ struct drm_crtc *drmcrtc = &drmsurf->current_crtc;
- if (kcrtc->crtc)
- drmModeFreeCrtc(kcrtc->crtc);
- kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id);
+ if (drmcrtc->crtc)
+ drmModeFreeCrtc(drmcrtc->crtc);
+ drmcrtc->crtc = drmModeGetCrtc(drmdpy->fd, crtc_id);
- assert(num_nconns < Elements(kcrtc->connectors));
- memcpy(kcrtc->connectors, connector_ids,
+ assert(num_nconns < Elements(drmcrtc->connectors));
+ memcpy(drmcrtc->connectors, connector_ids,
sizeof(*connector_ids) * num_nconns);
- kcrtc->num_connectors = num_nconns;
+ drmcrtc->num_connectors = num_nconns;
- ksurf->is_shown = TRUE;
+ drmsurf->is_shown = TRUE;
}
return TRUE;
}
static const struct native_mode **
-kms_display_get_modes(struct native_display *ndpy,
+drm_display_get_modes(struct native_display *ndpy,
const struct native_connector *nconn,
int *num_modes)
{
- struct kms_display *kdpy = kms_display(ndpy);
- struct kms_connector *kconn = kms_connector(nconn);
+ struct drm_display *drmdpy = drm_display(ndpy);
+ struct drm_connector *drmconn = drm_connector(nconn);
const struct native_mode **nmodes_return;
int count, i;
/* delete old data */
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
+ if (drmconn->connector) {
+ drmModeFreeConnector(drmconn->connector);
+ FREE(drmconn->drm_modes);
- kconn->connector = NULL;
- kconn->kms_modes = NULL;
- kconn->num_modes = 0;
+ drmconn->connector = NULL;
+ drmconn->drm_modes = NULL;
+ drmconn->num_modes = 0;
}
/* detect again */
- kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id);
- if (!kconn->connector)
+ drmconn->connector = drmModeGetConnector(drmdpy->fd, drmconn->connector_id);
+ if (!drmconn->connector)
return NULL;
- count = kconn->connector->count_modes;
- kconn->kms_modes = CALLOC(count, sizeof(*kconn->kms_modes));
- if (!kconn->kms_modes) {
- drmModeFreeConnector(kconn->connector);
- kconn->connector = NULL;
+ count = drmconn->connector->count_modes;
+ drmconn->drm_modes = CALLOC(count, sizeof(*drmconn->drm_modes));
+ if (!drmconn->drm_modes) {
+ drmModeFreeConnector(drmconn->connector);
+ drmconn->connector = NULL;
return NULL;
}
for (i = 0; i < count; i++) {
- struct kms_mode *kmode = &kconn->kms_modes[i];
- drmModeModeInfoPtr mode = &kconn->connector->modes[i];
+ struct drm_mode *drmmode = &drmconn->drm_modes[i];
+ drmModeModeInfoPtr mode = &drmconn->connector->modes[i];
- kmode->mode = *mode;
+ drmmode->mode = *mode;
- kmode->base.desc = kmode->mode.name;
- kmode->base.width = kmode->mode.hdisplay;
- kmode->base.height = kmode->mode.vdisplay;
- kmode->base.refresh_rate = kmode->mode.vrefresh;
+ drmmode->base.desc = drmmode->mode.name;
+ drmmode->base.width = drmmode->mode.hdisplay;
+ drmmode->base.height = drmmode->mode.vdisplay;
+ drmmode->base.refresh_rate = drmmode->mode.vrefresh;
/* not all kernels have vrefresh = refresh_rate * 1000 */
- if (kmode->base.refresh_rate > 1000)
- kmode->base.refresh_rate = (kmode->base.refresh_rate + 500) / 1000;
+ if (drmmode->base.refresh_rate > 1000)
+ drmmode->base.refresh_rate = (drmmode->base.refresh_rate + 500) / 1000;
}
nmodes_return = MALLOC(count * sizeof(*nmodes_return));
if (nmodes_return) {
for (i = 0; i < count; i++)
- nmodes_return[i] = &kconn->kms_modes[i].base;
+ nmodes_return[i] = &drmconn->drm_modes[i].base;
if (num_modes)
*num_modes = count;
}
@@ -485,135 +485,135 @@ kms_display_get_modes(struct native_display *ndpy,
}
static const struct native_connector **
-kms_display_get_connectors(struct native_display *ndpy, int *num_connectors,
+drm_display_get_connectors(struct native_display *ndpy, int *num_connectors,
int *num_crtc)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
const struct native_connector **connectors;
int i;
- if (!kdpy->connectors) {
- kdpy->connectors =
- CALLOC(kdpy->resources->count_connectors, sizeof(*kdpy->connectors));
- if (!kdpy->connectors)
+ if (!drmdpy->connectors) {
+ drmdpy->connectors =
+ CALLOC(drmdpy->resources->count_connectors, sizeof(*drmdpy->connectors));
+ if (!drmdpy->connectors)
return NULL;
- for (i = 0; i < kdpy->resources->count_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
+ for (i = 0; i < drmdpy->resources->count_connectors; i++) {
+ struct drm_connector *drmconn = &drmdpy->connectors[i];
- kconn->connector_id = kdpy->resources->connectors[i];
- /* kconn->connector is allocated when the modes are asked */
+ drmconn->connector_id = drmdpy->resources->connectors[i];
+ /* drmconn->connector is allocated when the modes are asked */
}
- kdpy->num_connectors = kdpy->resources->count_connectors;
+ drmdpy->num_connectors = drmdpy->resources->count_connectors;
}
- connectors = MALLOC(kdpy->num_connectors * sizeof(*connectors));
+ connectors = MALLOC(drmdpy->num_connectors * sizeof(*connectors));
if (connectors) {
- for (i = 0; i < kdpy->num_connectors; i++)
- connectors[i] = &kdpy->connectors[i].base;
+ for (i = 0; i < drmdpy->num_connectors; i++)
+ connectors[i] = &drmdpy->connectors[i].base;
if (num_connectors)
- *num_connectors = kdpy->num_connectors;
+ *num_connectors = drmdpy->num_connectors;
}
if (num_crtc)
- *num_crtc = kdpy->resources->count_crtcs;
+ *num_crtc = drmdpy->resources->count_crtcs;
return connectors;
}
static struct native_surface *
-kms_display_create_scanout_surface(struct native_display *ndpy,
+drm_display_create_scanout_surface(struct native_display *ndpy,
const struct native_config *nconf,
uint width, uint height)
{
- struct kms_surface *ksurf;
+ struct drm_surface *drmsurf;
- ksurf = kms_display_create_surface(ndpy, nconf, width, height);
- return &ksurf->base;
+ drmsurf = drm_display_create_surface(ndpy, nconf, width, height);
+ return &drmsurf->base;
}
-static struct native_display_modeset kms_display_modeset = {
- .get_connectors = kms_display_get_connectors,
- .get_modes = kms_display_get_modes,
- .create_scanout_surface = kms_display_create_scanout_surface,
- .program = kms_display_program
+static struct native_display_modeset drm_display_modeset = {
+ .get_connectors = drm_display_get_connectors,
+ .get_modes = drm_display_get_modes,
+ .create_scanout_surface = drm_display_create_scanout_surface,
+ .program = drm_display_program
};
void
-kms_display_fini_modeset(struct native_display *ndpy)
+drm_display_fini_modeset(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
int i;
- if (kdpy->connectors) {
- for (i = 0; i < kdpy->num_connectors; i++) {
- struct kms_connector *kconn = &kdpy->connectors[i];
- if (kconn->connector) {
- drmModeFreeConnector(kconn->connector);
- FREE(kconn->kms_modes);
+ if (drmdpy->connectors) {
+ for (i = 0; i < drmdpy->num_connectors; i++) {
+ struct drm_connector *drmconn = &drmdpy->connectors[i];
+ if (drmconn->connector) {
+ drmModeFreeConnector(drmconn->connector);
+ FREE(drmconn->drm_modes);
}
}
- FREE(kdpy->connectors);
+ FREE(drmdpy->connectors);
}
- if (kdpy->shown_surfaces) {
- FREE(kdpy->shown_surfaces);
- kdpy->shown_surfaces = NULL;
+ if (drmdpy->shown_surfaces) {
+ FREE(drmdpy->shown_surfaces);
+ drmdpy->shown_surfaces = NULL;
}
- if (kdpy->saved_crtcs) {
- for (i = 0; i < kdpy->resources->count_crtcs; i++) {
- struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i];
+ if (drmdpy->saved_crtcs) {
+ for (i = 0; i < drmdpy->resources->count_crtcs; i++) {
+ struct drm_crtc *drmcrtc = &drmdpy->saved_crtcs[i];
- if (kcrtc->crtc) {
+ if (drmcrtc->crtc) {
/* restore crtc */
- drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id,
- kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y,
- kcrtc->connectors, kcrtc->num_connectors,
- &kcrtc->crtc->mode);
+ drmModeSetCrtc(drmdpy->fd, drmcrtc->crtc->crtc_id,
+ drmcrtc->crtc->buffer_id, drmcrtc->crtc->x, drmcrtc->crtc->y,
+ drmcrtc->connectors, drmcrtc->num_connectors,
+ &drmcrtc->crtc->mode);
- drmModeFreeCrtc(kcrtc->crtc);
+ drmModeFreeCrtc(drmcrtc->crtc);
}
}
- FREE(kdpy->saved_crtcs);
+ FREE(drmdpy->saved_crtcs);
}
- if (kdpy->resources) {
- drmModeFreeResources(kdpy->resources);
- kdpy->resources = NULL;
+ if (drmdpy->resources) {
+ drmModeFreeResources(drmdpy->resources);
+ drmdpy->resources = NULL;
}
- kdpy->base.modeset = NULL;
+ drmdpy->base.modeset = NULL;
}
boolean
-kms_display_init_modeset(struct native_display *ndpy)
+drm_display_init_modeset(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
/* resources are fixed, unlike crtc, connector, or encoder */
- kdpy->resources = drmModeGetResources(kdpy->fd);
- if (!kdpy->resources) {
+ drmdpy->resources = drmModeGetResources(drmdpy->fd);
+ if (!drmdpy->resources) {
_eglLog(_EGL_DEBUG, "Failed to get KMS resources. Disable modeset.");
return FALSE;
}
- kdpy->saved_crtcs =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs));
- if (!kdpy->saved_crtcs) {
- kms_display_fini_modeset(&kdpy->base);
+ drmdpy->saved_crtcs =
+ CALLOC(drmdpy->resources->count_crtcs, sizeof(*drmdpy->saved_crtcs));
+ if (!drmdpy->saved_crtcs) {
+ drm_display_fini_modeset(&drmdpy->base);
return FALSE;
}
- kdpy->shown_surfaces =
- CALLOC(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces));
- if (!kdpy->shown_surfaces) {
- kms_display_fini_modeset(&kdpy->base);
+ drmdpy->shown_surfaces =
+ CALLOC(drmdpy->resources->count_crtcs, sizeof(*drmdpy->shown_surfaces));
+ if (!drmdpy->shown_surfaces) {
+ drm_display_fini_modeset(&drmdpy->base);
return FALSE;
}
- kdpy->base.modeset = &kms_display_modeset;
+ drmdpy->base.modeset = &drm_display_modeset;
return TRUE;
}
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index 8ffdde66ba..f6dc558437 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -37,7 +37,7 @@
#include "radeon/drm/radeon_drm.h"
static boolean
-kms_display_is_format_supported(struct native_display *ndpy,
+drm_display_is_format_supported(struct native_display *ndpy,
enum pipe_format fmt, boolean is_color)
{
return ndpy->screen->is_format_supported(ndpy->screen,
@@ -47,48 +47,48 @@ kms_display_is_format_supported(struct native_display *ndpy,
}
static const struct native_config **
-kms_display_get_configs(struct native_display *ndpy, int *num_configs)
+drm_display_get_configs(struct native_display *ndpy, int *num_configs)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
const struct native_config **configs;
/* first time */
- if (!kdpy->config) {
+ if (!drmdpy->config) {
struct native_config *nconf;
enum pipe_format format;
- kdpy->config = CALLOC(1, sizeof(*kdpy->config));
- if (!kdpy->config)
+ drmdpy->config = CALLOC(1, sizeof(*drmdpy->config));
+ if (!drmdpy->config)
return NULL;
- nconf = &kdpy->config->base;
+ nconf = &drmdpy->config->base;
nconf->buffer_mask =
(1 << NATIVE_ATTACHMENT_FRONT_LEFT) |
(1 << NATIVE_ATTACHMENT_BACK_LEFT);
format = PIPE_FORMAT_B8G8R8A8_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) {
+ if (!drm_display_is_format_supported(&drmdpy->base, format, TRUE)) {
format = PIPE_FORMAT_A8R8G8B8_UNORM;
- if (!kms_display_is_format_supported(&kdpy->base, format, TRUE))
+ if (!drm_display_is_format_supported(&drmdpy->base, format, TRUE))
format = PIPE_FORMAT_NONE;
}
if (format == PIPE_FORMAT_NONE) {
- FREE(kdpy->config);
- kdpy->config = NULL;
+ FREE(drmdpy->config);
+ drmdpy->config = NULL;
return NULL;
}
nconf->color_format = format;
/* support KMS */
- if (kdpy->resources)
+ if (drmdpy->resources)
nconf->scanout_bit = TRUE;
}
configs = MALLOC(sizeof(*configs));
if (configs) {
- configs[0] = &kdpy->config->base;
+ configs[0] = &drmdpy->config->base;
if (num_configs)
*num_configs = 1;
}
@@ -97,7 +97,7 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)
}
static int
-kms_display_get_param(struct native_display *ndpy,
+drm_display_get_param(struct native_display *ndpy,
enum native_param_type param)
{
int val;
@@ -112,22 +112,22 @@ kms_display_get_param(struct native_display *ndpy,
}
static void
-kms_display_destroy(struct native_display *ndpy)
+drm_display_destroy(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
- if (kdpy->config)
- FREE(kdpy->config);
+ if (drmdpy->config)
+ FREE(drmdpy->config);
- kms_display_fini_modeset(&kdpy->base);
+ drm_display_fini_modeset(&drmdpy->base);
- if (kdpy->base.screen)
- kdpy->base.screen->destroy(kdpy->base.screen);
+ if (drmdpy->base.screen)
+ drmdpy->base.screen->destroy(drmdpy->base.screen);
- if (kdpy->fd >= 0)
- close(kdpy->fd);
+ if (drmdpy->fd >= 0)
+ close(drmdpy->fd);
- FREE(kdpy);
+ FREE(drmdpy);
}
static const char *
@@ -155,26 +155,26 @@ get_drm_screen_name(int fd, drmVersionPtr version)
* Initialize KMS and pipe screen.
*/
static boolean
-kms_display_init_screen(struct native_display *ndpy)
+drm_display_init_screen(struct native_display *ndpy)
{
- struct kms_display *kdpy = kms_display(ndpy);
+ struct drm_display *drmdpy = drm_display(ndpy);
drmVersionPtr version;
const char *name;
- version = drmGetVersion(kdpy->fd);
+ version = drmGetVersion(drmdpy->fd);
if (!version) {
- _eglLog(_EGL_WARNING, "invalid fd %d", kdpy->fd);
+ _eglLog(_EGL_WARNING, "invalid fd %d", drmdpy->fd);
return FALSE;
}
- name = get_drm_screen_name(kdpy->fd, version);
+ name = get_drm_screen_name(drmdpy->fd, version);
if (name) {
- kdpy->base.screen =
- kdpy->event_handler->new_drm_screen(&kdpy->base, name, kdpy->fd);
+ drmdpy->base.screen =
+ drmdpy->event_handler->new_drm_screen(&drmdpy->base, name, drmdpy->fd);
}
drmFreeVersion(version);
- if (!kdpy->base.screen) {
+ if (!drmdpy->base.screen) {
_eglLog(_EGL_WARNING, "failed to create DRM screen");
return FALSE;
}
@@ -183,31 +183,31 @@ kms_display_init_screen(struct native_display *ndpy)
}
static struct native_display *
-kms_create_display(int fd, struct native_event_handler *event_handler,
+drm_create_display(int fd, struct native_event_handler *event_handler,
void *user_data)
{
- struct kms_display *kdpy;
+ struct drm_display *drmdpy;
- kdpy = CALLOC_STRUCT(kms_display);
- if (!kdpy)
+ drmdpy = CALLOC_STRUCT(drm_display);
+ if (!drmdpy)
return NULL;
- kdpy->fd = fd;
- kdpy->event_handler = event_handler;
- kdpy->base.user_data = user_data;
+ drmdpy->fd = fd;
+ drmdpy->event_handler = event_handler;
+ drmdpy->base.user_data = user_data;
- if (!kms_display_init_screen(&kdpy->base)) {
- kms_display_destroy(&kdpy->base);
+ if (!drm_display_init_screen(&drmdpy->base)) {
+ drm_display_destroy(&drmdpy->base);
return NULL;
}
- kdpy->base.destroy = kms_display_destroy;
- kdpy->base.get_param = kms_display_get_param;
- kdpy->base.get_configs = kms_display_get_configs;
+ drmdpy->base.destroy = drm_display_destroy;
+ drmdpy->base.get_param = drm_display_get_param;
+ drmdpy->base.get_configs = drm_display_get_configs;
- kms_display_init_modeset(&kdpy->base);
+ drm_display_init_modeset(&drmdpy->base);
- return &kdpy->base;
+ return &drmdpy->base;
}
static struct native_display *
@@ -225,7 +225,7 @@ native_create_display(void *dpy, struct native_event_handler *event_handler,
if (fd < 0)
return NULL;
- return kms_create_display(fd, event_handler, user_data);
+ return drm_create_display(fd, event_handler, user_data);
}
static const struct native_platform drm_platform = {
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.h b/src/gallium/state_trackers/egl/drm/native_drm.h
index 3a9b1a6788..03c4fe01dc 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.h
+++ b/src/gallium/state_trackers/egl/drm/native_drm.h
@@ -23,8 +23,8 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef _NATIVE_KMS_H_
-#define _NATIVE_KMS_H_
+#ifndef _NATIVE_DRM_H_
+#define _NATIVE_DRM_H_
#include
#include
@@ -37,110 +37,110 @@
#include "common/native.h"
#include "common/native_helper.h"
-struct kms_config;
-struct kms_crtc;
-struct kms_connector;
-struct kms_mode;
-struct kms_surface;
+struct drm_config;
+struct drm_crtc;
+struct drm_connector;
+struct drm_mode;
+struct drm_surface;
-struct kms_display {
+struct drm_display {
struct native_display base;
struct native_event_handler *event_handler;
int fd;
- struct kms_config *config;
+ struct drm_config *config;
/* for modesetting */
drmModeResPtr resources;
- struct kms_connector *connectors;
+ struct drm_connector *connectors;
int num_connectors;
- struct kms_surface **shown_surfaces;
+ struct drm_surface **shown_surfaces;
/* save the original settings of the CRTCs */
- struct kms_crtc *saved_crtcs;
+ struct drm_crtc *saved_crtcs;
};
-struct kms_config {
+struct drm_config {
struct native_config base;
};
-struct kms_crtc {
+struct drm_crtc {
drmModeCrtcPtr crtc;
uint32_t connectors[32];
int num_connectors;
};
-struct kms_framebuffer {
+struct drm_framebuffer {
struct pipe_resource *texture;
boolean is_passive;
uint32_t buffer_id;
};
-struct kms_surface {
+struct drm_surface {
struct native_surface base;
- struct kms_display *kdpy;
+ struct drm_display *drmdpy;
struct resource_surface *rsurf;
enum pipe_format color_format;
int width, height;
unsigned int sequence_number;
- struct kms_framebuffer front_fb, back_fb;
+ struct drm_framebuffer front_fb, back_fb;
boolean is_shown;
- struct kms_crtc current_crtc;
+ struct drm_crtc current_crtc;
};
-struct kms_connector {
+struct drm_connector {
struct native_connector base;
uint32_t connector_id;
drmModeConnectorPtr connector;
- struct kms_mode *kms_modes;
+ struct drm_mode *drm_modes;
int num_modes;
};
-struct kms_mode {
+struct drm_mode {
struct native_mode base;
drmModeModeInfo mode;
};
-static INLINE struct kms_display *
-kms_display(const struct native_display *ndpy)
+static INLINE struct drm_display *
+drm_display(const struct native_display *ndpy)
{
- return (struct kms_display *) ndpy;
+ return (struct drm_display *) ndpy;
}
-static INLINE struct kms_config *
-kms_config(const struct native_config *nconf)
+static INLINE struct drm_config *
+drm_config(const struct native_config *nconf)
{
- return (struct kms_config *) nconf;
+ return (struct drm_config *) nconf;
}
-static INLINE struct kms_surface *
-kms_surface(const struct native_surface *nsurf)
+static INLINE struct drm_surface *
+drm_surface(const struct native_surface *nsurf)
{
- return (struct kms_surface *) nsurf;
+ return (struct drm_surface *) nsurf;
}
-static INLINE struct kms_connector *
-kms_connector(const struct native_connector *nconn)
+static INLINE struct drm_connector *
+drm_connector(const struct native_connector *nconn)
{
- return (struct kms_connector *) nconn;
+ return (struct drm_connector *) nconn;
}
-static INLINE struct kms_mode *
-kms_mode(const struct native_mode *nmode)
+static INLINE struct drm_mode *
+drm_mode(const struct native_mode *nmode)
{
- return (struct kms_mode *) nmode;
+ return (struct drm_mode *) nmode;
}
boolean
-kms_display_init_modeset(struct native_display *ndpy);
+drm_display_init_modeset(struct native_display *ndpy);
void
-kms_display_fini_modeset(struct native_display *ndpy);
+drm_display_fini_modeset(struct native_display *ndpy);
-#endif /* _NATIVE_KMS_H_ */
+#endif /* _NATIVE_DRM_H_ */
--
cgit v1.2.3
From a1d9a58b825825723f1c5f7705f2ed3ef834038a Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Sun, 19 Sep 2010 19:27:30 +0200
Subject: r600g: Flush upload buffers before draws instead of before flushes.
If a upload buffer is used by a previous draw that's still in the CS,
accessing it would need a context flush. However, doing a context flush when
mapping the upload buffer would then flush/destroy the same buffer we're trying
to map there. Flushing the upload buffers before a draw avoids both the CS
flush and the upload buffer going away while it's being used. Note that
u_upload_data() could e.g. use a pool of buffers instead of allocating new
ones all the time if that turns out to be a significant issue.
---
src/gallium/drivers/r600/r600_context.c | 4 ----
src/gallium/drivers/r600/r600_draw.c | 5 +++++
2 files changed, 5 insertions(+), 4 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 776dc24569..f07cbfc2cc 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -70,10 +70,6 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
struct r600_context *rctx = r600_context(ctx);
struct r600_query *rquery = NULL;
- /* flush upload buffers */
- u_upload_flush(rctx->upload_vb);
- u_upload_flush(rctx->upload_ib);
-
/* suspend queries */
r600_queries_suspend(ctx);
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index cbfa44868e..00a6aeaef2 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
#include "radeon.h"
#include "r600_screen.h"
#include "r600_context.h"
@@ -125,6 +126,10 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
memset(&draw, 0, sizeof(draw));
+ /* flush upload buffers */
+ u_upload_flush(rctx->upload_vb);
+ u_upload_flush(rctx->upload_ib);
+
if (rctx->any_user_vbs) {
r600_upload_user_buffers(rctx);
rctx->any_user_vbs = false;
--
cgit v1.2.3
From b68030e9f8211e5905c81b4c7f8de5780f48b655 Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Sun, 19 Sep 2010 19:27:30 +0200
Subject: r600g: Check for other references before checking for existing
mappings in radeon_bo_pb_map_internal().
Having a non-NULL data pointer doesn't imply it's safe to reuse that mapping,
it may have been unmapped but not flushed yet.
---
src/gallium/winsys/r600/drm/radeon_bo_pb.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/winsys/r600/drm/radeon_bo_pb.c b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
index 65ba96233d..8cf6a78130 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo_pb.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
@@ -53,11 +53,16 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
unsigned flags, void *ctx)
{
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
-
- if (flags & PB_USAGE_DONTBLOCK) {
- if (p_atomic_read(&buf->bo->reference.count) > 1)
+
+ if (p_atomic_read(&buf->bo->reference.count) > 1) {
+ if (flags & PB_USAGE_DONTBLOCK) {
return NULL;
+ }
+ if (ctx) {
+ r600_flush_ctx(ctx);
+ }
}
+
if (buf->bo->data != NULL) {
LIST_DELINIT(&buf->maplist);
return buf->bo->data;
@@ -69,9 +74,6 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
return NULL;
}
- if (p_atomic_read(&buf->bo->reference.count) > 1 && ctx) {
- r600_flush_ctx(ctx);
- }
if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
}
--
cgit v1.2.3
From de9c8015eb30bf8a7e8571e7ca85e985173b0695 Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Sun, 19 Sep 2010 19:27:30 +0200
Subject: r600g: Remove a redundant flush in r600_texture_transfer_map().
radeon_ws_bo_map() will already take care of that if needed.
---
src/gallium/drivers/r600/r600_texture.c | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 274679d127..b7a12edc20 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -325,7 +325,6 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
char *map;
int r;
- ctx->flush(ctx, 0, NULL);
if (rtransfer->linear_texture) {
bo = ((struct r600_resource *)rtransfer->linear_texture)->bo;
} else {
--
cgit v1.2.3
From affd46cc2bb327490fbc6a96f936dccf82d4996d Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Sun, 19 Sep 2010 19:27:30 +0200
Subject: r600g: Buffer object maps imply a wait.
Unless e.g. PB_USAGE_DONTBLOCK or PB_USAGE_UNSYNCHRONIZED would be specified.
---
src/gallium/drivers/r600/r600.h | 21 ---------------------
src/gallium/drivers/r600/r600_query.c | 1 -
src/gallium/drivers/r600/r600_texture.c | 1 -
src/gallium/drivers/r600/radeon.h | 1 -
src/gallium/winsys/r600/drm/radeon_bo_pb.c | 20 +++++++++++++-------
src/gallium/winsys/r600/drm/radeon_ws_bo.c | 11 -----------
6 files changed, 13 insertions(+), 42 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index bce2707e77..7cbacea89a 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -92,26 +92,6 @@ enum radeon_family {
enum radeon_family r600_get_family(struct radeon *rw);
-/*
- * radeon object functions
- */
-#if 0
-struct radeon_bo {
- unsigned refcount;
- unsigned handle;
- unsigned size;
- unsigned alignment;
- unsigned map_count;
- void *data;
-};
-struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
- unsigned size, unsigned alignment, void *ptr);
-int radeon_bo_map(struct radeon *radeon, struct radeon_bo *bo);
-void radeon_bo_unmap(struct radeon *radeon, struct radeon_bo *bo);
-struct radeon_bo *radeon_bo_incref(struct radeon *radeon, struct radeon_bo *bo);
-struct radeon_bo *radeon_bo_decref(struct radeon *radeon, struct radeon_bo *bo);
-int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);
-#endif
/* lowlevel WS bo */
struct radeon_ws_bo;
struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon,
@@ -122,7 +102,6 @@ void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo, unsigned
void radeon_ws_bo_unmap(struct radeon *radeon, struct radeon_ws_bo *bo);
void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst,
struct radeon_ws_bo *src);
-int radeon_ws_bo_wait(struct radeon *radeon, struct radeon_ws_bo *bo);
/* R600/R700 STATES */
#define R600_GROUP_MAX 16
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index 12900cce11..298cc4eadd 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -108,7 +108,6 @@ static void r600_query_result(struct pipe_context *ctx, struct r600_query *rquer
u32 *results;
int i;
- radeon_ws_bo_wait(rscreen->rw, rquery->buffer);
results = radeon_ws_bo_map(rscreen->rw, rquery->buffer, 0, r600_context(ctx));
for (i = 0; i < rquery->num_results; i += 4) {
start = (u64)results[i] | (u64)results[i + 1] << 32;
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index b7a12edc20..d41150c938 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -347,7 +347,6 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
if (!map) {
return NULL;
}
- radeon_ws_bo_wait(radeon, bo);
return map + offset;
}
diff --git a/src/gallium/drivers/r600/radeon.h b/src/gallium/drivers/r600/radeon.h
index 5f9f21db1b..5249194eb1 100644
--- a/src/gallium/drivers/r600/radeon.h
+++ b/src/gallium/drivers/r600/radeon.h
@@ -100,7 +100,6 @@ void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo, unsigned
void radeon_ws_bo_unmap(struct radeon *radeon, struct radeon_ws_bo *bo);
void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst,
struct radeon_ws_bo *src);
-int radeon_ws_bo_wait(struct radeon *radeon, struct radeon_ws_bo *bo);
struct radeon_stype_info;
/*
diff --git a/src/gallium/winsys/r600/drm/radeon_bo_pb.c b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
index 8cf6a78130..b8744b00eb 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo_pb.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
@@ -63,20 +63,26 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
}
}
- if (buf->bo->data != NULL) {
- LIST_DELINIT(&buf->maplist);
- return buf->bo->data;
- }
-
if (flags & PB_USAGE_DONTBLOCK) {
uint32_t domain;
if (radeon_bo_busy(buf->mgr->radeon, buf->bo, &domain))
return NULL;
}
- if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
- return NULL;
+ if (buf->bo->data != NULL) {
+ if (radeon_bo_wait(buf->mgr->radeon, buf->bo)) {
+ return NULL;
+ }
+ } else {
+ if (radeon_bo_map(buf->mgr->radeon, buf->bo)) {
+ return NULL;
+ }
+ if (radeon_bo_wait(buf->mgr->radeon, buf->bo)) {
+ radeon_bo_unmap(buf->mgr->radeon, buf->bo);
+ return NULL;
+ }
}
+
LIST_DELINIT(&buf->maplist);
return buf->bo->data;
}
diff --git a/src/gallium/winsys/r600/drm/radeon_ws_bo.c b/src/gallium/winsys/r600/drm/radeon_ws_bo.c
index 8114526a14..daaf2cbc51 100644
--- a/src/gallium/winsys/r600/drm/radeon_ws_bo.c
+++ b/src/gallium/winsys/r600/drm/radeon_ws_bo.c
@@ -72,17 +72,6 @@ void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst,
*dst = src;
}
-int radeon_ws_bo_wait(struct radeon *radeon, struct radeon_ws_bo *pb_bo)
-{
- /* TODO */
- struct radeon_bo *bo;
- bo = radeon_bo_pb_get_bo(pb_bo->pb);
- if (!bo)
- return 0;
- radeon_bo_wait(radeon, bo);
- return 0;
-}
-
unsigned radeon_ws_bo_get_handle(struct radeon_ws_bo *pb_bo)
{
struct radeon_bo *bo;
--
cgit v1.2.3
From a01578c84ffcc03a98b3c3f20d05cdb0e0e4ada7 Mon Sep 17 00:00:00 2001
From: Luca Barbieri
Date: Sun, 19 Sep 2010 21:48:28 +0200
Subject: auxiliary: fix depth-only and stencil-only clears
Depth-only and stencil-only clears should mask out depth/stencil from the
output, mask out stencil/input from input, and OR or ADD them together.
However, due to a typo they were being ANDed, resulting in zeroing the buffer.
---
src/gallium/auxiliary/util/u_surface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index af99163b2e..f78b6838a7 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -332,7 +332,7 @@ util_clear_depth_stencil(struct pipe_context *pipe,
uint32_t *row = (uint32_t *)dst_map;
for (j = 0; j < width; j++) {
uint32_t tmp = *row & dst_mask;
- *row++ = tmp & (zstencil & ~dst_mask);
+ *row++ = tmp | (zstencil & ~dst_mask);
}
dst_map += dst_stride;
}
--
cgit v1.2.3
From d323118c3ef1ed197e61e7a80e0ddafbe9e70ecb Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck
Date: Sun, 19 Sep 2010 09:03:11 +0200
Subject: gallium/docs: Fixed a typo in the SCS opcode description.
Signed-off-by: Tilman Sauerbeck
---
src/gallium/docs/source/tgsi.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index e588c5b7bd..4c1f47ac67 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -726,7 +726,7 @@ This instruction replicates its result.
dst.z = 0
- dst.y = 1
+ dst.w = 1
.. opcode:: TXB - Texture Lookup With Bias
--
cgit v1.2.3
From 0f9181811fc0e2943b156acc4d43f2da8a4846d1 Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Sun, 19 Sep 2010 22:58:42 +0200
Subject: r600g: Respect PB_USAGE_UNSYNCHRONIZED in
radeon_bo_pb_map_internal().
---
src/gallium/winsys/r600/drm/radeon_bo_pb.c | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/winsys/r600/drm/radeon_bo_pb.c b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
index b8744b00eb..93dc927aba 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo_pb.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
@@ -54,6 +54,14 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
{
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
+ if (flags & PB_USAGE_UNSYNCHRONIZED) {
+ if (!buf->bo->data && radeon_bo_map(buf->mgr->radeon, buf->bo)) {
+ return NULL;
+ }
+ LIST_DELINIT(&buf->maplist);
+ return buf->bo->data;
+ }
+
if (p_atomic_read(&buf->bo->reference.count) > 1) {
if (flags & PB_USAGE_DONTBLOCK) {
return NULL;
--
cgit v1.2.3
From 1934ade18309d44f6e98f571674404ecb19d6364 Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Sun, 19 Sep 2010 22:59:14 +0200
Subject: Revert "r600g: Flush upload buffers before draws instead of before
flushes."
This reverts commit a1d9a58b825825723f1c5f7705f2ed3ef834038a.
Flushing the upload buffers on draw is wrong, uploads aren't supposed to
cause flushes in the first place. The real issue was
radeon_bo_pb_map_internal() not respecting PB_USAGE_UNSYNCHRONIZED.
---
src/gallium/drivers/r600/r600_context.c | 4 ++++
src/gallium/drivers/r600/r600_draw.c | 5 -----
2 files changed, 4 insertions(+), 5 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index f07cbfc2cc..776dc24569 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -70,6 +70,10 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
struct r600_context *rctx = r600_context(ctx);
struct r600_query *rquery = NULL;
+ /* flush upload buffers */
+ u_upload_flush(rctx->upload_vb);
+ u_upload_flush(rctx->upload_ib);
+
/* suspend queries */
r600_queries_suspend(ctx);
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index 00a6aeaef2..cbfa44868e 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -31,7 +31,6 @@
#include
#include
#include
-#include
#include "radeon.h"
#include "r600_screen.h"
#include "r600_context.h"
@@ -126,10 +125,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
memset(&draw, 0, sizeof(draw));
- /* flush upload buffers */
- u_upload_flush(rctx->upload_vb);
- u_upload_flush(rctx->upload_ib);
-
if (rctx->any_user_vbs) {
r600_upload_user_buffers(rctx);
rctx->any_user_vbs = false;
--
cgit v1.2.3
From 7faa37adf84c7fdc393a0e795c924ea9b047f235 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz
Date: Fri, 10 Sep 2010 02:15:11 +0200
Subject: rbug: Cast opcode to corrent int size
---
src/gallium/auxiliary/rbug/rbug_context.c | 20 ++++++++++----------
src/gallium/auxiliary/rbug/rbug_core.c | 10 +++++-----
src/gallium/auxiliary/rbug/rbug_shader.c | 12 ++++++------
src/gallium/auxiliary/rbug/rbug_texture.c | 14 +++++++-------
4 files changed, 28 insertions(+), 28 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c
index 1832425658..a3fd7e8430 100644
--- a/src/gallium/auxiliary/rbug/rbug_context.c
+++ b/src/gallium/auxiliary/rbug/rbug_context.c
@@ -480,7 +480,7 @@ struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_h
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST)
return NULL;
pos = 0;
@@ -506,7 +506,7 @@ struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_h
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO)
return NULL;
pos = 0;
@@ -533,7 +533,7 @@ struct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCK)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK)
return NULL;
pos = 0;
@@ -561,7 +561,7 @@ struct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rb
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_STEP)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_STEP)
return NULL;
pos = 0;
@@ -589,7 +589,7 @@ struct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(str
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)
return NULL;
pos = 0;
@@ -617,7 +617,7 @@ struct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rb
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_RULE)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_RULE)
return NULL;
pos = 0;
@@ -649,7 +649,7 @@ struct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_FLUSH)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_FLUSH)
return NULL;
pos = 0;
@@ -677,7 +677,7 @@ struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST_REPLY)
return NULL;
pos = 0;
@@ -705,7 +705,7 @@ struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO_REPLY)
return NULL;
pos = 0;
@@ -739,7 +739,7 @@ struct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(str
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)
+ if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)
return NULL;
pos = 0;
diff --git a/src/gallium/auxiliary/rbug/rbug_core.c b/src/gallium/auxiliary/rbug/rbug_core.c
index 876ae5a0ce..1d47d13c9f 100644
--- a/src/gallium/auxiliary/rbug/rbug_core.c
+++ b/src/gallium/auxiliary/rbug/rbug_core.c
@@ -233,7 +233,7 @@ struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header)
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_NOOP)
+ if (header->opcode != (int32_t)RBUG_OP_NOOP)
return NULL;
pos = 0;
@@ -259,7 +259,7 @@ struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header)
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_PING)
+ if (header->opcode != (int32_t)RBUG_OP_PING)
return NULL;
pos = 0;
@@ -285,7 +285,7 @@ struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header)
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_ERROR)
+ if (header->opcode != (int32_t)RBUG_OP_ERROR)
return NULL;
pos = 0;
@@ -312,7 +312,7 @@ struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_heade
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_PING_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_PING_REPLY)
return NULL;
pos = 0;
@@ -339,7 +339,7 @@ struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_hea
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_ERROR_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_ERROR_REPLY)
return NULL;
pos = 0;
diff --git a/src/gallium/auxiliary/rbug/rbug_shader.c b/src/gallium/auxiliary/rbug/rbug_shader.c
index fccd2f55ef..1742941cc1 100644
--- a/src/gallium/auxiliary/rbug/rbug_shader.c
+++ b/src/gallium/auxiliary/rbug/rbug_shader.c
@@ -305,7 +305,7 @@ struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_hea
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST)
+ if (header->opcode != (int32_t)RBUG_OP_SHADER_LIST)
return NULL;
pos = 0;
@@ -332,7 +332,7 @@ struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_hea
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO)
+ if (header->opcode != (int32_t)RBUG_OP_SHADER_INFO)
return NULL;
pos = 0;
@@ -360,7 +360,7 @@ struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_pro
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_SHADER_DISABLE)
+ if (header->opcode != (int32_t)RBUG_OP_SHADER_DISABLE)
return NULL;
pos = 0;
@@ -389,7 +389,7 @@ struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_pro
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_SHADER_REPLACE)
+ if (header->opcode != (int32_t)RBUG_OP_SHADER_REPLACE)
return NULL;
pos = 0;
@@ -418,7 +418,7 @@ struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rb
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_SHADER_LIST_REPLY)
return NULL;
pos = 0;
@@ -446,7 +446,7 @@ struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rb
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_SHADER_INFO_REPLY)
return NULL;
pos = 0;
diff --git a/src/gallium/auxiliary/rbug/rbug_texture.c b/src/gallium/auxiliary/rbug/rbug_texture.c
index 5a918fe6bc..2ad577915e 100644
--- a/src/gallium/auxiliary/rbug/rbug_texture.c
+++ b/src/gallium/auxiliary/rbug/rbug_texture.c
@@ -417,7 +417,7 @@ struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_h
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_LIST)
return NULL;
pos = 0;
@@ -443,7 +443,7 @@ struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_h
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_INFO)
return NULL;
pos = 0;
@@ -470,7 +470,7 @@ struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_WRITE)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_WRITE)
return NULL;
pos = 0;
@@ -506,7 +506,7 @@ struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_h
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_READ)
return NULL;
pos = 0;
@@ -540,7 +540,7 @@ struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_LIST_REPLY)
return NULL;
pos = 0;
@@ -568,7 +568,7 @@ struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_INFO_REPLY)
return NULL;
pos = 0;
@@ -606,7 +606,7 @@ struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct
if (!header)
return NULL;
- if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ_REPLY)
+ if (header->opcode != (int32_t)RBUG_OP_TEXTURE_READ_REPLY)
return NULL;
pos = 0;
--
cgit v1.2.3
From 00272e9e0991c7dab111cbea0acfd6adadece994 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz
Date: Fri, 10 Sep 2010 04:39:26 +0200
Subject: rbug: Add function to get opcode name string
---
src/gallium/auxiliary/rbug/rbug_demarshal.c | 64 +++++++++++++++++++++++++++++
src/gallium/auxiliary/rbug/rbug_proto.h | 5 +++
2 files changed, 69 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c
index 47390fbcee..06caa45469 100644
--- a/src/gallium/auxiliary/rbug/rbug_demarshal.c
+++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c
@@ -91,3 +91,67 @@ struct rbug_header * rbug_demarshal(struct rbug_proto_header *header)
return NULL;
}
}
+
+const char* rbug_proto_get_name(enum rbug_opcode opcode)
+{
+ switch(opcode) {
+ case RBUG_OP_NOOP:
+ return "RBUG_OP_NOOP";
+ case RBUG_OP_PING:
+ return "RBUG_OP_PING";
+ case RBUG_OP_ERROR:
+ return "RBUG_OP_ERROR";
+ case RBUG_OP_PING_REPLY:
+ return "RBUG_OP_PING_REPLY";
+ case RBUG_OP_ERROR_REPLY:
+ return "RBUG_OP_ERROR_REPLY";
+ case RBUG_OP_TEXTURE_LIST:
+ return "RBUG_OP_TEXTURE_LIST";
+ case RBUG_OP_TEXTURE_INFO:
+ return "RBUG_OP_TEXTURE_INFO";
+ case RBUG_OP_TEXTURE_WRITE:
+ return "RBUG_OP_TEXTURE_WRITE";
+ case RBUG_OP_TEXTURE_READ:
+ return "RBUG_OP_TEXTURE_READ";
+ case RBUG_OP_TEXTURE_LIST_REPLY:
+ return "RBUG_OP_TEXTURE_LIST_REPLY";
+ case RBUG_OP_TEXTURE_INFO_REPLY:
+ return "RBUG_OP_TEXTURE_INFO_REPLY";
+ case RBUG_OP_TEXTURE_READ_REPLY:
+ return "RBUG_OP_TEXTURE_READ_REPLY";
+ case RBUG_OP_CONTEXT_LIST:
+ return "RBUG_OP_CONTEXT_LIST";
+ case RBUG_OP_CONTEXT_INFO:
+ return "RBUG_OP_CONTEXT_INFO";
+ case RBUG_OP_CONTEXT_DRAW_BLOCK:
+ return "RBUG_OP_CONTEXT_DRAW_BLOCK";
+ case RBUG_OP_CONTEXT_DRAW_STEP:
+ return "RBUG_OP_CONTEXT_DRAW_STEP";
+ case RBUG_OP_CONTEXT_DRAW_UNBLOCK:
+ return "RBUG_OP_CONTEXT_DRAW_UNBLOCK";
+ case RBUG_OP_CONTEXT_DRAW_RULE:
+ return "RBUG_OP_CONTEXT_DRAW_RULE";
+ case RBUG_OP_CONTEXT_FLUSH:
+ return "RBUG_OP_CONTEXT_FLUSH";
+ case RBUG_OP_CONTEXT_LIST_REPLY:
+ return "RBUG_OP_CONTEXT_LIST_REPLY";
+ case RBUG_OP_CONTEXT_INFO_REPLY:
+ return "RBUG_OP_CONTEXT_INFO_REPLY";
+ case RBUG_OP_CONTEXT_DRAW_BLOCKED:
+ return "RBUG_OP_CONTEXT_DRAW_BLOCKED";
+ case RBUG_OP_SHADER_LIST:
+ return "RBUG_OP_SHADER_LIST";
+ case RBUG_OP_SHADER_INFO:
+ return "RBUG_OP_SHADER_INFO";
+ case RBUG_OP_SHADER_DISABLE:
+ return "RBUG_OP_SHADER_DISABLE";
+ case RBUG_OP_SHADER_REPLACE:
+ return "RBUG_OP_SHADER_REPLACE";
+ case RBUG_OP_SHADER_LIST_REPLY:
+ return "RBUG_OP_SHADER_LIST_REPLY";
+ case RBUG_OP_SHADER_INFO_REPLY:
+ return "RBUG_OP_SHADER_INFO_REPLY";
+ default:
+ return NULL;
+ }
+}
diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h
index 4f3eb75dc4..2fce725bc9 100644
--- a/src/gallium/auxiliary/rbug/rbug_proto.h
+++ b/src/gallium/auxiliary/rbug/rbug_proto.h
@@ -91,4 +91,9 @@ struct rbug_proto_header
*/
struct rbug_connection;
+/**
+ * Get printable string for opcode.
+ */
+const char* rbug_proto_get_name(enum rbug_opcode opcode);
+
#endif
--
cgit v1.2.3
From b83156d42fc0230fdbe0a566cc57ed87792ca887 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz
Date: Sun, 19 Sep 2010 22:08:47 +0200
Subject: scons: Link against talloc in the Gallium DRI drivers
---
src/gallium/targets/SConscript.dri | 1 +
1 file changed, 1 insertion(+)
(limited to 'src/gallium')
diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri
index e5981c2461..bc8d179e3d 100644
--- a/src/gallium/targets/SConscript.dri
+++ b/src/gallium/targets/SConscript.dri
@@ -69,6 +69,7 @@ COMMON_DRI_DRM_OBJECTS = [
drienv.AppendUnique(LIBS = [
'expat',
+ 'talloc',
])
Export([
--
cgit v1.2.3
From f1cf04dbc0549d1520159be6b4811d6d37ddb5bf Mon Sep 17 00:00:00 2001
From: Henri Verbeet
Date: Mon, 20 Sep 2010 09:29:43 +1000
Subject: r600g: fix exports_ps to export a number not a mask.
---
src/gallium/drivers/r600/eg_hw_states.c | 2 +-
src/gallium/drivers/r600/r600_hw_states.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_hw_states.c b/src/gallium/drivers/r600/eg_hw_states.c
index ad8aa4ca9a..65a5c6434b 100644
--- a/src/gallium/drivers/r600/eg_hw_states.c
+++ b/src/gallium/drivers/r600/eg_hw_states.c
@@ -961,10 +961,10 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
if (rshader->output[i].name == TGSI_SEMANTIC_POSITION)
exports_ps |= 1;
else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) {
- exports_ps |= (1 << (num_cout+1));
num_cout++;
}
}
+ exports_ps |= (1 << num_cout);
if (!exports_ps) {
/* always at least export 1 component per pixel */
exports_ps = 2;
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 25344c6f82..5e43085c62 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -974,10 +974,10 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
if (rshader->output[i].name == TGSI_SEMANTIC_POSITION)
exports_ps |= 1;
else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) {
- exports_ps |= (1 << (num_cout+1));
num_cout++;
}
}
+ exports_ps |= (num_cout << 1);
if (!exports_ps) {
/* always at least export 1 component per pixel */
exports_ps = 2;
--
cgit v1.2.3
From 91b70d84087967f65aba0ce4f9976d5e2c107f09 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Thu, 12 Aug 2010 20:20:23 +1000
Subject: util/r300g: split the r300 index buffer modifier functions out to
util
These can be used by other drivers, like r600g.
Signed-off-by: Dave Airlie
---
src/gallium/auxiliary/Makefile | 1 +
src/gallium/auxiliary/SConscript | 1 +
src/gallium/auxiliary/util/u_index_modify.c | 127 +++++++++++++++++++++++
src/gallium/auxiliary/util/u_index_modify.h | 41 ++++++++
src/gallium/drivers/r300/r300_render_translate.c | 112 +-------------------
5 files changed, 174 insertions(+), 108 deletions(-)
create mode 100644 src/gallium/auxiliary/util/u_index_modify.c
create mode 100644 src/gallium/auxiliary/util/u_index_modify.h
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 2de764c4ee..c339f72fe2 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -121,6 +121,7 @@ C_SOURCES = \
util/u_handle_table.c \
util/u_hash.c \
util/u_hash_table.c \
+ util/u_index_modify.c \
util/u_keymap.c \
util/u_linear.c \
util/u_linkage.c \
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index 294df30094..144d929f68 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -170,6 +170,7 @@ source = [
'util/u_handle_table.c',
'util/u_hash.c',
'util/u_hash_table.c',
+ 'util/u_index_modify.c',
'util/u_keymap.c',
'util/u_linear.c',
'util/u_linkage.c',
diff --git a/src/gallium/auxiliary/util/u_index_modify.c b/src/gallium/auxiliary/util/u_index_modify.c
new file mode 100644
index 0000000000..65b079ed53
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_index_modify.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2010 Marek Olšák
+ *
+ * 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 "pipe/p_context.h"
+#include "util/u_index_modify.h"
+#include "util/u_inlines.h"
+
+void util_shorten_ubyte_elts(struct pipe_context *context,
+ struct pipe_resource **elts,
+ int index_bias,
+ unsigned start,
+ unsigned count)
+{
+ struct pipe_screen* screen = context->screen;
+ struct pipe_resource* new_elts;
+ unsigned char *in_map;
+ unsigned short *out_map;
+ struct pipe_transfer *src_transfer, *dst_transfer;
+ unsigned i;
+
+ new_elts = pipe_buffer_create(screen,
+ PIPE_BIND_INDEX_BUFFER,
+ 2 * count);
+
+ in_map = pipe_buffer_map(context, *elts, PIPE_TRANSFER_READ, &src_transfer);
+ out_map = pipe_buffer_map(context, new_elts, PIPE_TRANSFER_WRITE, &dst_transfer);
+
+ in_map += start;
+
+ for (i = 0; i < count; i++) {
+ *out_map = (unsigned short)(*in_map + index_bias);
+ in_map++;
+ out_map++;
+ }
+
+ pipe_buffer_unmap(context, *elts, src_transfer);
+ pipe_buffer_unmap(context, new_elts, dst_transfer);
+
+ *elts = new_elts;
+}
+
+void util_rebuild_ushort_elts(struct pipe_context *context,
+ struct pipe_resource **elts,
+ int index_bias,
+ unsigned start, unsigned count)
+{
+ struct pipe_transfer *in_transfer = NULL;
+ struct pipe_transfer *out_transfer = NULL;
+ struct pipe_resource *new_elts;
+ unsigned short *in_map;
+ unsigned short *out_map;
+ unsigned i;
+
+ new_elts = pipe_buffer_create(context->screen,
+ PIPE_BIND_INDEX_BUFFER,
+ 2 * count);
+
+ in_map = pipe_buffer_map(context, *elts,
+ PIPE_TRANSFER_READ, &in_transfer);
+ out_map = pipe_buffer_map(context, new_elts,
+ PIPE_TRANSFER_WRITE, &out_transfer);
+
+ in_map += start;
+ for (i = 0; i < count; i++) {
+ *out_map = (unsigned short)(*in_map + index_bias);
+ in_map++;
+ out_map++;
+ }
+
+ pipe_buffer_unmap(context, *elts, in_transfer);
+ pipe_buffer_unmap(context, new_elts, out_transfer);
+
+ *elts = new_elts;
+}
+
+void util_rebuild_uint_elts(struct pipe_context *context,
+ struct pipe_resource **elts,
+ int index_bias,
+ unsigned start, unsigned count)
+{
+ struct pipe_transfer *in_transfer = NULL;
+ struct pipe_transfer *out_transfer = NULL;
+ struct pipe_resource *new_elts;
+ unsigned int *in_map;
+ unsigned int *out_map;
+ unsigned i;
+
+ new_elts = pipe_buffer_create(context->screen,
+ PIPE_BIND_INDEX_BUFFER,
+ 2 * count);
+
+ in_map = pipe_buffer_map(context, *elts,
+ PIPE_TRANSFER_READ, &in_transfer);
+ out_map = pipe_buffer_map(context, new_elts,
+ PIPE_TRANSFER_WRITE, &out_transfer);
+
+ in_map += start;
+ for (i = 0; i < count; i++) {
+ *out_map = (unsigned int)(*in_map + index_bias);
+ in_map++;
+ out_map++;
+ }
+
+ pipe_buffer_unmap(context, *elts, in_transfer);
+ pipe_buffer_unmap(context, new_elts, out_transfer);
+
+ *elts = new_elts;
+}
diff --git a/src/gallium/auxiliary/util/u_index_modify.h b/src/gallium/auxiliary/util/u_index_modify.h
new file mode 100644
index 0000000000..01a6cae94f
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_index_modify.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 Marek Olšák
+ *
+ * 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. */
+
+#ifndef UTIL_INDEX_MODIFY_H
+#define UTIL_INDEX_MODIFY_H
+
+void util_shorten_ubyte_elts(struct pipe_context *context,
+ struct pipe_resource **elts,
+ int index_bias,
+ unsigned start,
+ unsigned count);
+
+void util_rebuild_ushort_elts(struct pipe_context *context,
+ struct pipe_resource **elts,
+ int index_bias,
+ unsigned start, unsigned count);
+
+void util_rebuild_uint_elts(struct pipe_context *context,
+ struct pipe_resource **elts,
+ int index_bias,
+ unsigned start, unsigned count);
+#endif
diff --git a/src/gallium/drivers/r300/r300_render_translate.c b/src/gallium/drivers/r300/r300_render_translate.c
index 0ea11e5bfc..9247064508 100644
--- a/src/gallium/drivers/r300/r300_render_translate.c
+++ b/src/gallium/drivers/r300/r300_render_translate.c
@@ -29,6 +29,7 @@
#include "r300_context.h"
#include "translate/translate.h"
+#include "util/u_index_modify.h"
void r300_begin_vertex_translate(struct r300_context *r300)
{
@@ -188,111 +189,6 @@ void r300_end_vertex_translate(struct r300_context *r300)
NULL);
}
-static void r300_shorten_ubyte_elts(struct r300_context* r300,
- struct pipe_resource** elts,
- int index_bias,
- unsigned start,
- unsigned count)
-{
- struct pipe_context* context = &r300->context;
- struct pipe_screen* screen = r300->context.screen;
- struct pipe_resource* new_elts;
- unsigned char *in_map;
- unsigned short *out_map;
- struct pipe_transfer *src_transfer, *dst_transfer;
- unsigned i;
-
- new_elts = pipe_buffer_create(screen,
- PIPE_BIND_INDEX_BUFFER,
- 2 * count);
-
- in_map = pipe_buffer_map(context, *elts, PIPE_TRANSFER_READ, &src_transfer);
- out_map = pipe_buffer_map(context, new_elts, PIPE_TRANSFER_WRITE, &dst_transfer);
-
- in_map += start;
-
- for (i = 0; i < count; i++) {
- *out_map = (unsigned short)(*in_map + index_bias);
- in_map++;
- out_map++;
- }
-
- pipe_buffer_unmap(context, *elts, src_transfer);
- pipe_buffer_unmap(context, new_elts, dst_transfer);
-
- *elts = new_elts;
-}
-
-static void r300_rebuild_ushort_elts(struct r300_context *r300,
- struct pipe_resource **elts,
- int index_bias,
- unsigned start, unsigned count)
-{
- struct pipe_context *context = &r300->context;
- struct pipe_transfer *in_transfer = NULL;
- struct pipe_transfer *out_transfer = NULL;
- struct pipe_resource *new_elts;
- unsigned short *in_map;
- unsigned short *out_map;
- unsigned i;
-
- new_elts = pipe_buffer_create(context->screen,
- PIPE_BIND_INDEX_BUFFER,
- 2 * count);
-
- in_map = pipe_buffer_map(context, *elts,
- PIPE_TRANSFER_READ, &in_transfer);
- out_map = pipe_buffer_map(context, new_elts,
- PIPE_TRANSFER_WRITE, &out_transfer);
-
- in_map += start;
- for (i = 0; i < count; i++) {
- *out_map = (unsigned short)(*in_map + index_bias);
- in_map++;
- out_map++;
- }
-
- pipe_buffer_unmap(context, *elts, in_transfer);
- pipe_buffer_unmap(context, new_elts, out_transfer);
-
- *elts = new_elts;
-}
-
-static void r300_rebuild_uint_elts(struct r300_context *r300,
- struct pipe_resource **elts,
- int index_bias,
- unsigned start, unsigned count)
-{
- struct pipe_context *context = &r300->context;
- struct pipe_transfer *in_transfer = NULL;
- struct pipe_transfer *out_transfer = NULL;
- struct pipe_resource *new_elts;
- unsigned int *in_map;
- unsigned int *out_map;
- unsigned i;
-
- new_elts = pipe_buffer_create(context->screen,
- PIPE_BIND_INDEX_BUFFER,
- 2 * count);
-
- in_map = pipe_buffer_map(context, *elts,
- PIPE_TRANSFER_READ, &in_transfer);
- out_map = pipe_buffer_map(context, new_elts,
- PIPE_TRANSFER_WRITE, &out_transfer);
-
- in_map += start;
- for (i = 0; i < count; i++) {
- *out_map = (unsigned int)(*in_map + index_bias);
- in_map++;
- out_map++;
- }
-
- pipe_buffer_unmap(context, *elts, in_transfer);
- pipe_buffer_unmap(context, new_elts, out_transfer);
-
- *elts = new_elts;
-}
-
void r300_translate_index_buffer(struct r300_context *r300,
struct pipe_resource **index_buffer,
unsigned *index_size, unsigned index_offset,
@@ -300,21 +196,21 @@ void r300_translate_index_buffer(struct r300_context *r300,
{
switch (*index_size) {
case 1:
- r300_shorten_ubyte_elts(r300, index_buffer, index_offset, *start, count);
+ util_shorten_ubyte_elts(&r300->context, index_buffer, index_offset, *start, count);
*index_size = 2;
*start = 0;
break;
case 2:
if (*start % 2 != 0 || index_offset) {
- r300_rebuild_ushort_elts(r300, index_buffer, index_offset, *start, count);
+ util_rebuild_ushort_elts(&r300->context, index_buffer, index_offset, *start, count);
*start = 0;
}
break;
case 4:
if (index_offset) {
- r300_rebuild_uint_elts(r300, index_buffer, index_offset, *start, count);
+ util_rebuild_uint_elts(&r300->context, index_buffer, index_offset, *start, count);
*start = 0;
}
break;
--
cgit v1.2.3
From f59fe9671f29f37b02540c21957a673f8dfedc1a Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 09:57:47 +1000
Subject: r600g: modify index buffers for sizes the hw can't deal with.
this just uses the common code from r300g now in util to do translations on r600g.
---
src/gallium/drivers/r600/r600_draw.c | 39 ++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index cbfa44868e..5cebf67b07 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -31,12 +31,41 @@
#include
#include
#include
+#include
#include "radeon.h"
#include "r600_screen.h"
#include "r600_context.h"
#include "r600_resource.h"
#include "r600_state_inlines.h"
+static void r600_translate_index_buffer(struct r600_context *r600,
+ struct pipe_resource **index_buffer,
+ unsigned *index_size, unsigned index_offset,
+ unsigned *start, unsigned count)
+{
+ switch (*index_size) {
+ case 1:
+ util_shorten_ubyte_elts(&r600->context, index_buffer, index_offset, *start, count);
+ *index_size = 2;
+ *start = 0;
+ break;
+
+ case 2:
+ if (*start % 2 != 0 || index_offset) {
+ util_rebuild_ushort_elts(&r600->context, index_buffer, index_offset, *start, count);
+ *start = 0;
+ }
+ break;
+
+ case 4:
+ if (index_offset) {
+ util_rebuild_uint_elts(&r600->context, index_buffer, index_offset, *start, count);
+ *start = 0;
+ }
+ break;
+ }
+}
+
static int r600_draw_common(struct r600_draw *draw)
{
struct r600_context *rctx = r600_context(draw->ctx);
@@ -135,14 +164,20 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
draw.start = info->start;
draw.count = info->count;
if (info->indexed && rctx->index_buffer.buffer) {
+ draw.start += rctx->index_buffer.offset / rctx->index_buffer.index_size;
draw.min_index = info->min_index;
draw.max_index = info->max_index;
+
+ r600_translate_index_buffer(rctx, &rctx->index_buffer.buffer,
+ &rctx->index_buffer.index_size,
+ rctx->index_buffer.offset, &draw.start,
+ info->count);
+
+ fprintf(stderr,"draw start is %d\n", draw.start);
draw.index_size = rctx->index_buffer.index_size;
draw.index_buffer = rctx->index_buffer.buffer;
draw.index_buffer_offset = rctx->index_buffer.offset;
- assert(rctx->index_buffer.offset %
- rctx->index_buffer.index_size == 0);
r600_upload_index_buffer(rctx, &draw);
}
else {
--
cgit v1.2.3
From 3d12c207d7f9f1d25a0ee7f1bf94ce9a7f70dff3 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 10:15:26 +1000
Subject: r600g: send correct surface base update for multi-cbufs
---
src/gallium/winsys/r600/drm/r600_state.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/winsys/r600/drm/r600_state.c b/src/gallium/winsys/r600/drm/r600_state.c
index b04885a85f..57fc12ccf1 100644
--- a/src/gallium/winsys/r600/drm/r600_state.c
+++ b/src/gallium/winsys/r600/drm/r600_state.c
@@ -335,12 +335,14 @@ static void r600_state_pm4_with_flush(struct radeon_state *state, u32 flags, int
static int r600_state_pm4_cb0(struct radeon_state *state)
{
int r;
-
+ uint32_t sbu;
r = r600_state_pm4_generic(state);
if (r)
return r;
+
+ sbu = (2 << (state->stype->stype - R600_STATE_CB0));
state->pm4[state->cpm4++] = PKT3(PKT3_SURFACE_BASE_UPDATE, 0);
- state->pm4[state->cpm4++] = 0x00000002;
+ state->pm4[state->cpm4++] = sbu;
return 0;
}
--
cgit v1.2.3
From 4af55364ccb50e4f19cbb59ac6f51d86f58dedba Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 10:34:42 +1000
Subject: r600g: fix fbo-drawbuffers-maxtargets
we were leaking buffers since the flush code was added, it wasn't dropping references.
move setting up flush to the set_framebuffer_state.
clean up the flush state object.
make more space in the BOs array for flushing.
---
src/gallium/drivers/r600/r600_state.c | 29 ++++++++++++++++++++++-------
src/gallium/drivers/r600/radeon.h | 5 ++++-
2 files changed, 26 insertions(+), 8 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 4dcdc492fc..e347943873 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -33,6 +33,10 @@
#include "r600_context.h"
#include "r600_resource.h"
+static void clean_flush(struct r600_context *rctx, struct radeon_state *flush);
+static int setup_cb_flush(struct r600_context *rctx, struct radeon_state *flush);
+static int setup_db_flush(struct r600_context *rctx, struct radeon_state *flush);
+
static struct r600_context_state *r600_new_context_state(unsigned type)
{
struct r600_context_state *rstate = CALLOC_STRUCT(r600_context_state);
@@ -379,6 +383,8 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
int i;
r600_context_state_decref(rctx->framebuffer);
+ clean_flush(rctx, &rctx->hw_states.cb_flush);
+ clean_flush(rctx, &rctx->hw_states.db_flush);
rstate = r600_new_context_state(pipe_framebuffer_type);
rstate->state.framebuffer = *state;
@@ -393,6 +399,10 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
if (state->zsbuf) {
rctx->vtbl->db(rctx, &rstate->rstate[0], state);
}
+ /* setup flush states */
+ setup_cb_flush(rctx, &rctx->hw_states.cb_flush);
+ setup_db_flush(rctx, &rctx->hw_states.db_flush);
+
return;
}
@@ -554,6 +564,7 @@ struct r600_context_state *r600_context_state_decref(struct r600_context_state *
case pipe_framebuffer_type:
for (i = 0; i < rstate->state.framebuffer.nr_cbufs; i++) {
pipe_surface_reference(&rstate->state.framebuffer.cbufs[i], NULL);
+ radeon_state_fini(&rstate->rstate[i+1]);
}
pipe_surface_reference(&rstate->state.framebuffer.zsbuf, NULL);
break;
@@ -600,6 +611,17 @@ static void r600_bind_shader_sampler(struct r600_context *rctx, struct r600_shad
}
}
+static void clean_flush(struct r600_context *rctx, struct radeon_state *flush)
+{
+ struct r600_screen *rscreen = rctx->screen;
+ int i;
+
+ for (i = 0 ; i < flush->nbo; i++) {
+ radeon_ws_bo_reference(rscreen->rw, &flush->bo[i], NULL);
+ }
+ flush->nbo = 0;
+ radeon_state_fini(flush);
+}
static int setup_cb_flush(struct r600_context *rctx, struct radeon_state *flush)
{
@@ -658,10 +680,6 @@ int r600_context_hw_states(struct pipe_context *ctx)
rctx->vtbl->dsa(rctx, &rctx->hw_states.dsa);
rctx->vtbl->cb_cntl(rctx, &rctx->hw_states.cb_cntl);
- /* setup flushes */
- setup_db_flush(rctx, &rctx->hw_states.db_flush);
- setup_cb_flush(rctx, &rctx->hw_states.cb_flush);
-
/* bind states */
radeon_draw_bind(&rctx->draw, &rctx->config);
@@ -673,9 +691,6 @@ int r600_context_hw_states(struct pipe_context *ctx)
radeon_draw_bind(&rctx->draw, &rctx->hw_states.db_flush);
radeon_draw_bind(&rctx->draw, &rctx->hw_states.cb_flush);
- radeon_draw_bind(&rctx->draw, &rctx->hw_states.db_flush);
- radeon_draw_bind(&rctx->draw, &rctx->hw_states.cb_flush);
-
if (rctx->viewport) {
radeon_draw_bind(&rctx->draw, &rctx->viewport->rstate[0]);
}
diff --git a/src/gallium/drivers/r600/radeon.h b/src/gallium/drivers/r600/radeon.h
index 5249194eb1..06b5cec5a6 100644
--- a/src/gallium/drivers/r600/radeon.h
+++ b/src/gallium/drivers/r600/radeon.h
@@ -102,6 +102,9 @@ void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst,
struct radeon_ws_bo *src);
struct radeon_stype_info;
+
+/* currently limited to max buffers in a cb flush */
+#define RADEON_STATE_MAX_BO 8
/*
* states functions
*/
@@ -119,7 +122,7 @@ struct radeon_state {
u32 pm4_crc;
u32 pm4[128];
unsigned nbo;
- struct radeon_ws_bo *bo[4];
+ struct radeon_ws_bo *bo[RADEON_STATE_MAX_BO];
unsigned nreloc;
unsigned reloc_pm4_id[8];
unsigned reloc_bo_id[8];
--
cgit v1.2.3
From 040411de267bd6b0d82a621430cbbbb943fd455a Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 10:44:44 +1000
Subject: r600g: clean up valgrind issues on maxtargets test.
---
src/gallium/drivers/r600/r600_state.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index e347943873..2b97c2a94e 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -382,10 +382,16 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
struct r600_context_state *rstate;
int i;
- r600_context_state_decref(rctx->framebuffer);
+ if (rctx->framebuffer) {
+ for (i = 0; i < rctx->framebuffer->state.framebuffer.nr_cbufs; i++)
+ radeon_draw_unbind(&rctx->draw, &rctx->framebuffer->rstate[i+1]);
+ radeon_draw_unbind(&rctx->draw, &rctx->framebuffer->rstate[0]);
+ }
clean_flush(rctx, &rctx->hw_states.cb_flush);
clean_flush(rctx, &rctx->hw_states.db_flush);
+ r600_context_state_decref(rctx->framebuffer);
+
rstate = r600_new_context_state(pipe_framebuffer_type);
rstate->state.framebuffer = *state;
for (i = 0; i < rstate->state.framebuffer.nr_cbufs; i++) {
--
cgit v1.2.3
From 8d1ec80319bad197665f42b77786b94c3e9337f1 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 10:45:18 +1000
Subject: r600g: drop debugging that snuck in
---
src/gallium/drivers/r600/r600_draw.c | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index 5cebf67b07..ca205932bd 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -173,7 +173,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
rctx->index_buffer.offset, &draw.start,
info->count);
- fprintf(stderr,"draw start is %d\n", draw.start);
draw.index_size = rctx->index_buffer.index_size;
draw.index_buffer = rctx->index_buffer.buffer;
draw.index_buffer_offset = rctx->index_buffer.offset;
--
cgit v1.2.3
From 5f5bf25af5c4abeeb2f47f46e9efeeb4f8353b28 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 16:42:29 -0700
Subject: r600g: Use align() instead of handrolled code.
---
src/gallium/drivers/r600/eg_hw_states.c | 3 +--
src/gallium/drivers/r600/r600_hw_states.c | 3 +--
src/gallium/drivers/r600/r600_state2.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_hw_states.c b/src/gallium/drivers/r600/eg_hw_states.c
index 65a5c6434b..e8cf577c76 100644
--- a/src/gallium/drivers/r600/eg_hw_states.c
+++ b/src/gallium/drivers/r600/eg_hw_states.c
@@ -559,8 +559,7 @@ static void eg_resource(struct pipe_context *ctx, struct radeon_state *rstate,
rstate->placement[2] = RADEON_GEM_DOMAIN_GTT;
rstate->placement[3] = RADEON_GEM_DOMAIN_GTT;
- pitch = (tmp->pitch[0] / tmp->bpt);
- pitch = (pitch + 0x7) & ~0x7;
+ pitch = align(tmp->pitch[0] / tmp->bpt, 8);
/* FIXME properly handle first level != 0 */
rstate->states[EG_PS_RESOURCE__RESOURCE0_WORD0] =
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 5e43085c62..627a820d59 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -558,8 +558,7 @@ static void r600_resource(struct pipe_context *ctx, struct radeon_state *rstate,
rstate->placement[2] = RADEON_GEM_DOMAIN_GTT;
rstate->placement[3] = RADEON_GEM_DOMAIN_GTT;
- pitch = (tmp->pitch[0] / tmp->bpt);
- pitch = (pitch + 0x7) & ~0x7;
+ pitch = align(tmp->pitch[0] / tmp->bpt, 8);
/* FIXME properly handle first level != 0 */
rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD0] =
diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c
index 86c10a877d..38fab4bbb6 100644
--- a/src/gallium/drivers/r600/r600_state2.c
+++ b/src/gallium/drivers/r600/r600_state2.c
@@ -1218,8 +1218,7 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
bo[1] = radeon_ws_bo_incref(rscreen->rw, tmp->uncompressed);
#endif
}
- pitch = (tmp->pitch[0] / tmp->bpt);
- pitch = (pitch + 0x7) & ~0x7;
+ pitch = align(tmp->pitch[0] / tmp->bpt, 8);
/* FIXME properly handle first level != 0 */
r600_pipe_state_add_reg(rstate, R600_GROUP_RESOURCE, R_038000_RESOURCE0_WORD0,
--
cgit v1.2.3
From f76b81423e2ec178edf08df787b8241dae044484 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 17:12:26 -0700
Subject: r600g: Trivially deobfuscate r600_hw_states.
---
src/gallium/drivers/r600/r600_hw_states.c | 60 ++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 20 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 627a820d59..17851a9b6e 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -232,7 +232,8 @@ static void r600_rasterizer(struct r600_context *rctx, struct radeon_state *rsta
rctx->flat_shade = state->flatshade;
radeon_state_init(rstate, rscreen->rw, R600_STATE_RASTERIZER, 0, 0);
- rstate->states[R600_RASTERIZER__SPI_INTERP_CONTROL_0] = 0x00000001;
+ rstate->states[R600_RASTERIZER__SPI_INTERP_CONTROL_0] =
+ S_0286D4_FLAT_SHADE_ENA(1);
if (state->sprite_coord_enable) {
rstate->states[R600_RASTERIZER__SPI_INTERP_CONTROL_0] |=
S_0286D4_PNT_SPRITE_ENA(1) |
@@ -271,10 +272,10 @@ static void r600_rasterizer(struct r600_context *rctx, struct radeon_state *rsta
rstate->states[R600_RASTERIZER__PA_SC_LINE_STIPPLE] = 0x00000005;
rstate->states[R600_RASTERIZER__PA_SC_MPASS_PS_CNTL] = 0x00000000;
rstate->states[R600_RASTERIZER__PA_SC_LINE_CNTL] = 0x00000400;
- rstate->states[R600_RASTERIZER__PA_CL_GB_VERT_CLIP_ADJ] = 0x3F800000;
- rstate->states[R600_RASTERIZER__PA_CL_GB_VERT_DISC_ADJ] = 0x3F800000;
- rstate->states[R600_RASTERIZER__PA_CL_GB_HORZ_CLIP_ADJ] = 0x3F800000;
- rstate->states[R600_RASTERIZER__PA_CL_GB_HORZ_DISC_ADJ] = 0x3F800000;
+ rstate->states[R600_RASTERIZER__PA_CL_GB_VERT_CLIP_ADJ] = fui(1);
+ rstate->states[R600_RASTERIZER__PA_CL_GB_VERT_DISC_ADJ] = fui(1);
+ rstate->states[R600_RASTERIZER__PA_CL_GB_HORZ_CLIP_ADJ] = fui(1);
+ rstate->states[R600_RASTERIZER__PA_CL_GB_HORZ_DISC_ADJ] = fui(1);
rstate->states[R600_RASTERIZER__PA_SU_POLY_OFFSET_DB_FMT_CNTL] = offset_db_fmt_cntl;
rstate->states[R600_RASTERIZER__PA_SU_POLY_OFFSET_CLAMP] = 0x00000000;
rstate->states[R600_RASTERIZER__PA_SU_POLY_OFFSET_FRONT_SCALE] = fui(offset_scale);
@@ -314,7 +315,8 @@ static void r600_scissor(struct r600_context *rctx, struct radeon_state *rstate)
rstate->states[R600_SCISSOR__PA_SC_WINDOW_OFFSET] = 0x00000000;
rstate->states[R600_SCISSOR__PA_SC_WINDOW_SCISSOR_TL] = tl;
rstate->states[R600_SCISSOR__PA_SC_WINDOW_SCISSOR_BR] = br;
- rstate->states[R600_SCISSOR__PA_SC_CLIPRECT_RULE] = 0x0000FFFF;
+ rstate->states[R600_SCISSOR__PA_SC_CLIPRECT_RULE] =
+ S_02820C_CLIP_RULE(0xFFFF);
rstate->states[R600_SCISSOR__PA_SC_CLIPRECT_0_TL] = tl;
rstate->states[R600_SCISSOR__PA_SC_CLIPRECT_0_BR] = br;
rstate->states[R600_SCISSOR__PA_SC_CLIPRECT_1_TL] = tl;
@@ -339,8 +341,8 @@ static void r600_viewport(struct r600_context *rctx, struct radeon_state *rstate
struct r600_screen *rscreen = rctx->screen;
radeon_state_init(rstate, rscreen->rw, R600_STATE_VIEWPORT, 0, 0);
- rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMIN_0] = 0x00000000;
- rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMAX_0] = 0x3F800000;
+ rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMIN_0] = fui(0);
+ rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMAX_0] = fui(1);
rstate->states[R600_VIEWPORT__PA_CL_VPORT_XSCALE_0] = fui(state->scale[0]);
rstate->states[R600_VIEWPORT__PA_CL_VPORT_YSCALE_0] = fui(state->scale[1]);
rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZSCALE_0] = fui(state->scale[2]);
@@ -437,7 +439,7 @@ static void r600_dsa(struct r600_context *rctx, struct radeon_state *rstate)
}
rstate->states[R600_DSA__DB_STENCIL_CLEAR] = 0x00000000;
- rstate->states[R600_DSA__DB_DEPTH_CLEAR] = 0x3F800000;
+ rstate->states[R600_DSA__DB_DEPTH_CLEAR] = fui(1);
rstate->states[R600_DSA__SX_ALPHA_TEST_CONTROL] = alpha_test_control;
rstate->states[R600_DSA__DB_STENCILREFMASK] = stencil_ref_mask;
rstate->states[R600_DSA__DB_STENCILREFMASK_BF] = stencil_ref_mask_bf;
@@ -830,21 +832,38 @@ static void r600_init_config(struct r600_context *rctx)
rctx->config.states[R600_CONFIG__SX_MISC] = 0x00000000;
if (family >= CHIP_RV770) {
- rctx->config.states[R600_CONFIG__SQ_DYN_GPR_CNTL_PS_FLUSH_REQ] = 0x00004000;
+ rctx->config.states[R600_CONFIG__SQ_DYN_GPR_CNTL_PS_FLUSH_REQ] =
+ S_008D8C_VS_PC_LIMIT_ENABLE(1);
rctx->config.states[R600_CONFIG__TA_CNTL_AUX] = 0x07000002;
rctx->config.states[R600_CONFIG__DB_DEBUG] = 0x00000000;
- rctx->config.states[R600_CONFIG__DB_WATERMARKS] = 0x00420204;
+ rctx->config.states[R600_CONFIG__DB_WATERMARKS] =
+ S_009838_DEPTH_FREE(4) |
+ S_009838_DEPTH_FLUSH(16) |
+ S_009838_DEPTH_PENDING_FREE(4) |
+ S_009838_DEPTH_CACHELINE_FREE(4);
rctx->config.states[R600_CONFIG__SPI_THREAD_GROUPING] = 0x00000000;
- rctx->config.states[R600_CONFIG__PA_SC_MODE_CNTL] = 0x00514000;
+ rctx->config.states[R600_CONFIG__PA_SC_MODE_CNTL] = 0x00500000 |
+ S_028A4C_FORCE_EOV_CNTDWN_ENABLE(1) |
+ S_028A4C_FORCE_EOV_REZ_ENABLE(1);
} else {
rctx->config.states[R600_CONFIG__SQ_DYN_GPR_CNTL_PS_FLUSH_REQ] = 0x00000000;
- rctx->config.states[R600_CONFIG__TA_CNTL_AUX] = 0x07000003;
+ rctx->config.states[R600_CONFIG__TA_CNTL_AUX] = 0x07000002 |
+ S_009508_DISABLE_CUBE_WRAP(1);
rctx->config.states[R600_CONFIG__DB_DEBUG] = 0x82000000;
- rctx->config.states[R600_CONFIG__DB_WATERMARKS] = 0x01020204;
- rctx->config.states[R600_CONFIG__SPI_THREAD_GROUPING] = 0x00000001;
- rctx->config.states[R600_CONFIG__PA_SC_MODE_CNTL] = 0x00004010;
+ rctx->config.states[R600_CONFIG__DB_WATERMARKS] =
+ S_009838_DEPTH_FREE(4) |
+ S_009838_DEPTH_FLUSH(16) |
+ S_009838_DEPTH_PENDING_FREE(4) |
+ S_009838_DEPTH_CACHELINE_FREE(16);
+ rctx->config.states[R600_CONFIG__SPI_THREAD_GROUPING] =
+ S_0286C8_PS_GROUPING(1);
+ rctx->config.states[R600_CONFIG__PA_SC_MODE_CNTL] =
+ S_028A4C_WALK_ORDER_ENABLE(1) |
+ S_028A4C_FORCE_EOV_CNTDWN_ENABLE(1);
}
- rctx->config.states[R600_CONFIG__CB_SHADER_CONTROL] = 0x00000003;
+ rctx->config.states[R600_CONFIG__CB_SHADER_CONTROL] =
+ S_0287A0_RT0_ENABLE(1) |
+ S_0287A0_RT1_ENABLE(1);
rctx->config.states[R600_CONFIG__SQ_ESGS_RING_ITEMSIZE] = 0x00000000;
rctx->config.states[R600_CONFIG__SQ_GSVS_RING_ITEMSIZE] = 0x00000000;
rctx->config.states[R600_CONFIG__SQ_ESTMP_RING_ITEMSIZE] = 0x00000000;
@@ -868,7 +887,7 @@ static void r600_init_config(struct r600_context *rctx)
rctx->config.states[R600_CONFIG__VGT_GROUP_VECT_1_FMT_CNTL] = 0x00000000;
rctx->config.states[R600_CONFIG__VGT_GS_MODE] = 0x00000000;
rctx->config.states[R600_CONFIG__VGT_STRMOUT_EN] = 0x00000000;
- rctx->config.states[R600_CONFIG__VGT_REUSE_OFF] = 0x00000001;
+ rctx->config.states[R600_CONFIG__VGT_REUSE_OFF] = S_028AB4_REUSE_OFF(1);
rctx->config.states[R600_CONFIG__VGT_VTX_CNT_EN] = 0x00000000;
rctx->config.states[R600_CONFIG__VGT_STRMOUT_BUFFER_EN] = 0x00000000;
radeon_state_pm4(&rctx->config);
@@ -986,7 +1005,8 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
if (have_pos) {
state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_0] |= S_0286CC_POSITION_ENA(1) |
S_0286CC_BARYC_SAMPLE_CNTL(1);
- state->states[R600_PS_SHADER__SPI_INPUT_Z] |= 1;
+ state->states[R600_PS_SHADER__SPI_INPUT_Z] |=
+ S_0286D8_PROVIDE_Z_TO_SPI(1);
}
state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] = 0x00000000;
@@ -1170,7 +1190,7 @@ static void r600_texture_state_viewport(struct r600_screen *rscreen, struct r600
rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZOFFSET_0] = 0x3F000000;
rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZSCALE_0] = 0x3F000000;
rstate->states[R600_VIEWPORT__PA_CL_VTE_CNTL] = 0x0000043F;
- rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMAX_0] = 0x3F800000;
+ rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMAX_0] = fui(1);
radeon_state_pm4(rstate);
}
--
cgit v1.2.3
From 7ee9b0b951eed3e1a553b2d8cda6b52dad39f027 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 18:04:41 -0700
Subject: r600g: Deobfuscate and comment a few more functions in
r600_hw_states.
---
src/gallium/drivers/r600/r600_hw_states.c | 44 +++++++++++++++++++++++--------
src/gallium/drivers/r600/r600d.h | 33 +++++++++++++++++++++++
2 files changed, 66 insertions(+), 11 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 17851a9b6e..5ad396dc15 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -197,7 +197,7 @@ static void r600_rasterizer(struct r600_context *rctx, struct radeon_state *rsta
float offset_units = 0, offset_scale = 0;
char depth = 0;
unsigned offset_db_fmt_cntl = 0;
- unsigned tmp;
+ unsigned point_size;
unsigned prov_vtx = 1;
if (rctx->clip)
@@ -248,9 +248,18 @@ static void r600_rasterizer(struct r600_context *rctx, struct radeon_state *rsta
}
rstate->states[R600_RASTERIZER__PA_CL_CLIP_CNTL] = 0;
if (clip) {
- rstate->states[R600_RASTERIZER__PA_CL_CLIP_CNTL] = S_028810_PS_UCP_MODE(3) | ((1 << clip->nr) - 1);
- rstate->states[R600_RASTERIZER__PA_CL_CLIP_CNTL] |= S_028810_ZCLIP_NEAR_DISABLE(clip->depth_clamp);
- rstate->states[R600_RASTERIZER__PA_CL_CLIP_CNTL] |= S_028810_ZCLIP_FAR_DISABLE(clip->depth_clamp);
+ /* Clip plane enable bits are stashed in the lower six bits of
+ * PA_CL_CLIP_CNTL, so just set all of the corresponding bits with a
+ * pinch of bit twiddling.
+ *
+ * PS_UCP_MODE 3 is "expand and clip as trifan," which is the same
+ * setting that we use on r300-r500. I believe that fglrx always uses
+ * this mode as well. */
+ rstate->states[R600_RASTERIZER__PA_CL_CLIP_CNTL] =
+ ((1 << clip->nr) - 1) |
+ S_028810_PS_UCP_MODE(3) |
+ S_028810_ZCLIP_NEAR_DISABLE(clip->depth_clamp) |
+ S_028810_ZCLIP_FAR_DISABLE(clip->depth_clamp);
}
rstate->states[R600_RASTERIZER__PA_SU_SC_MODE_CNTL] =
S_028814_PROVOKING_VTX_LAST(prov_vtx) |
@@ -264,14 +273,20 @@ static void r600_rasterizer(struct r600_context *rctx, struct radeon_state *rsta
S_02881C_USE_VTX_POINT_SIZE(state->point_size_per_vertex) |
S_02881C_VS_OUT_MISC_VEC_ENA(state->point_size_per_vertex);
rstate->states[R600_RASTERIZER__PA_CL_NANINF_CNTL] = 0x00000000;
- /* point size 12.4 fixed point */
- tmp = (unsigned)(state->point_size * 8.0);
- rstate->states[R600_RASTERIZER__PA_SU_POINT_SIZE] = S_028A00_HEIGHT(tmp) | S_028A00_WIDTH(tmp);
- rstate->states[R600_RASTERIZER__PA_SU_POINT_MINMAX] = 0x80000000;
- rstate->states[R600_RASTERIZER__PA_SU_LINE_CNTL] = 0x00000008;
+ /* Point size for PA_SU_POINT_SIZE and PA_SU_POINT_MINMAX is fixed-point,
+ * 12.4.
+ *
+ * For some reason, maximum point size is set to 0x8000 (2048.0) instead
+ * of the maximum value 0xFFF0 (4095.0). */
+ point_size = (unsigned)(state->point_size * 8.0);
+ rstate->states[R600_RASTERIZER__PA_SU_POINT_SIZE] =
+ S_028A00_HEIGHT(point_size) | S_028A00_WIDTH(point_size);
+ rstate->states[R600_RASTERIZER__PA_SU_POINT_MINMAX] =
+ S_028A04_MIN_SIZE(0) | S_028A04_MAX_SIZE(0x8000);
+ rstate->states[R600_RASTERIZER__PA_SU_LINE_CNTL] = S_028A08_WIDTH(8);
rstate->states[R600_RASTERIZER__PA_SC_LINE_STIPPLE] = 0x00000005;
rstate->states[R600_RASTERIZER__PA_SC_MPASS_PS_CNTL] = 0x00000000;
- rstate->states[R600_RASTERIZER__PA_SC_LINE_CNTL] = 0x00000400;
+ rstate->states[R600_RASTERIZER__PA_SC_LINE_CNTL] = S_028C00_LAST_PIXEL(1);
rstate->states[R600_RASTERIZER__PA_CL_GB_VERT_CLIP_ADJ] = fui(1);
rstate->states[R600_RASTERIZER__PA_CL_GB_VERT_DISC_ADJ] = fui(1);
rstate->states[R600_RASTERIZER__PA_CL_GB_HORZ_CLIP_ADJ] = fui(1);
@@ -349,7 +364,14 @@ static void r600_viewport(struct r600_context *rctx, struct radeon_state *rstate
rstate->states[R600_VIEWPORT__PA_CL_VPORT_XOFFSET_0] = fui(state->translate[0]);
rstate->states[R600_VIEWPORT__PA_CL_VPORT_YOFFSET_0] = fui(state->translate[1]);
rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZOFFSET_0] = fui(state->translate[2]);
- rstate->states[R600_VIEWPORT__PA_CL_VTE_CNTL] = 0x0000043F;
+ rstate->states[R600_VIEWPORT__PA_CL_VTE_CNTL] =
+ S_028818_VPORT_X_SCALE_ENA(1) |
+ S_028818_VPORT_X_OFFSET_ENA(1) |
+ S_028818_VPORT_Y_SCALE_ENA(1) |
+ S_028818_VPORT_Y_OFFSET_ENA(1) |
+ S_028818_VPORT_Z_SCALE_ENA(1) |
+ S_028818_VPORT_Z_OFFSET_ENA(1) |
+ S_028818_VTX_W0_FMT(1);
radeon_state_pm4(rstate);
}
diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
index 07bfc0593e..3ca3cc764b 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -2112,6 +2112,9 @@
#define R_0286D4_SPI_INTERP_CONTROL_0 0x0286D4
#define R_028A48_PA_SC_MPASS_PS_CNTL 0x028A48
#define R_028C00_PA_SC_LINE_CNTL 0x028C00
+#define S_028C00_LAST_PIXEL(x) (((x) & 0x1) << 10)
+#define G_028C00_LAST_PIXEL(x) (((x) >> 10) & 0x1)
+#define C_028C00_LAST_PIXEL 0xFFFFFBFF
#define R_028C04_PA_SC_AA_CONFIG 0x028C04
#define R_028C1C_PA_SC_AA_SAMPLE_LOCS_MCTX 0x028C1C
#define R_028C48_PA_SC_AA_MASK 0x028C48
@@ -2125,7 +2128,16 @@
#define R_028814_PA_SU_SC_MODE_CNTL 0x028814
#define R_028A00_PA_SU_POINT_SIZE 0x028A00
#define R_028A04_PA_SU_POINT_MINMAX 0x028A04
+#define S_028A04_MIN_SIZE(x) (((x) & 0xFFFF) << 0)
+#define G_028A04_MIN_SIZE(x) (((x) >> 0) & 0xFFFF)
+#define C_028A04_MIN_SIZE 0xFFFF0000
+#define S_028A04_MAX_SIZE(x) (((x) & 0xFFFF) << 16)
+#define G_028A04_MAX_SIZE(x) (((x) >> 16) & 0xFFFF)
+#define C_028A04_MAX_SIZE 0x0000FFFF
#define R_028A08_PA_SU_LINE_CNTL 0x028A08
+#define S_028A08_WIDTH(x) (((x) & 0xFFFF) << 0)
+#define G_028A08_WIDTH(x) (((x) >> 0) & 0xFFFF)
+#define C_028A08_WIDTH 0xFFFF0000
#define R_028A0C_PA_SC_LINE_STIPPLE 0x028A0C
#define R_028DF8_PA_SU_POLY_OFFSET_DB_FMT_CNTL 0x028DF8
#define R_028DFC_PA_SU_POLY_OFFSET_CLAMP 0x028DFC
@@ -2134,6 +2146,27 @@
#define R_028E08_PA_SU_POLY_OFFSET_BACK_SCALE 0x028E08
#define R_028E0C_PA_SU_POLY_OFFSET_BACK_OFFSET 0x028E0C
#define R_028818_PA_CL_VTE_CNTL 0x028818
+#define S_028818_VPORT_X_SCALE_ENA(x) (((x) & 0x1) << 0)
+#define G_028818_VPORT_X_SCALE_ENA(x) (((x) >> 0 & 0x1)
+#define C_028818_VPORT_X_SCALE_ENA 0xFFFFFFFE
+#define S_028818_VPORT_X_OFFSET_ENA(x) (((x) & 0x1) << 1)
+#define G_028818_VPORT_X_OFFSET_ENA(x) (((x) >> 1 & 0x1)
+#define C_028818_VPORT_X_OFFSET_ENA 0xFFFFFFFD
+#define S_028818_VPORT_Y_SCALE_ENA(x) (((x) & 0x1) << 2)
+#define G_028818_VPORT_Y_SCALE_ENA(x) (((x) >> 2 & 0x1)
+#define C_028818_VPORT_Y_SCALE_ENA 0xFFFFFFFB
+#define S_028818_VPORT_Y_OFFSET_ENA(x) (((x) & 0x1) << 3)
+#define G_028818_VPORT_Y_OFFSET_ENA(x) (((x) >> 3 & 0x1)
+#define C_028818_VPORT_Y_OFFSET_ENA 0xFFFFFFF7
+#define S_028818_VPORT_Z_SCALE_ENA(x) (((x) & 0x1) << 4)
+#define G_028818_VPORT_Z_SCALE_ENA(x) (((x) >> 4 & 0x1)
+#define C_028818_VPORT_Z_SCALE_ENA 0xFFFFFFEF
+#define S_028818_VPORT_Z_OFFSET_ENA(x) (((x) & 0x1) << 5)
+#define G_028818_VPORT_Z_OFFSET_ENA(x) (((x) >> 5 & 0x1)
+#define C_028818_VPORT_Z_OFFSET_ENA 0xFFFFFFDF
+#define S_028818_VTX_W0_FMT(x) (((x) & 0x1) << 10)
+#define G_028818_VTX_W0_FMT(x) (((x) >> 10) & 0x1)
+#define C_028818_VTX_W0_FMT 0xFFFFFBFF
#define R_02843C_PA_CL_VPORT_XSCALE_0 0x02843C
#define R_028444_PA_CL_VPORT_YSCALE_0 0x028444
#define R_02844C_PA_CL_VPORT_ZSCALE_0 0x02844C
--
cgit v1.2.3
From eb347c7ef06a39b86c6de7c93417b6b90baf0300 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 18:13:41 -0700
Subject: r600g: Clean up some indentation and |= vs. | usage.
---
src/gallium/drivers/r600/r600_hw_states.c | 43 ++++++++++++++++---------------
1 file changed, 22 insertions(+), 21 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 5ad396dc15..1aefc705a8 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -392,9 +392,8 @@ static void r600_dsa(struct r600_context *rctx, struct radeon_state *rstate)
}
radeon_state_init(rstate, rscreen->rw, R600_STATE_DSA, 0, 0);
- db_shader_control = 0;
- db_shader_control |= S_02880C_DUAL_EXPORT_ENABLE(1);
- db_shader_control |= S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z);
+ db_shader_control = S_02880C_DUAL_EXPORT_ENABLE(1) |
+ S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z);
rshader = &rctx->ps_shader->shader;
if (rshader->uses_kill)
@@ -408,35 +407,37 @@ static void r600_dsa(struct r600_context *rctx, struct radeon_state *rstate)
db_depth_control = S_028800_Z_ENABLE(state->depth.enabled) |
S_028800_Z_WRITE_ENABLE(state->depth.writemask) |
S_028800_ZFUNC(state->depth.func);
- /* set stencil enable */
+ /* set stencil enable */
if (state->stencil[0].enabled) {
- db_depth_control |= S_028800_STENCIL_ENABLE(1);
- db_depth_control |= S_028800_STENCILFUNC(r600_translate_ds_func(state->stencil[0].func));
- db_depth_control |= S_028800_STENCILFAIL(r600_translate_stencil_op(state->stencil[0].fail_op));
- db_depth_control |= S_028800_STENCILZPASS(r600_translate_stencil_op(state->stencil[0].zpass_op));
- db_depth_control |= S_028800_STENCILZFAIL(r600_translate_stencil_op(state->stencil[0].zfail_op));
+ db_depth_control |= S_028800_STENCIL_ENABLE(1) |
+ S_028800_STENCILFUNC(r600_translate_ds_func(state->stencil[0].func)) |
+ S_028800_STENCILFAIL(r600_translate_stencil_op(state->stencil[0].fail_op)) |
+ S_028800_STENCILZPASS(r600_translate_stencil_op(state->stencil[0].zpass_op)) |
+ S_028800_STENCILZFAIL(r600_translate_stencil_op(state->stencil[0].zfail_op));
stencil_ref_mask = S_028430_STENCILMASK(state->stencil[0].valuemask) |
- S_028430_STENCILWRITEMASK(state->stencil[0].writemask);
- stencil_ref_mask |= S_028430_STENCILREF(stencil_ref->ref_value[0]);
+ S_028430_STENCILWRITEMASK(state->stencil[0].writemask) |
+ S_028430_STENCILREF(stencil_ref->ref_value[0]);
+
if (state->stencil[1].enabled) {
- db_depth_control |= S_028800_BACKFACE_ENABLE(1);
- db_depth_control |= S_028800_STENCILFUNC_BF(r600_translate_ds_func(state->stencil[1].func));
- db_depth_control |= S_028800_STENCILFAIL_BF(r600_translate_stencil_op(state->stencil[1].fail_op));
- db_depth_control |= S_028800_STENCILZPASS_BF(r600_translate_stencil_op(state->stencil[1].zpass_op));
- db_depth_control |= S_028800_STENCILZFAIL_BF(r600_translate_stencil_op(state->stencil[1].zfail_op));
- stencil_ref_mask_bf = S_028434_STENCILMASK_BF(state->stencil[1].valuemask) |
- S_028434_STENCILWRITEMASK_BF(state->stencil[1].writemask);
- stencil_ref_mask_bf |= S_028430_STENCILREF(stencil_ref->ref_value[1]);
+ db_depth_control |= S_028800_BACKFACE_ENABLE(1) |
+ S_028800_STENCILFUNC_BF(r600_translate_ds_func(state->stencil[1].func)) |
+ S_028800_STENCILFAIL_BF(r600_translate_stencil_op(state->stencil[1].fail_op)) |
+ S_028800_STENCILZPASS_BF(r600_translate_stencil_op(state->stencil[1].zpass_op)) |
+ S_028800_STENCILZFAIL_BF(r600_translate_stencil_op(state->stencil[1].zfail_op));
+ stencil_ref_mask_bf =
+ S_028434_STENCILMASK_BF(state->stencil[1].valuemask) |
+ S_028434_STENCILWRITEMASK_BF(state->stencil[1].writemask) |
+ S_028430_STENCILREF(stencil_ref->ref_value[1]);
}
}
alpha_test_control = 0;
alpha_ref = 0;
if (state->alpha.enabled) {
- alpha_test_control = S_028410_ALPHA_FUNC(state->alpha.func);
- alpha_test_control |= S_028410_ALPHA_TEST_ENABLE(1);
+ alpha_test_control = S_028410_ALPHA_FUNC(state->alpha.func) |
+ S_028410_ALPHA_TEST_ENABLE(1);
alpha_ref = fui(state->alpha.ref_value);
}
--
cgit v1.2.3
From 07b9e22a1f587026672a00a31cebaef5aae964c6 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 18:14:41 -0700
Subject: r600g: Fix false and true.
---
src/gallium/drivers/r600/eg_hw_states.c | 4 ++--
src/gallium/drivers/r600/r600_context.c | 2 +-
src/gallium/drivers/r600/r600_draw.c | 2 +-
src/gallium/drivers/r600/r600_hw_states.c | 4 ++--
src/gallium/drivers/r600/r600_query.c | 6 +++---
src/gallium/drivers/r600/r600_resource.h | 2 +-
src/gallium/drivers/r600/r600_shader.c | 4 ++--
src/gallium/drivers/r600/r600_state2.c | 10 +++++-----
8 files changed, 17 insertions(+), 17 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_hw_states.c b/src/gallium/drivers/r600/eg_hw_states.c
index e8cf577c76..1d3a3e11c1 100644
--- a/src/gallium/drivers/r600/eg_hw_states.c
+++ b/src/gallium/drivers/r600/eg_hw_states.c
@@ -422,11 +422,11 @@ static void eg_dsa(struct r600_context *rctx, struct radeon_state *rstate)
S_028D10_FORCE_HIS_ENABLE0(V_028D10_FORCE_DISABLE) |
S_028D10_FORCE_HIS_ENABLE1(V_028D10_FORCE_DISABLE);
- query_running = false;
+ query_running = FALSE;
LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
if (rquery->state & R600_QUERY_STATE_STARTED) {
- query_running = true;
+ query_running = TRUE;
}
}
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 776dc24569..97b21d5e31 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -80,7 +80,7 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
radeon_ctx_submit(rctx->ctx);
LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
- rquery->flushed = true;
+ rquery->flushed = TRUE;
}
radeon_ctx_clear(rctx->ctx);
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index ca205932bd..51c9b06549 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -156,7 +156,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
if (rctx->any_user_vbs) {
r600_upload_user_buffers(rctx);
- rctx->any_user_vbs = false;
+ rctx->any_user_vbs = FALSE;
}
draw.ctx = ctx;
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 1aefc705a8..86bcec727c 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -447,11 +447,11 @@ static void r600_dsa(struct r600_context *rctx, struct radeon_state *rstate)
S_028D10_FORCE_HIS_ENABLE0(V_028D10_FORCE_DISABLE) |
S_028D10_FORCE_HIS_ENABLE1(V_028D10_FORCE_DISABLE);
- query_running = false;
+ query_running = FALSE;
LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
if (rquery->state & R600_QUERY_STATE_STARTED) {
- query_running = true;
+ query_running = TRUE;
}
}
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index 298cc4eadd..023b09ef65 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -132,7 +132,7 @@ static void r600_query_resume(struct pipe_context *ctx, struct r600_query *rquer
r600_query_result(ctx, rquery);
}
r600_query_begin(rctx, rquery);
- rquery->flushed = false;
+ rquery->flushed = FALSE;
}
static void r600_query_suspend(struct pipe_context *ctx, struct r600_query *rquery)
@@ -151,7 +151,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
rquery->state = R600_QUERY_STATE_STARTED;
rquery->num_results = 0;
- rquery->flushed = false;
+ rquery->flushed = FALSE;
r600_query_resume(ctx, rquery);
r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
if (r == -EBUSY) {
@@ -231,7 +231,7 @@ static boolean r600_get_query_result(struct pipe_context *ctx,
if (!rquery->flushed) {
ctx->flush(ctx, 0, NULL);
- rquery->flushed = true;
+ rquery->flushed = TRUE;
}
r600_query_result(ctx, rquery);
*result = rquery->result;
diff --git a/src/gallium/drivers/r600/r600_resource.h b/src/gallium/drivers/r600/r600_resource.h
index 6ddb1ad32a..cd1c31e82d 100644
--- a/src/gallium/drivers/r600/r600_resource.h
+++ b/src/gallium/drivers/r600/r600_resource.h
@@ -103,7 +103,7 @@ static INLINE struct r600_resource_buffer *r600_buffer(struct pipe_resource *buf
static INLINE boolean r600_buffer_is_user_buffer(struct pipe_resource *buffer)
{
- return r600_buffer(buffer)->user_buffer ? true : false;
+ return r600_buffer(buffer)->user_buffer ? TRUE : FALSE;
}
#endif
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index eac46a7ae6..773e5f6cb1 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1530,7 +1530,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
r = r600_bc_add_alu(ctx->bc, &alu);
if (r)
return r;
- src_not_temp = false;
+ src_not_temp = FALSE;
src_gpr = ctx->temp_reg;
}
@@ -1641,7 +1641,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
r = r600_bc_add_literal(ctx->bc, lit_vals);
if (r)
return r;
- src_not_temp = false;
+ src_not_temp = FALSE;
src_gpr = ctx->temp_reg;
}
diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c
index 38fab4bbb6..a190204ef4 100644
--- a/src/gallium/drivers/r600/r600_state2.c
+++ b/src/gallium/drivers/r600/r600_state2.c
@@ -205,7 +205,7 @@ static void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shade
r600_pipe_state_add_reg(rstate, R600_GROUP_CONTEXT,
R_028894_SQ_PGM_START_FS,
0x00000000, 0xFFFFFFFF, shader->bo);
- rctx->vs_rebuild = false;
+ rctx->vs_rebuild = FALSE;
}
static void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader)
@@ -275,7 +275,7 @@ static void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shade
r600_pipe_state_add_reg(rstate, R600_GROUP_CONTEXT,
R_0288CC_SQ_PGM_CF_OFFSET_PS,
0x00000000, 0xFFFFFFFF, NULL);
- rctx->ps_rebuild = false;
+ rctx->ps_rebuild = FALSE;
}
static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader)
@@ -1082,10 +1082,10 @@ static void r600_bind_rs_state(struct pipe_context *ctx, void *state)
return;
if (rctx->flatshade != rs->flatshade) {
- rctx->ps_rebuild = true;
+ rctx->ps_rebuild = TRUE;
}
if (rctx->sprite_coord_enable != rs->sprite_coord_enable) {
- rctx->ps_rebuild = true;
+ rctx->ps_rebuild = TRUE;
}
rctx->flatshade = rs->flatshade;
rctx->sprite_coord_enable = rs->sprite_coord_enable;
@@ -1371,7 +1371,7 @@ static void r600_bind_vertex_elements(struct pipe_context *ctx, void *state)
rctx->vertex_elements = v;
if (v) {
v->refcount++;
- rctx->vs_rebuild = true;
+ rctx->vs_rebuild = TRUE;
}
}
--
cgit v1.2.3
From c2ba729321b1e36f50027382bb825f3152ecd1d1 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 18:20:05 -0700
Subject: r600g: "tmp" is such a bad name for a texture.
---
src/gallium/drivers/r600/r600_hw_states.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 86bcec727c..ed7c6b40a4 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -540,7 +540,7 @@ static void r600_resource(struct pipe_context *ctx, struct radeon_state *rstate,
struct r600_context *rctx = r600_context(ctx);
struct r600_screen *rscreen = rctx->screen;
const struct util_format_description *desc;
- struct r600_resource_texture *tmp;
+ struct r600_resource_texture *texture;
struct r600_resource *rbuffer;
unsigned format;
uint32_t word4 = 0, yuv_format = 0, pitch = 0;
@@ -564,15 +564,15 @@ static void r600_resource(struct pipe_context *ctx, struct radeon_state *rstate,
return;
}
radeon_state_init(rstate, rscreen->rw, R600_STATE_RESOURCE, id, R600_SHADER_PS);
- tmp = (struct r600_resource_texture*)view->texture;
- rbuffer = &tmp->resource;
- if (tmp->depth) {
- r = r600_texture_from_depth(ctx, tmp, view->first_level);
+ texture = (struct r600_resource_texture*)view->texture;
+ rbuffer = &texture->resource;
+ if (texture->depth) {
+ r = r600_texture_from_depth(ctx, texture, view->first_level);
if (r) {
return;
}
- radeon_ws_bo_reference(rscreen->rw, &rstate->bo[0], tmp->uncompressed);
- radeon_ws_bo_reference(rscreen->rw, &rstate->bo[1], tmp->uncompressed);
+ radeon_ws_bo_reference(rscreen->rw, &rstate->bo[0], texture->uncompressed);
+ radeon_ws_bo_reference(rscreen->rw, &rstate->bo[1], texture->uncompressed);
} else {
radeon_ws_bo_reference(rscreen->rw, &rstate->bo[0], rbuffer->bo);
radeon_ws_bo_reference(rscreen->rw, &rstate->bo[1], rbuffer->bo);
@@ -583,7 +583,7 @@ static void r600_resource(struct pipe_context *ctx, struct radeon_state *rstate,
rstate->placement[2] = RADEON_GEM_DOMAIN_GTT;
rstate->placement[3] = RADEON_GEM_DOMAIN_GTT;
- pitch = align(tmp->pitch[0] / tmp->bpt, 8);
+ pitch = align(texture->pitch[0] / texture->bpt, 8);
/* FIXME properly handle first level != 0 */
rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD0] =
@@ -596,8 +596,8 @@ static void r600_resource(struct pipe_context *ctx, struct radeon_state *rstate,
S_038004_TEX_HEIGHT(view->texture->height0 - 1) |
S_038004_TEX_DEPTH(view->texture->depth0 - 1) |
S_038004_DATA_FORMAT(format);
- rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD2] = tmp->offset[0] >> 8;
- rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD3] = tmp->offset[1] >> 8;
+ rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD2] = texture->offset[0] >> 8;
+ rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD3] = texture->offset[1] >> 8;
rstate->states[R600_PS_RESOURCE__RESOURCE0_WORD4] =
word4 |
S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_NORM) |
--
cgit v1.2.3
From 9b146eae2521d8e5f6d3cbefa4f6f7737666313a Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 11:39:14 +1000
Subject: r600g: fix tiling support for ddx supplied buffers
needed to emit some more relocs to the kernel.
---
src/gallium/winsys/r600/drm/r600_states.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/winsys/r600/drm/r600_states.h b/src/gallium/winsys/r600/drm/r600_states.h
index 50b25a9940..f7ef266f7d 100644
--- a/src/gallium/winsys/r600/drm/r600_states.h
+++ b/src/gallium/winsys/r600/drm/r600_states.h
@@ -401,7 +401,7 @@ static const struct radeon_register R600_names_GS_SAMPLER_BORDER[] = {
static const struct radeon_register R600_names_CB0[] = {
{0x00028040, 1, 0, "CB_COLOR0_BASE"},
- {0x000280A0, 0, 0, "CB_COLOR0_INFO"},
+ {0x000280A0, 1, 0, "CB_COLOR0_INFO"},
{0x00028060, 0, 0, "CB_COLOR0_SIZE"},
{0x00028080, 0, 0, "CB_COLOR0_VIEW"},
{0x000280E0, 1, 0, "CB_COLOR0_FRAG"},
@@ -411,7 +411,7 @@ static const struct radeon_register R600_names_CB0[] = {
static const struct radeon_register R600_names_CB1[] = {
{0x00028044, 1, 0, "CB_COLOR1_BASE"},
- {0x000280A4, 0, 0, "CB_COLOR1_INFO"},
+ {0x000280A4, 1, 0, "CB_COLOR1_INFO"},
{0x00028064, 0, 0, "CB_COLOR1_SIZE"},
{0x00028084, 0, 0, "CB_COLOR1_VIEW"},
{0x000280E4, 1, 0, "CB_COLOR1_FRAG"},
@@ -421,7 +421,7 @@ static const struct radeon_register R600_names_CB1[] = {
static const struct radeon_register R600_names_CB2[] = {
{0x00028048, 1, 0, "CB_COLOR2_BASE"},
- {0x000280A8, 0, 0, "CB_COLOR2_INFO"},
+ {0x000280A8, 1, 0, "CB_COLOR2_INFO"},
{0x00028068, 0, 0, "CB_COLOR2_SIZE"},
{0x00028088, 0, 0, "CB_COLOR2_VIEW"},
{0x000280E8, 1, 0, "CB_COLOR2_FRAG"},
@@ -431,7 +431,7 @@ static const struct radeon_register R600_names_CB2[] = {
static const struct radeon_register R600_names_CB3[] = {
{0x0002804C, 1, 0, "CB_COLOR3_BASE"},
- {0x000280AC, 0, 0, "CB_COLOR3_INFO"},
+ {0x000280AC, 1, 0, "CB_COLOR3_INFO"},
{0x0002806C, 0, 0, "CB_COLOR3_SIZE"},
{0x0002808C, 0, 0, "CB_COLOR3_VIEW"},
{0x000280EC, 1, 0, "CB_COLOR3_FRAG"},
@@ -441,7 +441,7 @@ static const struct radeon_register R600_names_CB3[] = {
static const struct radeon_register R600_names_CB4[] = {
{0x00028050, 1, 0, "CB_COLOR4_BASE"},
- {0x000280B0, 0, 0, "CB_COLOR4_INFO"},
+ {0x000280B0, 1, 0, "CB_COLOR4_INFO"},
{0x00028070, 0, 0, "CB_COLOR4_SIZE"},
{0x00028090, 0, 0, "CB_COLOR4_VIEW"},
{0x000280F0, 1, 0, "CB_COLOR4_FRAG"},
@@ -451,7 +451,7 @@ static const struct radeon_register R600_names_CB4[] = {
static const struct radeon_register R600_names_CB5[] = {
{0x00028054, 1, 0, "CB_COLOR5_BASE"},
- {0x000280B4, 0, 0, "CB_COLOR5_INFO"},
+ {0x000280B4, 1, 0, "CB_COLOR5_INFO"},
{0x00028074, 0, 0, "CB_COLOR5_SIZE"},
{0x00028094, 0, 0, "CB_COLOR5_VIEW"},
{0x000280F4, 1, 0, "CB_COLOR5_FRAG"},
@@ -461,7 +461,7 @@ static const struct radeon_register R600_names_CB5[] = {
static const struct radeon_register R600_names_CB6[] = {
{0x00028058, 1, 0, "CB_COLOR6_BASE"},
- {0x000280B8, 0, 0, "CB_COLOR6_INFO"},
+ {0x000280B8, 1, 0, "CB_COLOR6_INFO"},
{0x00028078, 0, 0, "CB_COLOR6_SIZE"},
{0x00028098, 0, 0, "CB_COLOR6_VIEW"},
{0x000280F8, 1, 0, "CB_COLOR6_FRAG"},
@@ -471,7 +471,7 @@ static const struct radeon_register R600_names_CB6[] = {
static const struct radeon_register R600_names_CB7[] = {
{0x0002805C, 1, 0, "CB_COLOR7_BASE"},
- {0x000280BC, 0, 0, "CB_COLOR7_INFO"},
+ {0x000280BC, 1, 0, "CB_COLOR7_INFO"},
{0x0002807C, 0, 0, "CB_COLOR7_SIZE"},
{0x0002809C, 0, 0, "CB_COLOR7_VIEW"},
{0x000280FC, 1, 0, "CB_COLOR7_FRAG"},
@@ -483,7 +483,7 @@ static const struct radeon_register R600_names_DB[] = {
{0x0002800C, 1, 0, "DB_DEPTH_BASE"},
{0x00028000, 0, 0, "DB_DEPTH_SIZE"},
{0x00028004, 0, 0, "DB_DEPTH_VIEW"},
- {0x00028010, 0, 0, "DB_DEPTH_INFO"},
+ {0x00028010, 1, 0, "DB_DEPTH_INFO"},
{0x00028D24, 0, 0, "DB_HTILE_SURFACE"},
{0x00028D34, 0, 0, "DB_PREFETCH_LIMIT"},
};
--
cgit v1.2.3
From 2cabbb290f07dae98fc969725028fdfde0b14b81 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 12:04:52 +1000
Subject: r600g: add z16 to color setup
---
src/gallium/drivers/r600/eg_state_inlines.h | 6 ++++++
src/gallium/drivers/r600/r600_state_inlines.h | 7 +++++++
2 files changed, 13 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_state_inlines.h b/src/gallium/drivers/r600/eg_state_inlines.h
index 4e3514638b..bee2a8adcf 100644
--- a/src/gallium/drivers/r600/eg_state_inlines.h
+++ b/src/gallium/drivers/r600/eg_state_inlines.h
@@ -283,6 +283,9 @@ static inline uint32_t r600_translate_colorswap(enum pipe_format format)
case PIPE_FORMAT_B4G4R4A4_UNORM:
case PIPE_FORMAT_B4G4R4X4_UNORM:
return V_028C70_SWAP_ALT;
+
+ case PIPE_FORMAT_Z16_UNORM:
+ return V_028C70_SWAP_STD;
/* 32-bit buffers. */
case PIPE_FORMAT_A8B8G8R8_SRGB:
@@ -357,6 +360,9 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
case PIPE_FORMAT_B4G4R4X4_UNORM:
return V_028C70_COLOR_4_4_4_4;
+ case PIPE_FORMAT_Z16_UNORM:
+ return V_028C70_COLOR_16;
+
/* 32-bit buffers. */
case PIPE_FORMAT_A8B8G8R8_SRGB:
case PIPE_FORMAT_A8B8G8R8_UNORM:
diff --git a/src/gallium/drivers/r600/r600_state_inlines.h b/src/gallium/drivers/r600/r600_state_inlines.h
index b4c21d9e12..9ffdd75582 100644
--- a/src/gallium/drivers/r600/r600_state_inlines.h
+++ b/src/gallium/drivers/r600/r600_state_inlines.h
@@ -283,6 +283,10 @@ static inline uint32_t r600_translate_colorswap(enum pipe_format format)
case PIPE_FORMAT_B4G4R4A4_UNORM:
case PIPE_FORMAT_B4G4R4X4_UNORM:
return V_0280A0_SWAP_ALT;
+
+ case PIPE_FORMAT_Z16_UNORM:
+ return V_0280A0_SWAP_STD;
+
/* 32-bit buffers. */
case PIPE_FORMAT_A8B8G8R8_SRGB:
@@ -357,6 +361,9 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
case PIPE_FORMAT_B4G4R4X4_UNORM:
return V_0280A0_COLOR_4_4_4_4;
+ case PIPE_FORMAT_Z16_UNORM:
+ return V_0280A0_COLOR_16;
+
/* 32-bit buffers. */
case PIPE_FORMAT_A8B8G8R8_SRGB:
case PIPE_FORMAT_A8B8G8R8_UNORM:
--
cgit v1.2.3
From 3a1defa5e88cc846d8f5ba73ef475af95e7bc4ae Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 12:21:35 +1000
Subject: r600g: add color/texture support for more depth formats.
---
src/gallium/drivers/r600/eg_state_inlines.h | 8 ++++++++
src/gallium/drivers/r600/r600_state_inlines.h | 8 ++++++++
src/gallium/drivers/r600/r600_texture.c | 6 ++++--
3 files changed, 20 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_state_inlines.h b/src/gallium/drivers/r600/eg_state_inlines.h
index bee2a8adcf..0a42abcdf2 100644
--- a/src/gallium/drivers/r600/eg_state_inlines.h
+++ b/src/gallium/drivers/r600/eg_state_inlines.h
@@ -313,6 +313,10 @@ static inline uint32_t r600_translate_colorswap(enum pipe_format format)
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
return V_028C70_SWAP_STD;
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ return V_028C70_SWAP_STD;
+
case PIPE_FORMAT_R10G10B10A2_UNORM:
case PIPE_FORMAT_R10G10B10X2_SNORM:
case PIPE_FORMAT_B10G10R10A2_UNORM:
@@ -389,6 +393,10 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
return V_028C70_COLOR_8_24;
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ return V_028C70_COLOR_24_8;
+
case PIPE_FORMAT_R32_FLOAT:
return V_028C70_COLOR_32_FLOAT;
diff --git a/src/gallium/drivers/r600/r600_state_inlines.h b/src/gallium/drivers/r600/r600_state_inlines.h
index 9ffdd75582..283f1e59b3 100644
--- a/src/gallium/drivers/r600/r600_state_inlines.h
+++ b/src/gallium/drivers/r600/r600_state_inlines.h
@@ -314,6 +314,10 @@ static inline uint32_t r600_translate_colorswap(enum pipe_format format)
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
return V_0280A0_SWAP_STD;
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ return V_0280A0_SWAP_STD;
+
case PIPE_FORMAT_R10G10B10A2_UNORM:
case PIPE_FORMAT_R10G10B10X2_SNORM:
case PIPE_FORMAT_B10G10R10A2_UNORM:
@@ -390,6 +394,10 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
return V_0280A0_COLOR_8_24;
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ return V_0280A0_COLOR_24_8;
+
case PIPE_FORMAT_R32_FLOAT:
return V_0280A0_COLOR_32_FLOAT;
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index d41150c938..369e5d28d0 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -467,11 +467,13 @@ uint32_t r600_translate_texformat(enum pipe_format format,
result = V_0280A0_COLOR_16;
goto out_word4;
case PIPE_FORMAT_Z24X8_UNORM:
- result = V_0280A0_COLOR_8_24;
- goto out_word4;
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
result = V_0280A0_COLOR_8_24;
goto out_word4;
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ result = V_0280A0_COLOR_24_8;
+ goto out_word4;
default:
goto out_unknown;
}
--
cgit v1.2.3
From d172ef31383112ca6967341c4007eac7ac75961e Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 15:30:52 +1000
Subject: r600g: fix r700 cube map sizing.
this fixes fbo-cubemap on r700.
---
src/gallium/drivers/r600/r600_texture.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 369e5d28d0..0d24f6ab0d 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -73,7 +73,7 @@ static unsigned long r600_texture_get_offset(struct r600_resource_texture *rtex,
}
}
-static void r600_setup_miptree(struct r600_resource_texture *rtex)
+static void r600_setup_miptree(struct r600_resource_texture *rtex, enum chip_class chipc)
{
struct pipe_resource *ptex = &rtex->resource.base.b;
unsigned long w, h, pitch, size, layer_size, i, offset;
@@ -86,8 +86,12 @@ static void r600_setup_miptree(struct r600_resource_texture *rtex)
pitch = util_format_get_stride(ptex->format, align(w, 64));
pitch = align(pitch, 256);
layer_size = pitch * h;
- if (ptex->target == PIPE_TEXTURE_CUBE)
- size = layer_size * 6;
+ if (ptex->target == PIPE_TEXTURE_CUBE) {
+ if (chipc == R700)
+ size = layer_size * 8;
+ else
+ size = layer_size * 6;
+ }
else
size = layer_size * u_minify(ptex->depth0, i);
rtex->offset[i] = offset;
@@ -103,6 +107,7 @@ static void r600_setup_miptree(struct r600_resource_texture *rtex)
struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
const struct pipe_resource *templ)
{
+ struct r600_screen *rscreen = r600_screen(screen);
struct r600_resource_texture *rtex;
struct r600_resource *resource;
struct radeon *radeon = (struct radeon *)screen->winsys;
@@ -116,7 +121,7 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
resource->base.vtbl = &r600_texture_vtbl;
pipe_reference_init(&resource->base.b.reference, 1);
resource->base.b.screen = screen;
- r600_setup_miptree(rtex);
+ r600_setup_miptree(rtex, rscreen->chip_class);
/* FIXME alignment 4096 enought ? too much ? */
resource->domain = r600_domain_from_usage(resource->base.b.bind);
--
cgit v1.2.3
From b110ddd9a95cfcd910900154af6f58e32e419f40 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 15:36:52 +1000
Subject: r600g: fixup r700 CB_SHADER_CONTROL register.
r600c emits this with a mask of each written output.
---
src/gallium/drivers/r600/r600_hw_states.c | 9 +++--
src/gallium/drivers/r600/r600_states_inc.h | 60 +++++++++++++++---------------
src/gallium/winsys/r600/drm/r600_states.h | 2 +-
3 files changed, 36 insertions(+), 35 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index ed7c6b40a4..020d16287f 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -618,15 +618,17 @@ static void r600_cb_cntl(struct r600_context *rctx, struct radeon_state *rstate)
struct r600_screen *rscreen = rctx->screen;
const struct pipe_blend_state *pbs = &rctx->blend->state.blend;
int nr_cbufs = rctx->framebuffer->state.framebuffer.nr_cbufs;
- uint32_t color_control, target_mask, shader_mask;
+ uint32_t color_control, target_mask, shader_mask, shader_control;
int i;
target_mask = 0;
shader_mask = 0;
+ shader_control = 0;
color_control = S_028808_PER_MRT_BLEND(1);
for (i = 0; i < nr_cbufs; i++) {
shader_mask |= 0xf << (i * 4);
+ shader_control |= (1 << i);
}
if (pbs->logicop_enable) {
@@ -654,6 +656,8 @@ static void r600_cb_cntl(struct r600_context *rctx, struct radeon_state *rstate)
rstate->states[R600_CB_CNTL__CB_SHADER_MASK] = shader_mask;
rstate->states[R600_CB_CNTL__CB_TARGET_MASK] = target_mask;
rstate->states[R600_CB_CNTL__CB_COLOR_CONTROL] = color_control;
+ if (rscreen->chip_class == R700)
+ rstate->states[R600_CB_CNTL__CB_SHADER_CONTROL] = shader_control;
rstate->states[R600_CB_CNTL__PA_SC_AA_CONFIG] = 0x00000000;
rstate->states[R600_CB_CNTL__PA_SC_AA_SAMPLE_LOCS_MCTX] = 0x00000000;
rstate->states[R600_CB_CNTL__PA_SC_AA_SAMPLE_LOCS_8S_WD1_MCTX] = 0x00000000;
@@ -884,9 +888,6 @@ static void r600_init_config(struct r600_context *rctx)
S_028A4C_WALK_ORDER_ENABLE(1) |
S_028A4C_FORCE_EOV_CNTDWN_ENABLE(1);
}
- rctx->config.states[R600_CONFIG__CB_SHADER_CONTROL] =
- S_0287A0_RT0_ENABLE(1) |
- S_0287A0_RT1_ENABLE(1);
rctx->config.states[R600_CONFIG__SQ_ESGS_RING_ITEMSIZE] = 0x00000000;
rctx->config.states[R600_CONFIG__SQ_GSVS_RING_ITEMSIZE] = 0x00000000;
rctx->config.states[R600_CONFIG__SQ_ESTMP_RING_ITEMSIZE] = 0x00000000;
diff --git a/src/gallium/drivers/r600/r600_states_inc.h b/src/gallium/drivers/r600/r600_states_inc.h
index de717f3536..1c8075ebdb 100644
--- a/src/gallium/drivers/r600/r600_states_inc.h
+++ b/src/gallium/drivers/r600/r600_states_inc.h
@@ -15,35 +15,34 @@
#define R600_CONFIG__DB_WATERMARKS 10
#define R600_CONFIG__SX_MISC 11
#define R600_CONFIG__SPI_THREAD_GROUPING 12
-#define R600_CONFIG__CB_SHADER_CONTROL 13
-#define R600_CONFIG__SQ_ESGS_RING_ITEMSIZE 14
-#define R600_CONFIG__SQ_GSVS_RING_ITEMSIZE 15
-#define R600_CONFIG__SQ_ESTMP_RING_ITEMSIZE 16
-#define R600_CONFIG__SQ_GSTMP_RING_ITEMSIZE 17
-#define R600_CONFIG__SQ_VSTMP_RING_ITEMSIZE 18
-#define R600_CONFIG__SQ_PSTMP_RING_ITEMSIZE 19
-#define R600_CONFIG__SQ_FBUF_RING_ITEMSIZE 20
-#define R600_CONFIG__SQ_REDUC_RING_ITEMSIZE 21
-#define R600_CONFIG__SQ_GS_VERT_ITEMSIZE 22
-#define R600_CONFIG__VGT_OUTPUT_PATH_CNTL 23
-#define R600_CONFIG__VGT_HOS_CNTL 24
-#define R600_CONFIG__VGT_HOS_MAX_TESS_LEVEL 25
-#define R600_CONFIG__VGT_HOS_MIN_TESS_LEVEL 26
-#define R600_CONFIG__VGT_HOS_REUSE_DEPTH 27
-#define R600_CONFIG__VGT_GROUP_PRIM_TYPE 28
-#define R600_CONFIG__VGT_GROUP_FIRST_DECR 29
-#define R600_CONFIG__VGT_GROUP_DECR 30
-#define R600_CONFIG__VGT_GROUP_VECT_0_CNTL 31
-#define R600_CONFIG__VGT_GROUP_VECT_1_CNTL 32
-#define R600_CONFIG__VGT_GROUP_VECT_0_FMT_CNTL 33
-#define R600_CONFIG__VGT_GROUP_VECT_1_FMT_CNTL 34
-#define R600_CONFIG__VGT_GS_MODE 35
-#define R600_CONFIG__PA_SC_MODE_CNTL 36
-#define R600_CONFIG__VGT_STRMOUT_EN 37
-#define R600_CONFIG__VGT_REUSE_OFF 38
-#define R600_CONFIG__VGT_VTX_CNT_EN 39
-#define R600_CONFIG__VGT_STRMOUT_BUFFER_EN 40
-#define R600_CONFIG_SIZE 41
+#define R600_CONFIG__SQ_ESGS_RING_ITEMSIZE 13
+#define R600_CONFIG__SQ_GSVS_RING_ITEMSIZE 14
+#define R600_CONFIG__SQ_ESTMP_RING_ITEMSIZE 15
+#define R600_CONFIG__SQ_GSTMP_RING_ITEMSIZE 16
+#define R600_CONFIG__SQ_VSTMP_RING_ITEMSIZE 17
+#define R600_CONFIG__SQ_PSTMP_RING_ITEMSIZE 18
+#define R600_CONFIG__SQ_FBUF_RING_ITEMSIZE 19
+#define R600_CONFIG__SQ_REDUC_RING_ITEMSIZE 20
+#define R600_CONFIG__SQ_GS_VERT_ITEMSIZE 21
+#define R600_CONFIG__VGT_OUTPUT_PATH_CNTL 22
+#define R600_CONFIG__VGT_HOS_CNTL 23
+#define R600_CONFIG__VGT_HOS_MAX_TESS_LEVEL 24
+#define R600_CONFIG__VGT_HOS_MIN_TESS_LEVEL 25
+#define R600_CONFIG__VGT_HOS_REUSE_DEPTH 26
+#define R600_CONFIG__VGT_GROUP_PRIM_TYPE 27
+#define R600_CONFIG__VGT_GROUP_FIRST_DECR 28
+#define R600_CONFIG__VGT_GROUP_DECR 29
+#define R600_CONFIG__VGT_GROUP_VECT_0_CNTL 30
+#define R600_CONFIG__VGT_GROUP_VECT_1_CNTL 31
+#define R600_CONFIG__VGT_GROUP_VECT_0_FMT_CNTL 32
+#define R600_CONFIG__VGT_GROUP_VECT_1_FMT_CNTL 33
+#define R600_CONFIG__VGT_GS_MODE 34
+#define R600_CONFIG__PA_SC_MODE_CNTL 35
+#define R600_CONFIG__VGT_STRMOUT_EN 36
+#define R600_CONFIG__VGT_REUSE_OFF 37
+#define R600_CONFIG__VGT_VTX_CNT_EN 38
+#define R600_CONFIG__VGT_STRMOUT_BUFFER_EN 39
+#define R600_CONFIG_SIZE 40
#define R600_CONFIG_PM4 128
/* R600_CB_CNTL */
@@ -65,7 +64,8 @@
#define R600_CB_CNTL__CB_CLRCMP_DST 15
#define R600_CB_CNTL__CB_CLRCMP_MSK 16
#define R600_CB_CNTL__PA_SC_AA_MASK 17
-#define R600_CB_CNTL_SIZE 18
+#define R600_CB_CNTL__CB_SHADER_CONTROL 18
+#define R600_CB_CNTL_SIZE 19
#define R600_CB_CNTL_PM4 128
/* R600_RASTERIZER */
diff --git a/src/gallium/winsys/r600/drm/r600_states.h b/src/gallium/winsys/r600/drm/r600_states.h
index f7ef266f7d..76e185ac03 100644
--- a/src/gallium/winsys/r600/drm/r600_states.h
+++ b/src/gallium/winsys/r600/drm/r600_states.h
@@ -31,7 +31,6 @@ static const struct radeon_register R600_names_CONFIG[] = {
{0x00009838, 0, 0, "DB_WATERMARKS"},
{0x00028350, 0, 0, "SX_MISC"},
{0x000286C8, 0, 0, "SPI_THREAD_GROUPING"},
- {0x000287A0, 0, 0, "CB_SHADER_CONTROL"},
{0x000288A8, 0, 0, "SQ_ESGS_RING_ITEMSIZE"},
{0x000288AC, 0, 0, "SQ_GSVS_RING_ITEMSIZE"},
{0x000288B0, 0, 0, "SQ_ESTMP_RING_ITEMSIZE"},
@@ -80,6 +79,7 @@ static const struct radeon_register R600_names_CB_CNTL[] = {
{0x00028C38, 0, 0, "CB_CLRCMP_DST"},
{0x00028C3C, 0, 0, "CB_CLRCMP_MSK"},
{0x00028C48, 0, 0, "PA_SC_AA_MASK"},
+ {0x000287A0, 0, 0, "CB_SHADER_CONTROL"},
};
static const struct radeon_register R600_names_RASTERIZER[] = {
--
cgit v1.2.3
From 7e5173d065f0da450cf553e3e3084a0f774919a3 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 15:38:40 +1000
Subject: r600g: add missing BC_INST wrapper for evergreen
---
src/gallium/drivers/r600/r600_shader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 773e5f6cb1..bce5297313 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -514,7 +514,7 @@ int r600_shader_from_tgsi(const struct tgsi_token *tokens, struct r600_shader *s
output[i].barrier = 1;
output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
output[i].array_base = 0;
- output[i].inst = V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT;
+ output[i].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
noutput++;
}
}
--
cgit v1.2.3
From f4020c66fd4ad28f27077238c7080c12bd5fa733 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Mon, 20 Sep 2010 15:39:03 +1000
Subject: r600g: only flush for the correct colorbuffer, not all of them.
---
src/gallium/winsys/r600/drm/r600_state.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/winsys/r600/drm/r600_state.c b/src/gallium/winsys/r600/drm/r600_state.c
index 57fc12ccf1..a4739021c4 100644
--- a/src/gallium/winsys/r600/drm/r600_state.c
+++ b/src/gallium/winsys/r600/drm/r600_state.c
@@ -304,6 +304,7 @@ static int r600_state_pm4_generic(struct radeon_state *state)
static void r600_state_pm4_with_flush(struct radeon_state *state, u32 flags, int bufs_are_cbs)
{
unsigned i, j, add, size;
+ uint32_t flags_cb;
state->nreloc = 0;
for (i = 0; i < state->nbo; i++) {
@@ -318,11 +319,12 @@ static void r600_state_pm4_with_flush(struct radeon_state *state, u32 flags, int
}
}
for (i = 0; i < state->nreloc; i++) {
+ flags_cb = flags;
size = (radeon_ws_bo_get_size(state->bo[state->reloc_bo_id[i]]) + 255) >> 8;
state->pm4[state->cpm4++] = PKT3(PKT3_SURFACE_SYNC, 3);
if (bufs_are_cbs)
- flags |= S_0085F0_CB0_DEST_BASE_ENA(1 << i);
- state->pm4[state->cpm4++] = flags;
+ flags_cb |= S_0085F0_CB0_DEST_BASE_ENA(1 << i);
+ state->pm4[state->cpm4++] = flags_cb;
state->pm4[state->cpm4++] = size;
state->pm4[state->cpm4++] = 0x00000000;
state->pm4[state->cpm4++] = 0x0000000A;
--
cgit v1.2.3
From e98062673e20109e4f95b4636a4695e50ba4b8cc Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 22:54:18 -0700
Subject: r600g: Clean up PS setup.
I didn't do r600d according to the docs; I split EXPORT_MODE to be a bit more
useful and obvious. Hope this is okay.
---
src/gallium/drivers/r600/r600_hw_states.c | 35 +++++++++++++++++--------------
src/gallium/drivers/r600/r600d.h | 6 ++++++
2 files changed, 25 insertions(+), 16 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index 020d16287f..fe6635df94 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -991,13 +991,12 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
radeon_state_init(state, rscreen->rw, R600_STATE_SHADER, 0, R600_SHADER_PS);
for (i = 0; i < rshader->ninput; i++) {
- tmp = S_028644_SEMANTIC(i);
- tmp |= S_028644_SEL_CENTROID(1);
+ tmp = S_028644_SEMANTIC(i) | S_028644_SEL_CENTROID(1);
if (rshader->input[i].name == TGSI_SEMANTIC_POSITION)
have_pos = TRUE;
if (rshader->input[i].name == TGSI_SEMANTIC_COLOR ||
- rshader->input[i].name == TGSI_SEMANTIC_BCOLOR ||
- rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
+ rshader->input[i].name == TGSI_SEMANTIC_BCOLOR ||
+ rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
}
@@ -1014,29 +1013,33 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
num_cout = 0;
for (i = 0; i < rshader->noutput; i++) {
if (rshader->output[i].name == TGSI_SEMANTIC_POSITION)
- exports_ps |= 1;
+ exports_ps |= S_028854_EXPORT_Z(1);
else if (rshader->output[i].name == TGSI_SEMANTIC_COLOR) {
num_cout++;
}
}
- exports_ps |= (num_cout << 1);
- if (!exports_ps) {
- /* always at least export 1 component per pixel */
- exports_ps = 2;
+ exports_ps |= S_028854_EXPORT_COLORS(num_cout);
+ if (exports_ps == 0) {
+ /* Always at least export 1 color component per pixel. */
+ exports_ps = S_028854_EXPORT_COLORS(1);
}
- state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_0] = S_0286CC_NUM_INTERP(rshader->ninput) |
- S_0286CC_PERSP_GRADIENT_ENA(1);
+ state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_0] =
+ S_0286CC_NUM_INTERP(rshader->ninput) |
+ S_0286CC_PERSP_GRADIENT_ENA(1);
+
if (have_pos) {
- state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_0] |= S_0286CC_POSITION_ENA(1) |
- S_0286CC_BARYC_SAMPLE_CNTL(1);
+ state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_0] |=
+ S_0286CC_POSITION_ENA(1) |
+ S_0286CC_BARYC_SAMPLE_CNTL(1);
state->states[R600_PS_SHADER__SPI_INPUT_Z] |=
S_0286D8_PROVIDE_Z_TO_SPI(1);
}
- state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] = 0x00000000;
- state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] |= S_0286D0_FRONT_FACE_ENA(have_face);
+ state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] =
+ S_0286D0_FRONT_FACE_ENA(have_face);
- state->states[R600_PS_SHADER__SQ_PGM_RESOURCES_PS] = S_028868_NUM_GPRS(rshader->bc.ngpr) |
+ state->states[R600_PS_SHADER__SQ_PGM_RESOURCES_PS] =
+ S_028868_NUM_GPRS(rshader->bc.ngpr) |
S_028868_STACK_SIZE(rshader->bc.nstack);
state->states[R600_PS_SHADER__SQ_PGM_EXPORTS_PS] = exports_ps;
radeon_ws_bo_reference(rscreen->rw, &state->bo[0], rpshader->bo);
diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
index 3ca3cc764b..f1aa49c0f7 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -2232,6 +2232,12 @@
#define R_0286C0_SPI_PS_INPUT_CNTL_31 0x0286C0
#define R_028850_SQ_PGM_RESOURCES_PS 0x028850
#define R_028854_SQ_PGM_EXPORTS_PS 0x028854
+#define S_028854_EXPORT_COLORS(x) (((x) & 0xF) << 1)
+#define G_028854_EXPORT_COLORS(x) (((x) >> 1) & 0xF)
+#define C_028854_EXPORT_COLORS 0xFFFFFFE1
+#define S_028854_EXPORT_Z(x) (((x) & 0x1) << 0)
+#define G_028854_EXPORT_Z(x) (((x) >> 0) & 0x1)
+#define C_028854_EXPORT_Z 0xFFFFFFFE
#define R_008958_VGT_PRIMITIVE_TYPE 0x008958
#define R_028A7C_VGT_DMA_INDEX_TYPE 0x028A7C
#define R_028A88_VGT_DMA_NUM_INSTANCES 0x028A88
--
cgit v1.2.3
From 0d53dfa3c5bdac3a04187a93d916b84c1ad9e8d2 Mon Sep 17 00:00:00 2001
From: Corbin Simpson
Date: Sun, 19 Sep 2010 23:02:19 -0700
Subject: r600g: Cleanup viewport floats.
---
src/gallium/drivers/r600/r600_hw_states.c | 33 +++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index fe6635df94..a4cd1bf1a1 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -1064,8 +1064,10 @@ static int r600_vs_shader(struct r600_context *rctx, struct r600_context_state *
tmp = i << ((i & 3) * 8);
state->states[R600_VS_SHADER__SPI_VS_OUT_ID_0 + i / 4] |= tmp;
}
- state->states[R600_VS_SHADER__SPI_VS_OUT_CONFIG] = S_0286C4_VS_EXPORT_COUNT(rshader->noutput - 2);
- state->states[R600_VS_SHADER__SQ_PGM_RESOURCES_VS] = S_028868_NUM_GPRS(rshader->bc.ngpr) |
+ state->states[R600_VS_SHADER__SPI_VS_OUT_CONFIG] =
+ S_0286C4_VS_EXPORT_COUNT(rshader->noutput - 2);
+ state->states[R600_VS_SHADER__SQ_PGM_RESOURCES_VS] =
+ S_028868_NUM_GPRS(rshader->bc.ngpr) |
S_028868_STACK_SIZE(rshader->bc.nstack);
radeon_ws_bo_reference(rscreen->rw, &state->bo[0], rpshader->bo);
radeon_ws_bo_reference(rscreen->rw, &state->bo[1], rpshader->bo);
@@ -1204,19 +1206,30 @@ static void r600_texture_state_db(struct r600_screen *rscreen, struct r600_resou
static void r600_texture_state_viewport(struct r600_screen *rscreen, struct r600_resource_texture *rtexture, unsigned level)
{
struct radeon_state *rstate = &rtexture->viewport[level];
+ float width, height;
radeon_state_init(rstate, rscreen->rw, R600_STATE_VIEWPORT, 0, 0);
+ width = rtexture->width[level] * 0.5;
+ height = rtexture->height[level] * 0.5;
+
/* set states (most default value are 0 and struct already
* initialized to 0, thus avoid resetting them)
*/
- rstate->states[R600_VIEWPORT__PA_CL_VPORT_XOFFSET_0] = fui((float)rtexture->width[level]/2.0);
- rstate->states[R600_VIEWPORT__PA_CL_VPORT_XSCALE_0] = fui((float)rtexture->width[level]/2.0);
- rstate->states[R600_VIEWPORT__PA_CL_VPORT_YOFFSET_0] = fui((float)rtexture->height[level]/2.0);
- rstate->states[R600_VIEWPORT__PA_CL_VPORT_YSCALE_0] = fui((float)-rtexture->height[level]/2.0);
- rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZOFFSET_0] = 0x3F000000;
- rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZSCALE_0] = 0x3F000000;
- rstate->states[R600_VIEWPORT__PA_CL_VTE_CNTL] = 0x0000043F;
+ rstate->states[R600_VIEWPORT__PA_CL_VPORT_XOFFSET_0] = fui(width);
+ rstate->states[R600_VIEWPORT__PA_CL_VPORT_XSCALE_0] = fui(width);
+ rstate->states[R600_VIEWPORT__PA_CL_VPORT_YOFFSET_0] = fui(height);
+ rstate->states[R600_VIEWPORT__PA_CL_VPORT_YSCALE_0] = fui(height);
+ rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZOFFSET_0] = fui(0.5);
+ rstate->states[R600_VIEWPORT__PA_CL_VPORT_ZSCALE_0] = fui(0.5);
+ rstate->states[R600_VIEWPORT__PA_CL_VTE_CNTL] =
+ S_028818_VPORT_X_SCALE_ENA(1) |
+ S_028818_VPORT_X_OFFSET_ENA(1) |
+ S_028818_VPORT_Y_SCALE_ENA(1) |
+ S_028818_VPORT_Y_OFFSET_ENA(1) |
+ S_028818_VPORT_Z_SCALE_ENA(1) |
+ S_028818_VPORT_Z_OFFSET_ENA(1) |
+ S_028818_VTX_W0_FMT(1);
rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMAX_0] = fui(1);
radeon_state_pm4(rstate);
@@ -1325,7 +1338,7 @@ void r600_set_constant_buffer_mem(struct pipe_context *ctx,
nconstant = buffer->width0 / 16;
size = ALIGN_DIVUP(nconstant, 16);
-
+
radeon_state_init(rstate, rscreen->rw, type, 0, shader_class);
rstate->states[R600_VS_CBUF__ALU_CONST_BUFFER_SIZE_VS_0] = size;
rstate->states[R600_VS_CBUF__ALU_CONST_CACHE_VS_0] = 0;
--
cgit v1.2.3
From 0742e0b3767072fe664ca9f39fc31d86d8d314ed Mon Sep 17 00:00:00 2001
From: Michal Krol
Date: Thu, 16 Sep 2010 16:48:00 +0000
Subject: svga: Fix relative addressing translation for pixel shaders.
Pixel shaders do not have address registers a#, only one
loop register aL. Our only hope is to assume the address
register is in fact a loop counter and replace it with aL.
Do not translate ARL instruction for pixel shaders -- MOVA
instruction is only valid for vertex saders.
Make it more explicit relative addressing of inputs is only valid
for pixel shaders and constants for vertex shaders.
---
src/gallium/drivers/svga/svga_tgsi_insn.c | 51 ++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 14 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index 72dccdf150..ad7d27acbb 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -197,22 +197,37 @@ translate_src_register( const struct svga_shader_emitter *emit,
break;
}
- /* Indirect addressing (for coninstant buffer lookups only)
+ /* Indirect addressing.
*/
- if (reg->Register.Indirect)
- {
- /* we shift the offset towards the minimum */
- if (svga_arl_needs_adjustment( emit )) {
- src.base.num -= svga_arl_adjustment( emit );
+ if (reg->Register.Indirect) {
+ if (emit->unit == PIPE_SHADER_FRAGMENT) {
+ /* Pixel shaders have only loop registers for relative
+ * addressing into inputs. Ignore the redundant address
+ * register, the contents of aL should be in sync with it.
+ */
+ if (reg->Register.File == TGSI_FILE_INPUT) {
+ src.base.relAddr = 1;
+ src.indirect = src_token(SVGA3DREG_LOOP, 0);
+ }
+ }
+ else {
+ /* Constant buffers only.
+ */
+ if (reg->Register.File == TGSI_FILE_CONSTANT) {
+ /* we shift the offset towards the minimum */
+ if (svga_arl_needs_adjustment( emit )) {
+ src.base.num -= svga_arl_adjustment( emit );
+ }
+ src.base.relAddr = 1;
+
+ /* Not really sure what should go in the second token:
+ */
+ src.indirect = src_token( SVGA3DREG_ADDR,
+ reg->Indirect.Index );
+
+ src.indirect.swizzle = SWIZZLE_XXXX;
+ }
}
- src.base.relAddr = 1;
-
- /* Not really sure what should go in the second token:
- */
- src.indirect = src_token( SVGA3DREG_ADDR,
- reg->Indirect.Index );
-
- src.indirect.swizzle = SWIZZLE_XXXX;
}
src = swizzle( src,
@@ -1593,6 +1608,14 @@ static boolean emit_arl(struct svga_shader_emitter *emit,
const struct tgsi_full_instruction *insn)
{
++emit->current_arl;
+ if (emit->unit == PIPE_SHADER_FRAGMENT) {
+ /* MOVA not present in pixel shader instruction set.
+ * Ignore this instruction altogether since it is
+ * only used for loop counters -- and for that
+ * we reference aL directly.
+ */
+ return TRUE;
+ }
if (svga_arl_needs_adjustment( emit )) {
return emit_fake_arl( emit, insn );
} else {
--
cgit v1.2.3
From 279492386ffe741c2f5b91919b37068562b6a282 Mon Sep 17 00:00:00 2001
From: Michal Krol
Date: Thu, 16 Sep 2010 16:51:03 +0000
Subject: svga: Integer constant register file has a separate namespace.
Count int and float constants independently. Since there are only
few i# constants available and hundreds of c# constants, it would
be too easy to end up with an i# declaration out of its range.
---
src/gallium/drivers/svga/svga_tgsi.c | 2 +-
src/gallium/drivers/svga/svga_tgsi_emit.h | 3 ++-
src/gallium/drivers/svga/svga_tgsi_insn.c | 12 ++++++------
3 files changed, 9 insertions(+), 8 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/svga/svga_tgsi.c b/src/gallium/drivers/svga/svga_tgsi.c
index 0cd620189b..781fe6334a 100644
--- a/src/gallium/drivers/svga/svga_tgsi.c
+++ b/src/gallium/drivers/svga/svga_tgsi.c
@@ -203,7 +203,7 @@ svga_tgsi_translate( const struct svga_shader *shader,
emit.imm_start += key.vkey.num_zero_stride_vertex_elements;
}
- emit.nr_hw_const = (emit.imm_start + emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1);
+ emit.nr_hw_float_const = (emit.imm_start + emit.info.file_max[TGSI_FILE_IMMEDIATE] + 1);
emit.nr_hw_temp = emit.info.file_max[TGSI_FILE_TEMPORARY] + 1;
emit.in_main_func = TRUE;
diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h
index b4e90a957d..63ef7f867a 100644
--- a/src/gallium/drivers/svga/svga_tgsi_emit.h
+++ b/src/gallium/drivers/svga/svga_tgsi_emit.h
@@ -62,7 +62,8 @@ struct svga_shader_emitter
int imm_start;
- int nr_hw_const;
+ int nr_hw_float_const;
+ int nr_hw_int_const;
int nr_hw_temp;
int insn_offset;
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index ad7d27acbb..f2591c5721 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -553,7 +553,7 @@ static boolean emit_def_const( struct svga_shader_emitter *emit,
static INLINE boolean
create_zero_immediate( struct svga_shader_emitter *emit )
{
- unsigned idx = emit->nr_hw_const++;
+ unsigned idx = emit->nr_hw_float_const++;
if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT,
idx, 0, 0, 0, 1 ))
@@ -568,7 +568,7 @@ create_zero_immediate( struct svga_shader_emitter *emit )
static INLINE boolean
create_loop_const( struct svga_shader_emitter *emit )
{
- unsigned idx = emit->nr_hw_const++;
+ unsigned idx = emit->nr_hw_int_const++;
if (!emit_def_const( emit, SVGA3D_CONST_TYPE_INT, idx,
255, /* iteration count */
@@ -586,7 +586,7 @@ create_loop_const( struct svga_shader_emitter *emit )
static INLINE boolean
create_sincos_consts( struct svga_shader_emitter *emit )
{
- unsigned idx = emit->nr_hw_const++;
+ unsigned idx = emit->nr_hw_float_const++;
if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT, idx,
-1.5500992e-006f,
@@ -596,7 +596,7 @@ create_sincos_consts( struct svga_shader_emitter *emit )
return FALSE;
emit->sincos_consts_idx = idx;
- idx = emit->nr_hw_const++;
+ idx = emit->nr_hw_float_const++;
if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT, idx,
-0.020833334f,
@@ -617,7 +617,7 @@ create_arl_consts( struct svga_shader_emitter *emit )
for (i = 0; i < emit->num_arl_consts; i += 4) {
int j;
- unsigned idx = emit->nr_hw_const++;
+ unsigned idx = emit->nr_hw_float_const++;
float vals[4];
for (j = 0; j < 4 && (j + i) < emit->num_arl_consts; ++j) {
vals[j] = emit->arl_consts[i + j].number;
@@ -2407,7 +2407,7 @@ static boolean make_immediate( struct svga_shader_emitter *emit,
float d,
struct src_register *out )
{
- unsigned idx = emit->nr_hw_const++;
+ unsigned idx = emit->nr_hw_float_const++;
if (!emit_def_const( emit, SVGA3D_CONST_TYPE_FLOAT,
idx, a, b, c, d ))
--
cgit v1.2.3
From 208f1f381076560cb76aac753d6da2287f53ddb5 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz
Date: Mon, 20 Sep 2010 15:25:18 +0200
Subject: i915g: Link with wrapper sw winsys with scons
---
src/gallium/targets/dri-i915/SConscript | 1 +
1 file changed, 1 insertion(+)
(limited to 'src/gallium')
diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript
index 6f9336b5ac..172f92d6b8 100644
--- a/src/gallium/targets/dri-i915/SConscript
+++ b/src/gallium/targets/dri-i915/SConscript
@@ -11,6 +11,7 @@ env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD'])
env.Prepend(LIBS = [
+ ws_wrapper,
st_dri,
i915drm,
i915,
--
cgit v1.2.3
From 363dfb83f1ca7f1ab09eec30aeb89732c5ce3e02 Mon Sep 17 00:00:00 2001
From: Jerome Glisse
Date: Mon, 20 Sep 2010 11:58:00 -0400
Subject: r600g: move chip class to radeon common structure
So texture code can be shared btw new state design
& old one.
Signed-off-by: Jerome Glisse
---
src/gallium/drivers/r600/r600.h | 7 ++++++
src/gallium/drivers/r600/r600_blit.c | 4 ++--
src/gallium/drivers/r600/r600_context.c | 2 +-
src/gallium/drivers/r600/r600_hw_states.c | 4 ++--
src/gallium/drivers/r600/r600_screen.c | 32 +++------------------------
src/gallium/drivers/r600/r600_screen.h | 9 +-------
src/gallium/drivers/r600/r600_state.c | 2 +-
src/gallium/drivers/r600/r600_state2.c | 28 ------------------------
src/gallium/drivers/r600/r600_texture.c | 6 ++----
src/gallium/drivers/r600/radeon.h | 7 ++++++
src/gallium/winsys/r600/drm/r600.c | 36 +++++++++++++++++++++++++++++++
src/gallium/winsys/r600/drm/r600_priv.h | 1 +
src/gallium/winsys/r600/drm/radeon.c | 36 +++++++++++++++++++++++++++++++
src/gallium/winsys/r600/drm/radeon_priv.h | 1 +
14 files changed, 100 insertions(+), 75 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index 7cbacea89a..a123eb62e0 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -90,7 +90,14 @@ enum radeon_family {
CHIP_LAST,
};
+enum chip_class {
+ R600,
+ R700,
+ EVERGREEN,
+};
+
enum radeon_family r600_get_family(struct radeon *rw);
+enum chip_class r600_get_family_class(struct radeon *radeon);
/* lowlevel WS bo */
struct radeon_ws_bo;
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 54fbc50bbc..0506e8280a 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -283,7 +283,7 @@ static void r600_blit_state_vs_shader(struct r600_screen *rscreen, struct radeon
radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
return;
}
- switch (rscreen->chip_class) {
+ switch (radeon_get_family_class(rscreen->rw)) {
case R600:
memcpy(data, shader_bc_r600, 128);
break;
@@ -347,7 +347,7 @@ static void r600_blit_state_ps_shader(struct r600_screen *rscreen, struct radeon
radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
return;
}
- switch (rscreen->chip_class) {
+ switch (radeon_get_family_class(rscreen->rw)) {
case R600:
memcpy(data, shader_bc_r600, 48);
break;
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 97b21d5e31..72aab91d04 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -113,7 +113,7 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
rctx->screen = rscreen;
rctx->rw = rscreen->rw;
- if (rscreen->chip_class == EVERGREEN)
+ if (radeon_get_family_class(rscreen->rw) == EVERGREEN)
rctx->vtbl = &eg_hw_state_vtbl;
else
rctx->vtbl = &r600_hw_state_vtbl;
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index a4cd1bf1a1..271bd1ac50 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -457,7 +457,7 @@ static void r600_dsa(struct r600_context *rctx, struct radeon_state *rstate)
if (query_running) {
db_render_override |= S_028D10_NOOP_CULL_DISABLE(1);
- if (rscreen->chip_class == R700)
+ if (radeon_get_family_class(rscreen->rw) == R700)
db_render_control |= S_028D0C_R700_PERFECT_ZPASS_COUNTS(1);
}
@@ -656,7 +656,7 @@ static void r600_cb_cntl(struct r600_context *rctx, struct radeon_state *rstate)
rstate->states[R600_CB_CNTL__CB_SHADER_MASK] = shader_mask;
rstate->states[R600_CB_CNTL__CB_TARGET_MASK] = target_mask;
rstate->states[R600_CB_CNTL__CB_COLOR_CONTROL] = color_control;
- if (rscreen->chip_class == R700)
+ if (radeon_get_family_class(rscreen->rw) == R700)
rstate->states[R600_CB_CNTL__CB_SHADER_CONTROL] = shader_control;
rstate->states[R600_CB_CNTL__PA_SC_AA_CONFIG] = 0x00000000;
rstate->states[R600_CB_CNTL__PA_SC_AA_SAMPLE_LOCS_MCTX] = 0x00000000;
diff --git a/src/gallium/drivers/r600/r600_screen.c b/src/gallium/drivers/r600/r600_screen.c
index 1711fabfc7..d280a45bab 100644
--- a/src/gallium/drivers/r600/r600_screen.c
+++ b/src/gallium/drivers/r600/r600_screen.c
@@ -242,39 +242,13 @@ struct pipe_screen *r600_screen_create(struct radeon *rw)
if (rscreen == NULL) {
return NULL;
}
-
+
/* don't enable mem constant for r600 yet */
rscreen->use_mem_constant = FALSE;
-
- switch (family) {
- case CHIP_R600:
- case CHIP_RV610:
- case CHIP_RV630:
- case CHIP_RV670:
- case CHIP_RV620:
- case CHIP_RV635:
- case CHIP_RS780:
- case CHIP_RS880:
- rscreen->chip_class = R600;
- break;
- case CHIP_RV770:
- case CHIP_RV730:
- case CHIP_RV710:
- case CHIP_RV740:
- rscreen->chip_class = R700;
- break;
- case CHIP_CEDAR:
- case CHIP_REDWOOD:
- case CHIP_JUNIPER:
- case CHIP_CYPRESS:
- case CHIP_HEMLOCK:
- rscreen->chip_class = EVERGREEN;
+ if (radeon_get_family_class(rw) == EVERGREEN) {
rscreen->use_mem_constant = TRUE;
- break;
- default:
- FREE(rscreen);
- return NULL;
}
+
radeon_set_mem_constant(rw, rscreen->use_mem_constant);
rscreen->rw = rw;
rscreen->screen.winsys = (struct pipe_winsys*)rw;
diff --git a/src/gallium/drivers/r600/r600_screen.h b/src/gallium/drivers/r600/r600_screen.h
index 4be77865fb..502444f03a 100644
--- a/src/gallium/drivers/r600/r600_screen.h
+++ b/src/gallium/drivers/r600/r600_screen.h
@@ -42,17 +42,10 @@ struct r600_transfer {
struct pipe_resource *linear_texture;
};
-enum chip_class {
- R600,
- R700,
- EVERGREEN,
-};
-
struct r600_screen {
struct pipe_screen screen;
struct radeon *rw;
- enum chip_class chip_class;
- boolean use_mem_constant;
+ boolean use_mem_constant;
};
static INLINE struct r600_screen *r600_screen(struct pipe_screen *screen)
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 2b97c2a94e..424f7a8913 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -527,7 +527,7 @@ void r600_init_state_functions(struct r600_context *rctx)
rctx->context.set_blend_color = r600_set_blend_color;
rctx->context.set_clip_state = r600_set_clip_state;
- if (rctx->screen->chip_class == EVERGREEN)
+ if (radeon_get_family_class(rctx->rw) == EVERGREEN)
rctx->context.set_constant_buffer = eg_set_constant_buffer;
else if (rctx->screen->use_mem_constant)
rctx->context.set_constant_buffer = r600_set_constant_buffer_mem;
diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c
index a190204ef4..ffb18ab7fb 100644
--- a/src/gallium/drivers/r600/r600_state2.c
+++ b/src/gallium/drivers/r600/r600_state2.c
@@ -56,12 +56,6 @@ uint32_t r600_translate_texformat(enum pipe_format format,
#include "r600_state_inlines.h"
-enum chip_class {
- R600,
- R700,
- EVERGREEN,
-};
-
enum r600_pipe_state_id {
R600_PIPE_STATE_BLEND = 0,
R600_PIPE_STATE_BLEND_COLOR,
@@ -85,7 +79,6 @@ enum r600_pipe_state_id {
struct r600_screen {
struct pipe_screen screen;
struct radeon *radeon;
- unsigned chip_class;
};
struct r600_pipe_sampler_view {
@@ -2189,27 +2182,6 @@ struct pipe_screen *r600_screen_create2(struct radeon *radeon)
return NULL;
}
- switch (family) {
- case CHIP_R600:
- case CHIP_RV610:
- case CHIP_RV630:
- case CHIP_RV670:
- case CHIP_RV620:
- case CHIP_RV635:
- case CHIP_RS780:
- case CHIP_RS880:
- rscreen->chip_class = R600;
- break;
- case CHIP_RV770:
- case CHIP_RV730:
- case CHIP_RV710:
- case CHIP_RV740:
- rscreen->chip_class = R700;
- break;
- default:
- FREE(rscreen);
- return NULL;
- }
rscreen->radeon = radeon;
rscreen->screen.winsys = (struct pipe_winsys*)radeon;
rscreen->screen.destroy = r600_destroy_screen;
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 0d24f6ab0d..6633258090 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -107,7 +107,6 @@ static void r600_setup_miptree(struct r600_resource_texture *rtex, enum chip_cla
struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
const struct pipe_resource *templ)
{
- struct r600_screen *rscreen = r600_screen(screen);
struct r600_resource_texture *rtex;
struct r600_resource *resource;
struct radeon *radeon = (struct radeon *)screen->winsys;
@@ -121,7 +120,7 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
resource->base.vtbl = &r600_texture_vtbl;
pipe_reference_init(&resource->base.b.reference, 1);
resource->base.b.screen = screen;
- r600_setup_miptree(rtex, rscreen->chip_class);
+ r600_setup_miptree(rtex, radeon_get_family_class(radeon));
/* FIXME alignment 4096 enought ? too much ? */
resource->domain = r600_domain_from_usage(resource->base.b.bind);
@@ -320,7 +319,6 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
void* r600_texture_transfer_map(struct pipe_context *ctx,
struct pipe_transfer* transfer)
{
- struct r600_screen *rscreen = r600_screen(ctx->screen);
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
struct radeon_ws_bo *bo;
enum pipe_format format = transfer->resource->format;
@@ -334,7 +332,7 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
bo = ((struct r600_resource *)rtransfer->linear_texture)->bo;
} else {
rtex = (struct r600_resource_texture*)transfer->resource;
- if (rtex->depth && rscreen->chip_class != EVERGREEN) {
+ if (rtex->depth && radeon_get_family_class(radeon) != EVERGREEN) {
r = r600_texture_from_depth(ctx, rtex, transfer->sr.level);
if (r) {
return NULL;
diff --git a/src/gallium/drivers/r600/radeon.h b/src/gallium/drivers/r600/radeon.h
index 06b5cec5a6..e52dcb4a34 100644
--- a/src/gallium/drivers/r600/radeon.h
+++ b/src/gallium/drivers/r600/radeon.h
@@ -79,6 +79,12 @@ enum radeon_family {
CHIP_LAST,
};
+enum chip_class {
+ R600,
+ R700,
+ EVERGREEN,
+};
+
enum {
R600_SHADER_PS = 1,
R600_SHADER_VS,
@@ -88,6 +94,7 @@ enum {
};
enum radeon_family radeon_get_family(struct radeon *rw);
+enum chip_class radeon_get_family_class(struct radeon *radeon);
void radeon_set_mem_constant(struct radeon *radeon, boolean state);
/* lowlevel WS bo */
diff --git a/src/gallium/winsys/r600/drm/r600.c b/src/gallium/winsys/r600/drm/r600.c
index af9b9187ab..fdcadffc53 100644
--- a/src/gallium/winsys/r600/drm/r600.c
+++ b/src/gallium/winsys/r600/drm/r600.c
@@ -32,6 +32,11 @@ enum radeon_family r600_get_family(struct radeon *r600)
return r600->family;
}
+enum chip_class r600_get_family_class(struct radeon *radeon)
+{
+ return radeon->chip_class;
+}
+
static int r600_get_device(struct radeon *r600)
{
struct drm_radeon_info info;
@@ -117,6 +122,37 @@ struct radeon *r600_new(int fd, unsigned device)
R600_ERR("unknown or unsupported chipset 0x%04X\n", r600->device);
break;
}
+
+ /* setup class */
+ switch (r600->family) {
+ case CHIP_R600:
+ case CHIP_RV610:
+ case CHIP_RV630:
+ case CHIP_RV670:
+ case CHIP_RV620:
+ case CHIP_RV635:
+ case CHIP_RS780:
+ case CHIP_RS880:
+ r600->chip_class = R600;
+ break;
+ case CHIP_RV770:
+ case CHIP_RV730:
+ case CHIP_RV710:
+ case CHIP_RV740:
+ r600->chip_class = R700;
+ break;
+ case CHIP_CEDAR:
+ case CHIP_REDWOOD:
+ case CHIP_JUNIPER:
+ case CHIP_CYPRESS:
+ case CHIP_HEMLOCK:
+ r600->chip_class = EVERGREEN;
+ break;
+ default:
+ R600_ERR("unknown or unsupported chipset 0x%04X\n", r600->device);
+ break;
+ }
+
return r600;
}
diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h
index 7a9025ad3c..d02562f17f 100644
--- a/src/gallium/winsys/r600/drm/r600_priv.h
+++ b/src/gallium/winsys/r600/drm/r600_priv.h
@@ -38,6 +38,7 @@ struct radeon {
int refcount;
unsigned device;
unsigned family;
+ enum chip_class chip_class;
};
struct radeon *r600_new(int fd, unsigned device);
diff --git a/src/gallium/winsys/r600/drm/radeon.c b/src/gallium/winsys/r600/drm/radeon.c
index f39d020559..c3d345fef9 100644
--- a/src/gallium/winsys/r600/drm/radeon.c
+++ b/src/gallium/winsys/r600/drm/radeon.c
@@ -30,6 +30,11 @@ enum radeon_family radeon_get_family(struct radeon *radeon)
return radeon->family;
}
+enum chip_class radeon_get_family_class(struct radeon *radeon)
+{
+ return radeon->chip_class;
+}
+
void radeon_set_mem_constant(struct radeon *radeon, boolean state)
{
radeon->use_mem_constant = state;
@@ -127,6 +132,37 @@ struct radeon *radeon_new(int fd, unsigned device)
break;
}
+ /* setup class */
+ switch (radeon->family) {
+ case CHIP_R600:
+ case CHIP_RV610:
+ case CHIP_RV630:
+ case CHIP_RV670:
+ case CHIP_RV620:
+ case CHIP_RV635:
+ case CHIP_RS780:
+ case CHIP_RS880:
+ radeon->chip_class = R600;
+ break;
+ case CHIP_RV770:
+ case CHIP_RV730:
+ case CHIP_RV710:
+ case CHIP_RV740:
+ radeon->chip_class = R700;
+ break;
+ case CHIP_CEDAR:
+ case CHIP_REDWOOD:
+ case CHIP_JUNIPER:
+ case CHIP_CYPRESS:
+ case CHIP_HEMLOCK:
+ radeon->chip_class = EVERGREEN;
+ break;
+ default:
+ fprintf(stderr, "%s unknown or unsupported chipset 0x%04X\n",
+ __func__, radeon->device);
+ break;
+ }
+
radeon->mman = pb_malloc_bufmgr_create();
if (!radeon->mman)
return NULL;
diff --git a/src/gallium/winsys/r600/drm/radeon_priv.h b/src/gallium/winsys/r600/drm/radeon_priv.h
index c284f6aa7d..85aea89c70 100644
--- a/src/gallium/winsys/r600/drm/radeon_priv.h
+++ b/src/gallium/winsys/r600/drm/radeon_priv.h
@@ -83,6 +83,7 @@ struct radeon {
int refcount;
unsigned device;
unsigned family;
+ enum chip_class chip_class;
unsigned nstype;
struct radeon_stype_info *stype;
unsigned max_states;
--
cgit v1.2.3
From 7888a2f82200738ac03c78d9900eb028d48725a1 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 10:50:15 -0600
Subject: llvmpipe: fix query bug when no there's no scene
---
src/gallium/drivers/llvmpipe/lp_query.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
index ff0e207a54..84c66dd36e 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.c
+++ b/src/gallium/drivers/llvmpipe/lp_query.c
@@ -92,8 +92,9 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
int i;
if (!pq->fence) {
- assert(0); /* query not in issued state */
- return FALSE;
+ /* no fence because there was no scene, so results is zero */
+ *result = 0;
+ return TRUE;
}
if (!lp_fence_signalled(pq->fence)) {
--
cgit v1.2.3
From b2ad8b5c221da0a7fd0d12c718d13b9a903179cc Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 11:21:44 -0600
Subject: gallivm: remove debug code
---
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 2 --
1 file changed, 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index 2d80db6dc9..f86d0553c7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -1195,7 +1195,6 @@ lp_build_sample_soa(LLVMBuilderRef builder,
lp_is_simple_wrap_mode(static_state->wrap_s) &&
lp_is_simple_wrap_mode(static_state->wrap_t)) {
/* do sampling/filtering with fixed pt arithmetic */
- printf("new sample\n");
lp_build_sample_aos(&bld, unit, s, t, r, ddx, ddy,
lod_bias, explicit_lod,
width, height, depth,
@@ -1217,7 +1216,6 @@ lp_build_sample_soa(LLVMBuilderRef builder,
static_state->wrap_t);
}
- printf("old sample\n");
lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy,
lod_bias, explicit_lod,
width, height, depth,
--
cgit v1.2.3
From 6d0b695fa7fa521c5e815f185841732163dfbb3e Mon Sep 17 00:00:00 2001
From: Luca Barbieri
Date: Mon, 20 Sep 2010 20:13:30 +0200
Subject: gallium: avoid the C++ keyword "template" in sw_winsys.h
---
src/gallium/include/state_tracker/sw_winsys.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h
index d461dedb90..0b11fe3beb 100644
--- a/src/gallium/include/state_tracker/sw_winsys.h
+++ b/src/gallium/include/state_tracker/sw_winsys.h
@@ -97,7 +97,7 @@ struct sw_winsys
*/
struct sw_displaytarget *
(*displaytarget_from_handle)( struct sw_winsys *ws,
- const struct pipe_resource *template,
+ const struct pipe_resource *templat,
struct winsys_handle *whandle,
unsigned *stride );
--
cgit v1.2.3
From 2e7d1c2c86014d8bdd615d587fb9e98bc8eda605 Mon Sep 17 00:00:00 2001
From: Luca Barbieri
Date: Mon, 20 Sep 2010 19:22:44 +0200
Subject: softpipe: make z/s test always pass if no zsbuf, instead of crashing
D3D10 specifies this.
---
src/gallium/drivers/softpipe/sp_quad_depth_test.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index 5590d40892..425fecd5da 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -695,8 +695,9 @@ depth_test_quads_fallback(struct quad_stage *qs,
nr = alpha_test_quads(qs, quads, nr);
}
- if (qs->softpipe->depth_stencil->depth.enabled ||
- qs->softpipe->depth_stencil->stencil[0].enabled) {
+ if (qs->softpipe->framebuffer.zsbuf &&
+ (qs->softpipe->depth_stencil->depth.enabled ||
+ qs->softpipe->depth_stencil->stencil[0].enabled)) {
data.ps = qs->softpipe->framebuffer.zsbuf;
data.format = data.ps->format;
@@ -805,6 +806,9 @@ choose_depth_test(struct quad_stage *qs,
boolean occlusion = qs->softpipe->active_query_count;
+ if(!qs->softpipe->framebuffer.zsbuf)
+ depth = depthwrite = stencil = FALSE;
+
/* default */
qs->run = depth_test_quads_fallback;
--
cgit v1.2.3
From de71e7a4c96e513beacb94eccbb8e5241a71aaf3 Mon Sep 17 00:00:00 2001
From: Luca Barbieri
Date: Mon, 20 Sep 2010 19:19:50 +0200
Subject: tgsi: add switch/case opcodes to tgsi_opcode_tmp.h
---
src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
index e472947507..b3123ed016 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
@@ -163,6 +163,10 @@ OP12(USGE)
OP12(USHR)
OP12(USLT)
OP12(USNE)
+OP01(SWITCH)
+OP01(CASE)
+OP00(DEFAULT)
+OP00(ENDSWITCH)
#undef OP00
--
cgit v1.2.3
From 86d5ec70d1a7bccdc26325d07c18f2a4d532dc81 Mon Sep 17 00:00:00 2001
From: Luca Barbieri
Date: Mon, 20 Sep 2010 20:49:03 +0200
Subject: softpipe: fix whitespace
---
src/gallium/drivers/softpipe/sp_quad_depth_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index 425fecd5da..e9b9262617 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -696,8 +696,8 @@ depth_test_quads_fallback(struct quad_stage *qs,
}
if (qs->softpipe->framebuffer.zsbuf &&
- (qs->softpipe->depth_stencil->depth.enabled ||
- qs->softpipe->depth_stencil->stencil[0].enabled)) {
+ (qs->softpipe->depth_stencil->depth.enabled ||
+ qs->softpipe->depth_stencil->stencil[0].enabled)) {
data.ps = qs->softpipe->framebuffer.zsbuf;
data.format = data.ps->format;
--
cgit v1.2.3
From 955d76c3d2004c058c326d68eddc5a06d1611a41 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 12:52:16 -0600
Subject: llvmpipe: maintain fragment shader state for draw module
---
src/gallium/drivers/llvmpipe/lp_state_fs.c | 12 ++++++++++++
src/gallium/drivers/llvmpipe/lp_state_fs.h | 2 ++
2 files changed, 14 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index e54dd9f0a3..fb673db6d0 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -886,6 +886,7 @@ static void *
llvmpipe_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
+ struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
struct lp_fragment_shader *shader;
int nr_samplers;
@@ -902,6 +903,12 @@ llvmpipe_create_fs_state(struct pipe_context *pipe,
/* we need to keep a local copy of the tokens */
shader->base.tokens = tgsi_dup_tokens(templ->tokens);
+ shader->draw_data = draw_create_fragment_shader(llvmpipe->draw, templ);
+ if (shader->draw_data == NULL) {
+ FREE((void *) shader->base.tokens);
+ return NULL;
+ }
+
nr_samplers = shader->info.file_max[TGSI_FILE_SAMPLER] + 1;
shader->variant_key_size = Offset(struct lp_fragment_shader_variant_key,
@@ -938,6 +945,9 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
draw_flush(llvmpipe->draw);
+ draw_bind_fragment_shader(llvmpipe->draw,
+ (llvmpipe->fs ? llvmpipe->fs->draw_data : NULL));
+
llvmpipe->fs = fs;
llvmpipe->dirty |= LP_NEW_FS;
@@ -995,6 +1005,8 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
li = next;
}
+ draw_delete_fragment_shader(llvmpipe->draw, shader->draw_data);
+
assert(shader->variants_cached == 0);
FREE((void *) shader->base.tokens);
FREE(shader);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.h b/src/gallium/drivers/llvmpipe/lp_state_fs.h
index 2914e7d7ef..4999b8dca1 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.h
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.h
@@ -100,6 +100,8 @@ struct lp_fragment_shader
struct lp_fs_variant_list_item variants;
+ struct draw_fragment_shader *draw_data;
+
/* For debugging/profiling purposes */
unsigned variant_key_size;
unsigned no;
--
cgit v1.2.3
From ebba92875aca586b661f6547888a2ed95e70e0ff Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 12:55:29 -0600
Subject: llvmpipe: indentation fix
---
src/gallium/drivers/llvmpipe/lp_state_rasterizer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index 0bad7320f3..b81c2cfd15 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -79,7 +79,7 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
llvmpipe->rasterizer->point_size,
llvmpipe->rasterizer->point_size_per_vertex,
llvmpipe->rasterizer->sprite_coord_enable);
- }
+ }
llvmpipe->dirty |= LP_NEW_RASTERIZER;
}
--
cgit v1.2.3
From 924c18da95bbc62492f8e54bd8273a4981a919dc Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 13:07:59 -0600
Subject: llvmpipe: reformatting, remove trailing whitespace, etc
---
src/gallium/drivers/llvmpipe/lp_setup_point.c | 44 ++++++++++++++-------------
1 file changed, 23 insertions(+), 21 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index 5538987151..5521cbbe87 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -52,26 +52,29 @@ struct point_info {
/**
* Compute a0 for a constant-valued coefficient (GL_FLAT shading).
*/
-static void constant_coef( struct lp_setup_context *setup,
- struct lp_rast_triangle *point,
- unsigned slot,
- const float value,
- unsigned i )
+static void
+constant_coef(struct lp_setup_context *setup,
+ struct lp_rast_triangle *point,
+ unsigned slot,
+ const float value,
+ unsigned i)
{
point->inputs.a0[slot][i] = value;
point->inputs.dadx[slot][i] = 0.0f;
point->inputs.dady[slot][i] = 0.0f;
}
-static void perspective_coef( struct lp_setup_context *setup,
- struct lp_rast_triangle *point,
- const struct point_info *info,
- unsigned slot,
- unsigned vert_attr,
- unsigned i)
+
+static void
+perspective_coef(struct lp_setup_context *setup,
+ struct lp_rast_triangle *point,
+ const struct point_info *info,
+ unsigned slot,
+ unsigned vert_attr,
+ unsigned i)
{
- if (i == 0) {
- float dadx = FIXED_ONE / (float)info->dx12;
+ if (i == 0) {
+ float dadx = FIXED_ONE / (float)info->dx12;
float dady = 0.0f;
point->inputs.dadx[slot][i] = dadx;
point->inputs.dady[slot][i] = dady;
@@ -79,30 +82,26 @@ static void perspective_coef( struct lp_setup_context *setup,
(dadx * ((float)info->v0[0][0] - setup->pixel_offset) +
dady * ((float)info->v0[0][1] - setup->pixel_offset)));
}
-
else if (i == 1) {
- float dadx = 0.0f;
+ float dadx = 0.0f;
float dady = FIXED_ONE / (float)info->dx12;
-
+
point->inputs.dadx[slot][i] = dadx;
point->inputs.dady[slot][i] = dady;
point->inputs.a0[slot][i] = (0.5 -
(dadx * ((float)info->v0[0][0] - setup->pixel_offset) +
dady * ((float)info->v0[0][1] - setup->pixel_offset)));
}
-
else if (i == 2) {
point->inputs.a0[slot][i] = 0.0f;
point->inputs.dadx[slot][i] = 0.0f;
point->inputs.dady[slot][i] = 0.0f;
}
-
else if (i == 3) {
point->inputs.a0[slot][i] = 1.0f;
point->inputs.dadx[slot][i] = 0.0f;
point->inputs.dady[slot][i] = 0.0f;
}
-
}
@@ -144,6 +143,7 @@ setup_point_fragcoord_coef(struct lp_setup_context *setup,
}
}
+
/**
* Compute the point->coef[] array dadx, dady, a0 values.
*/
@@ -203,6 +203,7 @@ setup_point_coefficients( struct lp_setup_context *setup,
fragcoord_usage_mask);
}
+
static INLINE int
subpixel_snap(float a)
{
@@ -322,8 +323,9 @@ try_setup_point( struct lp_setup_context *setup,
}
-static void lp_setup_point( struct lp_setup_context *setup,
- const float (*v0)[4] )
+static void
+lp_setup_point(struct lp_setup_context *setup,
+ const float (*v0)[4])
{
if (!try_setup_point( setup, v0 ))
{
--
cgit v1.2.3
From 57bf96b43be2abcbadc387d7b5466b772125a093 Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck
Date: Sun, 19 Sep 2010 10:06:34 +0200
Subject: r600g: Honour destination operand's writemask in the SCS
implementation.
If we are not going to write to the X or Y components of the destination
vector we also don't need to prepare to compute SIN or COS.
Signed-off-by: Tilman Sauerbeck
---
src/gallium/drivers/r600/r600_shader.c | 61 +++++++++++++++++++---------------
1 file changed, 35 insertions(+), 26 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index bce5297313..523b6d2451 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -926,38 +926,47 @@ static int tgsi_scs(struct r600_shader_ctx *ctx)
struct r600_bc_alu alu;
int r;
- r = tgsi_setup_trig(ctx, r600_src);
- if (r)
- return r;
-
+ /* We'll only need the trig stuff if we are going to write to the
+ * X or Y components of the destination vector.
+ */
+ if (likely(inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_XY)) {
+ r = tgsi_setup_trig(ctx, r600_src);
+ if (r)
+ return r;
+ }
/* dst.x = COS */
- memset(&alu, 0, sizeof(struct r600_bc_alu));
- alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS);
- r = tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
- if (r)
- return r;
+ if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) {
+ memset(&alu, 0, sizeof(struct r600_bc_alu));
+ alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS);
+ r = tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
+ if (r)
+ return r;
- alu.src[0].sel = ctx->temp_reg;
- alu.src[0].chan = 0;
- alu.last = 1;
- r = r600_bc_add_alu(ctx->bc, &alu);
- if (r)
- return r;
+ alu.src[0].sel = ctx->temp_reg;
+ alu.src[0].chan = 0;
+ alu.last = 1;
+ r = r600_bc_add_alu(ctx->bc, &alu);
+ if (r)
+ return r;
+ }
/* dst.y = SIN */
- memset(&alu, 0, sizeof(struct r600_bc_alu));
- alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN);
- r = tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
- if (r)
- return r;
+ if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) {
+ memset(&alu, 0, sizeof(struct r600_bc_alu));
+ alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN);
+ r = tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
+ if (r)
+ return r;
+
+ alu.src[0].sel = ctx->temp_reg;
+ alu.src[0].chan = 0;
+ alu.last = 1;
+ r = r600_bc_add_alu(ctx->bc, &alu);
+ if (r)
+ return r;
+ }
- alu.src[0].sel = ctx->temp_reg;
- alu.src[0].chan = 0;
- alu.last = 1;
- r = r600_bc_add_alu(ctx->bc, &alu);
- if (r)
- return r;
return 0;
}
--
cgit v1.2.3
From b7a5eac1f3723a369885bad369a04c456bdf1565 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 13:26:27 -0600
Subject: llvmpipe: clean-up, comments in setup_point_coefficient()
---
src/gallium/drivers/llvmpipe/lp_setup_point.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index 5521cbbe87..fb4fb2c436 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -152,6 +152,7 @@ setup_point_coefficients( struct lp_setup_context *setup,
struct lp_rast_triangle *point,
const struct point_info *info)
{
+ const struct lp_fragment_shader *shader = setup->fs.current.variant->shader;
unsigned fragcoord_usage_mask = TGSI_WRITEMASK_XYZ;
unsigned slot;
@@ -172,12 +173,16 @@ setup_point_coefficients( struct lp_setup_context *setup,
fragcoord_usage_mask |= usage_mask;
break;
+ case LP_INTERP_LINEAR:
+ /* Sprite tex coords may use linear interpolation someday */
+ /* fall-through */
+
case LP_INTERP_PERSPECTIVE:
- /* For point sprite textures */
- if (setup->fs.current.variant->shader->info.input_semantic_name[slot]
- == TGSI_SEMANTIC_GENERIC)
- {
- int index = setup->fs.current.variant->shader->info.input_semantic_index[slot];
+ /* check if the sprite coord flag is set for this attribute.
+ * If so, set it up so it up so x any y vary from 0 to 1.
+ */
+ if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_GENERIC) {
+ const int index = shader->info.input_semantic_index[slot];
if (setup->sprite & (1 << index)) {
for (i = 0; i < NUM_CHANNELS; i++)
--
cgit v1.2.3
From ef419599d9b18de2a9077c5f0a7f02bfc11d1762 Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck
Date: Mon, 20 Sep 2010 21:27:59 +0200
Subject: r600g: Implemented the Z and W component write for the SCS opcode.
Signed-off-by: Tilman Sauerbeck
---
src/gallium/drivers/r600/r600_shader.c | 49 ++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 523b6d2451..1702475fa3 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -967,6 +967,55 @@ static int tgsi_scs(struct r600_shader_ctx *ctx)
return r;
}
+ /* dst.z = 0.0; */
+ if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) {
+ fprintf(stderr, "writing z\n");
+ memset(&alu, 0, sizeof(struct r600_bc_alu));
+
+ alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+
+ r = tgsi_dst(ctx, &inst->Dst[0], 2, &alu.dst);
+ if (r)
+ return r;
+
+ alu.src[0].sel = V_SQ_ALU_SRC_0;
+ alu.src[0].chan = 0;
+
+ alu.last = 1;
+
+ r = r600_bc_add_alu(ctx->bc, &alu);
+ if (r)
+ return r;
+
+ r = r600_bc_add_literal(ctx->bc, ctx->value);
+ if (r)
+ return r;
+ }
+
+ /* dst.w = 1.0; */
+ if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) {
+ memset(&alu, 0, sizeof(struct r600_bc_alu));
+
+ alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
+
+ r = tgsi_dst(ctx, &inst->Dst[0], 3, &alu.dst);
+ if (r)
+ return r;
+
+ alu.src[0].sel = V_SQ_ALU_SRC_1;
+ alu.src[0].chan = 0;
+
+ alu.last = 1;
+
+ r = r600_bc_add_alu(ctx->bc, &alu);
+ if (r)
+ return r;
+
+ r = r600_bc_add_literal(ctx->bc, ctx->value);
+ if (r)
+ return r;
+ }
+
return 0;
}
--
cgit v1.2.3
From c3982c6bcdeb88f7fb1b20f8bd300db31cd7288d Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 13:29:55 -0600
Subject: llvmpipe: rename sprite field, add sprite_coord_origin
---
src/gallium/drivers/llvmpipe/lp_setup.c | 6 ++++--
src/gallium/drivers/llvmpipe/lp_setup.h | 3 ++-
src/gallium/drivers/llvmpipe/lp_setup_context.h | 2 +-
src/gallium/drivers/llvmpipe/lp_setup_point.c | 2 +-
src/gallium/drivers/llvmpipe/lp_state_rasterizer.c | 3 ++-
5 files changed, 10 insertions(+), 6 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 6674d281d1..ea7002aafc 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -490,12 +490,14 @@ void
lp_setup_set_point_state( struct lp_setup_context *setup,
float point_size,
boolean point_size_per_vertex,
- uint sprite)
+ uint sprite_coord_enable,
+ uint sprite_coord_origin)
{
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
setup->point_size = point_size;
- setup->sprite = sprite;
+ setup->sprite_coord_enable = sprite_coord_enable;
+ setup->sprite_coord_origin = sprite_coord_origin;
setup->point_size_per_vertex = point_size_per_vertex;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h
index b94061b7d4..81ff43f8ad 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup.h
@@ -107,7 +107,8 @@ void
lp_setup_set_point_state( struct lp_setup_context *setup,
float point_size,
boolean point_size_per_vertex,
- uint sprite);
+ uint sprite_coord_enable,
+ uint sprite_coord_origin);
void
lp_setup_set_fs_inputs( struct lp_setup_context *setup,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index 80b356476a..8506ed2dc9 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -73,7 +73,7 @@ struct lp_setup_context
uint prim;
uint vertex_size;
uint nr_vertices;
- uint sprite;
+ uint sprite_coord_enable, sprite_coord_origin;
uint vertex_buffer_size;
void *vertex_buffer;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index fb4fb2c436..f8f411f4f1 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -184,7 +184,7 @@ setup_point_coefficients( struct lp_setup_context *setup,
if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_GENERIC) {
const int index = shader->info.input_semantic_index[slot];
- if (setup->sprite & (1 << index)) {
+ if (setup->sprite_coord_enable & (1 << index)) {
for (i = 0; i < NUM_CHANNELS; i++)
if (usage_mask & (1 << i))
perspective_coef(setup, point, info, slot+1, vert_attr, i);
diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index b81c2cfd15..dbd73812e4 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -78,7 +78,8 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
lp_setup_set_point_state( llvmpipe->setup,
llvmpipe->rasterizer->point_size,
llvmpipe->rasterizer->point_size_per_vertex,
- llvmpipe->rasterizer->sprite_coord_enable);
+ llvmpipe->rasterizer->sprite_coord_enable,
+ llvmpipe->rasterizer->sprite_coord_mode);
}
llvmpipe->dirty |= LP_NEW_RASTERIZER;
--
cgit v1.2.3
From 021e68b2cdc9a675887dac33689d5ffe244d8f9a Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck
Date: Sun, 19 Sep 2010 19:25:21 +0200
Subject: python/tests: Fixed tri.py for API and TGSI syntax changes.
Signed-off-by: Tilman Sauerbeck
---
src/gallium/tests/python/samples/tri.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/tests/python/samples/tri.py b/src/gallium/tests/python/samples/tri.py
index fed929d420..6d17c88c05 100644
--- a/src/gallium/tests/python/samples/tri.py
+++ b/src/gallium/tests/python/samples/tri.py
@@ -88,8 +88,8 @@ def test(dev):
# rasterizer
rasterizer = Rasterizer()
- rasterizer.front_winding = PIPE_WINDING_CW
- rasterizer.cull_mode = PIPE_WINDING_NONE
+ rasterizer.front_ccw = False
+ rasterizer.cull_face = PIPE_FACE_NONE
rasterizer.scissor = 1
ctx.set_rasterizer(rasterizer)
@@ -161,8 +161,8 @@ def test(dev):
# vertex shader
vs = Shader('''
VERT
- DCL IN[0], POSITION, CONSTANT
- DCL IN[1], COLOR, CONSTANT
+ DCL IN[0]
+ DCL IN[1]
DCL OUT[0], POSITION, CONSTANT
DCL OUT[1], COLOR, CONSTANT
0:MOV OUT[0], IN[0]
--
cgit v1.2.3
From 61fcd9aaa2bf91eb400eeb4df2ab2c7e48b3bb6c Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 13:48:02 -0600
Subject: llvmpipe: implement sprite coord origin modes
---
src/gallium/drivers/llvmpipe/lp_setup_point.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index f8f411f4f1..bb6b88069b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -71,7 +71,8 @@ perspective_coef(struct lp_setup_context *setup,
const struct point_info *info,
unsigned slot,
unsigned vert_attr,
- unsigned i)
+ unsigned i,
+ unsigned sprite_coord_origin)
{
if (i == 0) {
float dadx = FIXED_ONE / (float)info->dx12;
@@ -83,14 +84,18 @@ perspective_coef(struct lp_setup_context *setup,
dady * ((float)info->v0[0][1] - setup->pixel_offset)));
}
else if (i == 1) {
- float dadx = 0.0f;
- float dady = FIXED_ONE / (float)info->dx12;
+ float dadx = 0.0f;
+ float dady = FIXED_ONE / (float)info->dx12;
+
+ if (sprite_coord_origin == PIPE_SPRITE_COORD_LOWER_LEFT) {
+ dady = -dady;
+ }
point->inputs.dadx[slot][i] = dadx;
point->inputs.dady[slot][i] = dady;
point->inputs.a0[slot][i] = (0.5 -
- (dadx * ((float)info->v0[0][0] - setup->pixel_offset) +
- dady * ((float)info->v0[0][1] - setup->pixel_offset)));
+ (dadx * ((float)info->v0[0][0] - setup->pixel_offset) +
+ dady * ((float)info->v0[0][1] - setup->pixel_offset)));
}
else if (i == 2) {
point->inputs.a0[slot][i] = 0.0f;
@@ -187,7 +192,8 @@ setup_point_coefficients( struct lp_setup_context *setup,
if (setup->sprite_coord_enable & (1 << index)) {
for (i = 0; i < NUM_CHANNELS; i++)
if (usage_mask & (1 << i))
- perspective_coef(setup, point, info, slot+1, vert_attr, i);
+ perspective_coef(setup, point, info, slot+1, vert_attr, i,
+ setup->sprite_coord_origin);
fragcoord_usage_mask |= TGSI_WRITEMASK_W;
break;
}
--
cgit v1.2.3
From 0f099f2906773690210661fb533e207626dc8e40 Mon Sep 17 00:00:00 2001
From: Jerome Glisse
Date: Mon, 20 Sep 2010 15:35:19 -0400
Subject: r600g: use pipe context for flushing inside map
This allow to share code path btw old & new, also
remove check on reference this might make things
a little slower but new design doesn't use reference
stuff.
Signed-off-by: Jerome Glisse
---
src/gallium/drivers/r600/r600_buffer.c | 2 +-
src/gallium/drivers/r600/r600_context.c | 21 ++++++++++++++-------
src/gallium/drivers/r600/r600_query.c | 2 +-
src/gallium/drivers/r600/r600_shader.c | 2 +-
src/gallium/drivers/r600/r600_state2.c | 3 +++
src/gallium/drivers/r600/r600_texture.c | 2 +-
src/gallium/drivers/r600/radeon.h | 1 -
src/gallium/winsys/r600/drm/radeon_bo_pb.c | 14 +++++++-------
8 files changed, 28 insertions(+), 19 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c
index dc3fc812e1..ea370782fd 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -171,7 +171,7 @@ static void *r600_buffer_transfer_map(struct pipe_context *pipe,
if (transfer->usage & PIPE_TRANSFER_WRITE) {
write = 1;
}
- data = radeon_ws_bo_map(rscreen->rw, rbuffer->r.bo, transfer->usage, rctx);
+ data = radeon_ws_bo_map(rscreen->rw, rbuffer->r.bo, transfer->usage, pipe);
if (!data)
return NULL;
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 72aab91d04..7a63d966eb 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -69,6 +69,10 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
{
struct r600_context *rctx = r600_context(ctx);
struct r600_query *rquery = NULL;
+#if 0
+ static int dc = 0;
+ char dname[256];
+#endif
/* flush upload buffers */
u_upload_flush(rctx->upload_vb);
@@ -77,6 +81,16 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
/* suspend queries */
r600_queries_suspend(ctx);
+
+#if 0
+ sprintf(dname, "gallium-%08d.bof", dc);
+ if (dc < 2) {
+ radeon_ctx_dump_bof(rctx->ctx, dname);
+ R600_ERR("dumped %s\n", dname);
+ }
+ dc++;
+#endif
+
radeon_ctx_submit(rctx->ctx);
LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
@@ -88,13 +102,6 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
r600_queries_resume(ctx);
}
-void r600_flush_ctx(void *data)
-{
- struct r600_context *rctx = data;
-
- rctx->context.flush(&rctx->context, 0, NULL);
-}
-
struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
{
struct r600_context *rctx = CALLOC_STRUCT(r600_context);
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index 023b09ef65..6e50701de6 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -108,7 +108,7 @@ static void r600_query_result(struct pipe_context *ctx, struct r600_query *rquer
u32 *results;
int i;
- results = radeon_ws_bo_map(rscreen->rw, rquery->buffer, 0, r600_context(ctx));
+ results = radeon_ws_bo_map(rscreen->rw, rquery->buffer, 0, ctx);
for (i = 0; i < rquery->num_results; i += 4) {
start = (u64)results[i] | (u64)results[i + 1] << 32;
end = (u64)results[i + 2] | (u64)results[i + 3] << 32;
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 1702475fa3..e1e2891b6e 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -167,7 +167,7 @@ static int r600_pipe_shader(struct pipe_context *ctx, struct r600_context_state
if (rpshader->bo == NULL) {
return -ENOMEM;
}
- data = radeon_ws_bo_map(rscreen->rw, rpshader->bo, 0, rctx);
+ data = radeon_ws_bo_map(rscreen->rw, rpshader->bo, 0, ctx);
memcpy(data, rshader->bc.bytecode, rshader->bc.ndw * 4);
radeon_ws_bo_unmap(rscreen->rw, rpshader->bo);
/* build state */
diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c
index ffb18ab7fb..5269e6db91 100644
--- a/src/gallium/drivers/r600/r600_state2.c
+++ b/src/gallium/drivers/r600/r600_state2.c
@@ -1600,6 +1600,9 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
/* unreference old buffer and reference new one */
rstate->id = R600_PIPE_STATE_FRAMEBUFFER;
for (int i = 0; i < rctx->framebuffer.nr_cbufs; i++) {
+ pipe_surface_reference(&rctx->framebuffer.cbufs[i], NULL);
+ }
+ for (int i = 0; i < state->nr_cbufs; i++) {
pipe_surface_reference(&rctx->framebuffer.cbufs[i], state->cbufs[i]);
}
pipe_surface_reference(&rctx->framebuffer.zsbuf, state->zsbuf);
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 6633258090..abfe406402 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -346,7 +346,7 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
- map = radeon_ws_bo_map(radeon, bo, 0, r600_context(ctx));
+ map = radeon_ws_bo_map(radeon, bo, 0, ctx);
if (!map) {
return NULL;
}
diff --git a/src/gallium/drivers/r600/radeon.h b/src/gallium/drivers/r600/radeon.h
index e52dcb4a34..a7e7982c19 100644
--- a/src/gallium/drivers/r600/radeon.h
+++ b/src/gallium/drivers/r600/radeon.h
@@ -221,5 +221,4 @@ enum r600_stype {
#define R600_QUERY_SIZE 1
#define R600_QUERY_PM4 128
-void r600_flush_ctx(void *data);
#endif
diff --git a/src/gallium/winsys/r600/drm/radeon_bo_pb.c b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
index 93dc927aba..148cf6d81d 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo_pb.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
@@ -53,7 +53,9 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
unsigned flags, void *ctx)
{
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
+ struct pipe_context *pctx = ctx;
+//printf("%s:%d ************************************************\n", __func__, __LINE__);
if (flags & PB_USAGE_UNSYNCHRONIZED) {
if (!buf->bo->data && radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
@@ -62,13 +64,11 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
return buf->bo->data;
}
- if (p_atomic_read(&buf->bo->reference.count) > 1) {
- if (flags & PB_USAGE_DONTBLOCK) {
- return NULL;
- }
- if (ctx) {
- r600_flush_ctx(ctx);
- }
+ if (flags & PB_USAGE_DONTBLOCK) {
+ return NULL;
+ }
+ if (ctx) {
+ pctx->flush(pctx, 0, NULL);
}
if (flags & PB_USAGE_DONTBLOCK) {
--
cgit v1.2.3
From a7ea4d11fb5a2a39daaad8752706291ac93013f7 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 13:48:29 -0600
Subject: draw: fix test for using the wide-point stage
As it was, we weren't obeying the draw->pipeline.point_sprite state.
Fixes point sprites in llvmpipe driver.
---
src/gallium/auxiliary/draw/draw_pipe_validate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c
index 8b92543987..c575a8ac7c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_validate.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c
@@ -172,7 +172,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
wide_lines = (rast->line_width > draw->pipeline.wide_line_threshold
&& !rast->line_smooth);
- /* drawing large points? */
+ /* drawing large/sprite points (but not AA points)? */
if (rast->sprite_coord_enable && draw->pipeline.point_sprite)
wide_points = TRUE;
else if (rast->point_smooth && draw->pipeline.aapoint)
@@ -207,7 +207,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
precalc_flat = TRUE;
}
- if (wide_points || rast->sprite_coord_enable) {
+ if (wide_points) {
draw->pipeline.wide_point->next = next;
next = draw->pipeline.wide_point;
}
--
cgit v1.2.3
From 4fc5050f82a6b59a86370f44c64e7592ff621f6f Mon Sep 17 00:00:00 2001
From: Jerome Glisse
Date: Mon, 20 Sep 2010 17:21:37 -0400
Subject: r600g: add back reference check when mapping buffer
Signed-off-by: Jerome Glisse
---
src/gallium/targets/dri-r600/target.c | 2 +-
src/gallium/winsys/r600/drm/radeon_bo_pb.c | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/targets/dri-r600/target.c b/src/gallium/targets/dri-r600/target.c
index eb268d5bc0..2c1b2f5be4 100644
--- a/src/gallium/targets/dri-r600/target.c
+++ b/src/gallium/targets/dri-r600/target.c
@@ -4,7 +4,7 @@
#include "r600/drm/r600_drm_public.h"
#include "r600/r600_public.h"
-#if 1
+#if 0
static struct pipe_screen *
create_screen(int fd)
{
diff --git a/src/gallium/winsys/r600/drm/radeon_bo_pb.c b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
index 148cf6d81d..897938c2ca 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo_pb.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo_pb.c
@@ -55,7 +55,6 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
struct pipe_context *pctx = ctx;
-//printf("%s:%d ************************************************\n", __func__, __LINE__);
if (flags & PB_USAGE_UNSYNCHRONIZED) {
if (!buf->bo->data && radeon_bo_map(buf->mgr->radeon, buf->bo)) {
return NULL;
@@ -64,11 +63,13 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
return buf->bo->data;
}
- if (flags & PB_USAGE_DONTBLOCK) {
- return NULL;
- }
- if (ctx) {
- pctx->flush(pctx, 0, NULL);
+ if (p_atomic_read(&buf->bo->reference.count) > 1) {
+ if (flags & PB_USAGE_DONTBLOCK) {
+ return NULL;
+ }
+ if (ctx) {
+ pctx->flush(pctx, 0, NULL);
+ }
}
if (flags & PB_USAGE_DONTBLOCK) {
--
cgit v1.2.3
From 1662c317032cf280701d7e55b028b7f0dc8afc65 Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 15:33:49 -0600
Subject: llvmpipe: check bitshift against PIPE_MAX_SHADER_OUTPUTS
---
src/gallium/drivers/llvmpipe/lp_setup_point.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index bb6b88069b..774a3c80da 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -188,8 +188,11 @@ setup_point_coefficients( struct lp_setup_context *setup,
*/
if (shader->info.input_semantic_name[slot] == TGSI_SEMANTIC_GENERIC) {
const int index = shader->info.input_semantic_index[slot];
-
- if (setup->sprite_coord_enable & (1 << index)) {
+ /* Note that sprite_coord enable is a bitfield of
+ * PIPE_MAX_SHADER_OUTPUTS bits.
+ */
+ if (index < PIPE_MAX_SHADER_OUTPUTS &&
+ (setup->sprite_coord_enable & (1 << index))) {
for (i = 0; i < NUM_CHANNELS; i++)
if (usage_mask & (1 << i))
perspective_coef(setup, point, info, slot+1, vert_attr, i,
--
cgit v1.2.3
From 77af10955462819d973a395270777c5b8217f6ae Mon Sep 17 00:00:00 2001
From: Brian Paul
Date: Mon, 20 Sep 2010 15:34:02 -0600
Subject: draw: check bitshift against PIPE_MAX_SHADER_OUTPUS
---
src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index 40843c58c2..3646c6a714 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -237,7 +237,11 @@ widepoint_first_point(struct draw_stage *stage,
for (i = 0; i < fs->info.num_inputs; i++) {
if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
const int generic_index = fs->info.input_semantic_index[i];
- if (rast->sprite_coord_enable & (1 << generic_index)) {
+ /* Note that sprite_coord enable is a bitfield of
+ * PIPE_MAX_SHADER_OUTPUTS bits.
+ */
+ if (generic_index < PIPE_MAX_SHADER_OUTPUTS &&
+ (rast->sprite_coord_enable & (1 << generic_index))) {
/* OK, this generic attribute needs to be replaced with a
* texcoord (see above).
*/
--
cgit v1.2.3
From c66f0c46297996613fa8271925e37e594cf5d16b Mon Sep 17 00:00:00 2001
From: José Fonseca
Date: Tue, 21 Sep 2010 02:16:19 +0200
Subject: tgsi: Don't ignore indirect registers in tgsi_check_soa_dependencies
NOTE: This is a candidate for the 7.9 branch.
---
src/gallium/auxiliary/tgsi/tgsi_exec.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 0757f05dfa..3a71540506 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -605,8 +605,10 @@ tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst)
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
if ((inst->Src[i].Register.File ==
inst->Dst[0].Register.File) &&
- (inst->Src[i].Register.Index ==
- inst->Dst[0].Register.Index)) {
+ ((inst->Src[i].Register.Index ==
+ inst->Dst[0].Register.Index) ||
+ inst->Src[i].Register.Indirect ||
+ inst->Dst[0].Register.Indirect)) {
/* loop over dest channels */
uint channelsWritten = 0x0;
FOR_EACH_ENABLED_CHANNEL(*inst, chan) {
--
cgit v1.2.3
From d21301675c249602e19310d5b62fad424f2f2ac2 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz
Date: Tue, 21 Sep 2010 02:16:31 +0200
Subject: tgsi: Actually care what check_soa_dependencies says
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Thanks to José for the more complete list of supported opcodes.
NOTE: This is a candidate for the 7.9 branch.
---
src/gallium/auxiliary/tgsi/tgsi_sse2.c | 56 +++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 17 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 13e2e8eb99..83a6d75896 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -2830,31 +2830,53 @@ static void soa_to_aos( struct x86_function *func,
* Check if the instructions dst register is the same as any src
* register and warn if there's a posible SOA dependency.
*/
-static void
+static boolean
check_soa_dependencies(const struct tgsi_full_instruction *inst)
{
- switch (inst->Instruction.Opcode) {
+ uint opcode = inst->Instruction.Opcode;
+
+ /* XXX: we only handle src/dst aliasing in a few opcodes currently.
+ * Need to use an additional temporay to hold the result in the
+ * cases where the code is too opaque to fix.
+ */
+
+ switch (opcode) {
case TGSI_OPCODE_ADD:
case TGSI_OPCODE_MOV:
case TGSI_OPCODE_MUL:
case TGSI_OPCODE_XPD:
+ case TGSI_OPCODE_RCP:
+ case TGSI_OPCODE_RSQ:
+ case TGSI_OPCODE_EXP:
+ case TGSI_OPCODE_LOG:
+ case TGSI_OPCODE_DP3:
+ case TGSI_OPCODE_DP4:
+ case TGSI_OPCODE_DP2A:
+ case TGSI_OPCODE_EX2:
+ case TGSI_OPCODE_LG2:
+ case TGSI_OPCODE_POW:
+ case TGSI_OPCODE_XPD:
+ case TGSI_OPCODE_DPH:
+ case TGSI_OPCODE_COS:
+ case TGSI_OPCODE_SIN:
+ case TGSI_OPCODE_TEX:
+ case TGSI_OPCODE_TXB:
+ case TGSI_OPCODE_TXP:
+ case TGSI_OPCODE_NRM:
+ case TGSI_OPCODE_NRM4:
+ case TGSI_OPCODE_DP2:
/* OK - these opcodes correctly handle SOA dependencies */
- break;
+ return TRUE;
default:
- if (tgsi_check_soa_dependencies(inst)) {
- uint opcode = inst->Instruction.Opcode;
+ if (!tgsi_check_soa_dependencies(inst))
+ return TRUE;
- /* XXX: we only handle src/dst aliasing in a few opcodes
- * currently. Need to use an additional temporay to hold
- * the result in the cases where the code is too opaque to
- * fix.
- */
- if (opcode != TGSI_OPCODE_MOV) {
- debug_printf("Warning: src/dst aliasing in instruction"
- " is not handled:\n");
- tgsi_dump_instruction(inst, 1);
- }
- }
+ debug_printf("Warning: src/dst aliasing in instruction"
+ " is not handled:\n");
+ debug_printf("Warning: ");
+ tgsi_dump_instruction(inst, 1);
+
+ return FALSE;
}
}
@@ -2954,7 +2976,7 @@ tgsi_emit_sse2(
tgsi_get_processor_name(proc));
}
- check_soa_dependencies(&parse.FullToken.FullInstruction);
+ ok = check_soa_dependencies(&parse.FullToken.FullInstruction);
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
--
cgit v1.2.3
From 2491258436a9c404f177c861101f7bcefc8fffb3 Mon Sep 17 00:00:00 2001
From: Vinson Lee
Date: Mon, 20 Sep 2010 18:20:04 -0700
Subject: tgsi: Remove duplicate case value.
---
src/gallium/auxiliary/tgsi/tgsi_sse2.c | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 83a6d75896..67deffbd11 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -2844,7 +2844,6 @@ check_soa_dependencies(const struct tgsi_full_instruction *inst)
case TGSI_OPCODE_ADD:
case TGSI_OPCODE_MOV:
case TGSI_OPCODE_MUL:
- case TGSI_OPCODE_XPD:
case TGSI_OPCODE_RCP:
case TGSI_OPCODE_RSQ:
case TGSI_OPCODE_EXP:
--
cgit v1.2.3
From 8e8b60588b37e2d9cce7c0c04cdae73ce8206d09 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Tue, 21 Sep 2010 11:24:49 +1000
Subject: r600g: deal with overflow of VTX/TEX CF clauses.
running piglit's texrect-many caused the vtx to overflow.
---
src/gallium/drivers/r600/r600_asm.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c
index 8c01987318..dcb1b4fccc 100644
--- a/src/gallium/drivers/r600/r600_asm.c
+++ b/src/gallium/drivers/r600/r600_asm.c
@@ -531,7 +531,8 @@ int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx)
/* cf can contains only alu or only vtx or only tex */
if (bc->cf_last == NULL ||
(bc->cf_last->inst != V_SQ_CF_WORD1_SQ_CF_INST_VTX &&
- bc->cf_last->inst != V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC)) {
+ bc->cf_last->inst != V_SQ_CF_WORD1_SQ_CF_INST_VTX_TC) ||
+ bc->force_add_cf) {
r = r600_bc_add_cf(bc);
if (r) {
free(nvtx);
@@ -543,6 +544,8 @@ int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx)
/* each fetch use 4 dwords */
bc->cf_last->ndw += 4;
bc->ndw += 4;
+ if ((bc->ndw / 4) > 7)
+ bc->force_add_cf = 1;
return 0;
}
@@ -557,7 +560,8 @@ int r600_bc_add_tex(struct r600_bc *bc, const struct r600_bc_tex *tex)
/* cf can contains only alu or only vtx or only tex */
if (bc->cf_last == NULL ||
- bc->cf_last->inst != V_SQ_CF_WORD1_SQ_CF_INST_TEX) {
+ bc->cf_last->inst != V_SQ_CF_WORD1_SQ_CF_INST_TEX ||
+ bc->force_add_cf) {
r = r600_bc_add_cf(bc);
if (r) {
free(ntex);
@@ -569,6 +573,8 @@ int r600_bc_add_tex(struct r600_bc *bc, const struct r600_bc_tex *tex)
/* each texture fetch use 4 dwords */
bc->cf_last->ndw += 4;
bc->ndw += 4;
+ if ((bc->ndw / 4) > 7)
+ bc->force_add_cf = 1;
return 0;
}
--
cgit v1.2.3
From 84997cd5663a2f528c1c8b2c1f7329d546c087be Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Tue, 21 Sep 2010 11:32:15 +1000
Subject: r600g: set back to correct codepaths.
Jerome please use git diff and git show before pushing.
---
src/gallium/targets/dri-r600/target.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/targets/dri-r600/target.c b/src/gallium/targets/dri-r600/target.c
index 2c1b2f5be4..eb268d5bc0 100644
--- a/src/gallium/targets/dri-r600/target.c
+++ b/src/gallium/targets/dri-r600/target.c
@@ -4,7 +4,7 @@
#include "r600/drm/r600_drm_public.h"
#include "r600/r600_public.h"
-#if 0
+#if 1
static struct pipe_screen *
create_screen(int fd)
{
--
cgit v1.2.3
From b6ced8ee7b2c86e94fd7467d12aca5e322048ba4 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Tue, 21 Sep 2010 19:57:15 +1000
Subject: r600g: fixup evergreen miptree setup.
eg seems to have a higher pitch aligmment requirement and uses r700 cube setup
this fixes a couple of piglit tests here.
---
src/gallium/drivers/r600/r600_texture.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index abfe406402..f60fe9f316 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -84,10 +84,13 @@ static void r600_setup_miptree(struct r600_resource_texture *rtex, enum chip_cla
h = u_minify(ptex->height0, i);
h = util_next_power_of_two(h);
pitch = util_format_get_stride(ptex->format, align(w, 64));
- pitch = align(pitch, 256);
+ if (chipc == EVERGREEN)
+ pitch = align(pitch, 512);
+ else
+ pitch = align(pitch, 256);
layer_size = pitch * h;
if (ptex->target == PIPE_TEXTURE_CUBE) {
- if (chipc == R700)
+ if (chipc >= R700)
size = layer_size * 8;
else
size = layer_size * 6;
--
cgit v1.2.3
From 88934273776242878dbaabdae25a7027fdeaff05 Mon Sep 17 00:00:00 2001
From: Dave Airlie
Date: Tue, 21 Sep 2010 19:57:58 +1000
Subject: r600g: fix eg texture borders.
texture border regs are indexed on evergreen.
---
src/gallium/drivers/r600/eg_hw_states.c | 1 +
src/gallium/drivers/r600/eg_states_inc.h | 33 +++++++++++++++++---------------
src/gallium/winsys/r600/drm/eg_states.h | 27 ++++++++++++++------------
src/gallium/winsys/r600/drm/r600_state.c | 2 +-
4 files changed, 35 insertions(+), 28 deletions(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/eg_hw_states.c b/src/gallium/drivers/r600/eg_hw_states.c
index 1d3a3e11c1..3d10095919 100644
--- a/src/gallium/drivers/r600/eg_hw_states.c
+++ b/src/gallium/drivers/r600/eg_hw_states.c
@@ -471,6 +471,7 @@ static void eg_sampler_border(struct r600_context *rctx, struct radeon_state *rs
radeon_state_init(rstate, rscreen->rw, R600_STATE_SAMPLER_BORDER, id, R600_SHADER_PS);
if (uc.ui) {
+ rstate->states[EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_INDEX] = id;
rstate->states[EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_RED] = fui(state->border_color[0]);
rstate->states[EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_GREEN] = fui(state->border_color[1]);
rstate->states[EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_BLUE] = fui(state->border_color[2]);
diff --git a/src/gallium/drivers/r600/eg_states_inc.h b/src/gallium/drivers/r600/eg_states_inc.h
index 462f31cc79..9f8007c8e9 100644
--- a/src/gallium/drivers/r600/eg_states_inc.h
+++ b/src/gallium/drivers/r600/eg_states_inc.h
@@ -368,27 +368,30 @@
#define EG_GS_SAMPLER_PM4 128
/* EG_PS_SAMPLER_BORDER */
-#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_RED 0
-#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_GREEN 1
-#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_BLUE 2
-#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_ALPHA 3
-#define EG_PS_SAMPLER_BORDER_SIZE 4
+#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_INDEX 0
+#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_RED 1
+#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_GREEN 2
+#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_BLUE 3
+#define EG_PS_SAMPLER_BORDER__TD_PS_SAMPLER0_BORDER_ALPHA 4
+#define EG_PS_SAMPLER_BORDER_SIZE 5
#define EG_PS_SAMPLER_BORDER_PM4 128
/* EG_VS_SAMPLER_BORDER */
-#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_RED 0
-#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_GREEN 1
-#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_BLUE 2
-#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_ALPHA 3
-#define EG_VS_SAMPLER_BORDER_SIZE 4
+#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_INDEX 0
+#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_RED 1
+#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_GREEN 2
+#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_BLUE 3
+#define EG_VS_SAMPLER_BORDER__TD_VS_SAMPLER0_BORDER_ALPHA 4
+#define EG_VS_SAMPLER_BORDER_SIZE 5
#define EG_VS_SAMPLER_BORDER_PM4 128
/* EG_GS_SAMPLER_BORDER */
-#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_RED 0
-#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_GREEN 1
-#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_BLUE 2
-#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_ALPHA 3
-#define EG_GS_SAMPLER_BORDER_SIZE 4
+#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_INDEX 0
+#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_RED 1
+#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_GREEN 2
+#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_BLUE 3
+#define EG_GS_SAMPLER_BORDER__TD_GS_SAMPLER0_BORDER_ALPHA 4
+#define EG_GS_SAMPLER_BORDER_SIZE 5
#define EG_GS_SAMPLER_BORDER_PM4 128
/* EG_CB */
diff --git a/src/gallium/winsys/r600/drm/eg_states.h b/src/gallium/winsys/r600/drm/eg_states.h
index c26ba6c6cd..518e05fefb 100644
--- a/src/gallium/winsys/r600/drm/eg_states.h
+++ b/src/gallium/winsys/r600/drm/eg_states.h
@@ -371,24 +371,27 @@ static const struct radeon_register EG_names_GS_SAMPLER[] = {
};
static const struct radeon_register EG_names_PS_SAMPLER_BORDER[] = {
- {0x0000A400, 0, 0, "TD_PS_SAMPLER0_BORDER_RED"},
- {0x0000A404, 0, 0, "TD_PS_SAMPLER0_BORDER_GREEN"},
- {0x0000A408, 0, 0, "TD_PS_SAMPLER0_BORDER_BLUE"},
- {0x0000A40C, 0, 0, "TD_PS_SAMPLER0_BORDER_ALPHA"},
+ {0x0000A400, 0, 0, "TD_PS_SAMPLER0_BORDER_INDEX"},
+ {0x0000A404, 0, 0, "TD_PS_SAMPLER0_BORDER_RED"},
+ {0x0000A408, 0, 0, "TD_PS_SAMPLER0_BORDER_GREEN"},
+ {0x0000A40C, 0, 0, "TD_PS_SAMPLER0_BORDER_BLUE"},
+ {0x0000A410, 0, 0, "TD_PS_SAMPLER0_BORDER_ALPHA"},
};
static const struct radeon_register EG_names_VS_SAMPLER_BORDER[] = {
- {0x0000A600, 0, 0, "TD_VS_SAMPLER0_BORDER_RED"},
- {0x0000A604, 0, 0, "TD_VS_SAMPLER0_BORDER_GREEN"},
- {0x0000A608, 0, 0, "TD_VS_SAMPLER0_BORDER_BLUE"},
- {0x0000A60C, 0, 0, "TD_VS_SAMPLER0_BORDER_ALPHA"},
+ {0x0000A414, 0, 0, "TD_VS_SAMPLER0_BORDER_INDEX"},
+ {0x0000A418, 0, 0, "TD_VS_SAMPLER0_BORDER_RED"},
+ {0x0000A41C, 0, 0, "TD_VS_SAMPLER0_BORDER_GREEN"},
+ {0x0000A420, 0, 0, "TD_VS_SAMPLER0_BORDER_BLUE"},
+ {0x0000A424, 0, 0, "TD_VS_SAMPLER0_BORDER_ALPHA"},
};
static const struct radeon_register EG_names_GS_SAMPLER_BORDER[] = {
- {0x0000A800, 0, 0, "TD_GS_SAMPLER0_BORDER_RED"},
- {0x0000A804, 0, 0, "TD_GS_SAMPLER0_BORDER_GREEN"},
- {0x0000A808, 0, 0, "TD_GS_SAMPLER0_BORDER_BLUE"},
- {0x0000A80C, 0, 0, "TD_GS_SAMPLER0_BORDER_ALPHA"},
+ {0x0000A428, 0, 0, "TD_GS_SAMPLER0_BORDER_INDEX"},
+ {0x0000A42C, 0, 0, "TD_GS_SAMPLER0_BORDER_RED"},
+ {0x0000A430, 0, 0, "TD_GS_SAMPLER0_BORDER_GREEN"},
+ {0x0000A434, 0, 0, "TD_GS_SAMPLER0_BORDER_BLUE"},
+ {0x0000A438, 0, 0, "TD_GS_SAMPLER0_BORDER_ALPHA"},
};
static const struct radeon_register EG_names_CB[] = {
diff --git a/src/gallium/winsys/r600/drm/r600_state.c b/src/gallium/winsys/r600/drm/r600_state.c
index a4739021c4..25dd8fe7d8 100644
--- a/src/gallium/winsys/r600/drm/r600_state.c
+++ b/src/gallium/winsys/r600/drm/r600_state.c
@@ -110,7 +110,7 @@ struct radeon_stype_info eg_stypes[] = {
{ R600_STATE_CBUF, 1, 0, r600_state_pm4_shader, { EG_SUB_PS(PS_CBUF), EG_SUB_VS(VS_CBUF) } },
{ R600_STATE_RESOURCE, 176, 0x20, r600_state_pm4_resource, { EG_SUB_PS(PS_RESOURCE), EG_SUB_VS(VS_RESOURCE), EG_SUB_GS(GS_RESOURCE), EG_SUB_FS(FS_RESOURCE)} },
{ R600_STATE_SAMPLER, 18, 0xc, r600_state_pm4_generic, { EG_SUB_PS(PS_SAMPLER), EG_SUB_VS(VS_SAMPLER), EG_SUB_GS(GS_SAMPLER) } },
- { R600_STATE_SAMPLER_BORDER, 18, 0x10, r600_state_pm4_generic, { EG_SUB_PS(PS_SAMPLER_BORDER), EG_SUB_VS(VS_SAMPLER_BORDER), EG_SUB_GS(GS_SAMPLER_BORDER) } },
+ { R600_STATE_SAMPLER_BORDER, 18, 0, r600_state_pm4_generic, { EG_SUB_PS(PS_SAMPLER_BORDER), EG_SUB_VS(VS_SAMPLER_BORDER), EG_SUB_GS(GS_SAMPLER_BORDER) } },
{ R600_STATE_CB0, 11, 0x3c, r600_state_pm4_generic, EG_SUB_NONE(CB) },
{ R600_STATE_QUERY_BEGIN, 1, 0, r600_state_pm4_query_begin, EG_SUB_NONE(VGT_EVENT) },
{ R600_STATE_QUERY_END, 1, 0, r600_state_pm4_query_end, EG_SUB_NONE(VGT_EVENT) },
--
cgit v1.2.3
From 894a307a91d6437ec418800952da2ec174e092f5 Mon Sep 17 00:00:00 2001
From: Tilman Sauerbeck
Date: Tue, 21 Sep 2010 08:13:03 +0200
Subject: r600g: Removed debug code.
Signed-off-by: Tilman Sauerbeck
---
src/gallium/drivers/r600/r600_shader.c | 1 -
1 file changed, 1 deletion(-)
(limited to 'src/gallium')
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index e1e2891b6e..e18c6ce605 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -969,7 +969,6 @@ static int tgsi_scs(struct r600_shader_ctx *ctx)
/* dst.z = 0.0; */
if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) {
- fprintf(stderr, "writing z\n");
memset(&alu, 0, sizeof(struct r600_bc_alu));
alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
--
cgit v1.2.3
From 92617aeac109481258f0c3863d09c1b8903d438b Mon Sep 17 00:00:00 2001
From: Luca Barbieri
Date: Sun, 12 Sep 2010 02:49:36 +0200
Subject: d3d1x: add new Direct3D 10/11 COM state tracker for Gallium
This is a new implementation of the Direct3D 11 COM API for Gallium.
Direct3D 10 and 10.1 implementations are also provided, which are
automatically generated with s/D3D11/D3D10/g plus a bunch of #ifs.
While this is an initial version, most of the code is there (limited
to what Gallium can express), and tri, gears and texturing demos
are working.
The primary goal is to realize Gallium's promise of multiple API
support, and provide an API that can be easily implemented with just
a very thin wrapper over Gallium, instead of the enormous amount of
complex code needed for OpenGL.
The secondary goal is to run Windows Direct3D 10/11 games on Linux
using Wine.
Wine dlls are currently not provided, but adding them should be
quite easy.
Fglrx and nvidia drivers can also be supported by writing a Gallium
driver that talks to them using OpenGL, which is a relatively easy
task.
Thanks to the great design of Direct3D 10/11 and closeness to Gallium,
this approach should not result in detectable overhead, and is the
most maintainable way to do it, providing a path to switch to the
open Gallium drivers once they are on par with the proprietary ones.
Currently Wine has a very limited Direct3D 10 implementation, and
completely lacks a Direct3D 11 implementation.
Note that Direct3D 10/11 are completely different from Direct3D 9
and earlier, and thus warrant a fully separate implementation.
The third goal is to provide a superior alternative to OpenGL for
graphics programming on non-Windows systems, particularly Linux
and other free and open systems.
Thanks to a very clean and well-though design done from scratch,
the Direct3D 10/11 APIs are vastly better than OpenGL and can be
supported with orders of magnitude less code and development time,
as you can see by comparing the lines of code of this commit and
those in the existing Mesa OpenGL implementation.
This would have been true for the Longs Peak proposal as well, but
unfortunately it was abandoned by Khronos, leaving the OpenGL
ecosystem without a graphics API with a modern design.
A binding of Direct3D 10/11 to EGL would solve this issue in the
most economical way possible, and this would be great to provide
in Mesa, since DXGI, the API used to bind Direct3D 10/11 to Windows,
is a bit suboptimal, especially on non-Windows platforms.
Finally, a mature Direct3D 10/11 implementation is intrinsically going
to be faster and more reliable than an OpenGL implementation, thanks
to the dramatically smaller API and the segregation of all nontrivial
work to object creation that the application must perform ahead of
time.
Currently, this commit contains:
- Independently created headers for Direct3D 10, 10.1, 11 and DXGI 1.1,
partially based on the existing Wine headers for D3D10 and DXGI 1.0
- A parser for Direct3D 10/11 DXBC and TokenizedProgramFormat (TPF)
- A shader translator from TokenizedProgramFormat to TGSI
- Implementation of the Direct3D 11 core interfaces
- Automatically generated implementation of Direct3D 10 and 10.1
- Implementation of DXGI using the "native" framework of the EGL st
- Demos, usable either on Windows or on this implementation
- d3d11tri, a clone of tri
- d3d11tex, a (multi)texturing demo
- d3d11gears, an improved version of glxgears
- d3d11spikysphere, a D3D11 tessellation demo (currently Windows-only)
- A downloader for the Microsoft HLSL compiler, needed to recompile
the shaders (compiled shader bytecode is also included)
To compile this, configure at least with these options:
--with-state-trackers=egl,d3d1x --with-egl-platforms=x11
plus some gallium drivers (such as softpipe with --enable-gallium-swrast)
The Wine headers (usually from a wine-dev or wine-devel package) must
be installed.
Only x86-32 has been tested.
You may need to run "make" in the subdirectories of src/gallium/winsys/sw
and you may need to manually run "sudo make install" in
src/gallium/targets/egl
To test it, run the demos in the "progs" directory.
Windows binaries are included to find out how demos should work, and to
test Wine integration when it will be done.
Enjoy, and let me know if you manage to compile and run this, or
which issues you are facing if not.
Using softpipe is recommended for now, and your mileage with hardware
drivers may vary.
However, getting this to work on hardware drivers is also obviously very
important.
Note that currently llvmpipe is buggy and causes all 3 gears to be
drawn with the same color.
Use export GALLIUM_DRIVER=softpipe to avoid this.
Thanks to all the Gallium contributors and especially the VMware
team, whose work made it possible to implement Direct3D 10/11 much
more easily than it would have been otherwise.
---
src/gallium/state_trackers/d3d1x/Makefile | 11 +
src/gallium/state_trackers/d3d1x/Makefile.inc | 19 +
.../state_trackers/d3d1x/d3d1xshader/Makefile | 7 +
.../d3d1x/d3d1xshader/include/dxbc.h | 101 +
.../d3d1x/d3d1xshader/include/le32.h | 45 +
.../state_trackers/d3d1x/d3d1xshader/include/tpf.h | 808 +++++++
.../d3d1x/d3d1xshader/src/dxbc_dump.cpp | 43 +
.../d3d1x/d3d1xshader/src/dxbc_parse.cpp | 93 +
.../d3d1x/d3d1xshader/src/tpf_analyze.cpp | 186 ++
.../d3d1x/d3d1xshader/src/tpf_dump.cpp | 222 ++
.../d3d1x/d3d1xshader/src/tpf_parse.cpp | 424 ++++
.../d3d1x/d3d1xshader/src/tpf_text.cpp | 385 +++
.../state_trackers/d3d1x/d3d1xshader/src/utils.h | 45 +
.../d3d1x/d3d1xshader/tools/fxdis.cpp | 75 +
.../state_trackers/d3d1x/d3d1xstutil/Makefile | 5 +
.../d3d1x/d3d1xstutil/include/d3d1xstutil.h | 1038 ++++++++
.../d3d1x/d3d1xstutil/src/dxgi_enums.cpp | 147 ++
src/gallium/state_trackers/d3d1x/d3dapi/Makefile | 4 +
src/gallium/state_trackers/d3d1x/d3dapi/d3d10.idl | 1554 ++++++++++++
.../state_trackers/d3d1x/d3dapi/d3d10_1.idl | 191 ++
.../state_trackers/d3d1x/d3dapi/d3d10misc.h | 47 +
.../state_trackers/d3d1x/d3dapi/d3d10shader.idl | 269 +++
src/gallium/state_trackers/d3d1x/d3dapi/d3d11.idl | 2492 ++++++++++++++++++++
.../state_trackers/d3d1x/d3dapi/d3d11shader.idl | 287 +++
.../state_trackers/d3d1x/d3dapi/d3dcommon.idl | 700 ++++++
src/gallium/state_trackers/d3d1x/d3dapi/dxgi.idl | 470 ++++
.../state_trackers/d3d1x/d3dapi/dxgiformat.idl | 129 +
.../state_trackers/d3d1x/d3dapi/dxgitype.idl | 84 +
.../state_trackers/d3d1x/d3dapi/specstrings.h | 25 +
src/gallium/state_trackers/d3d1x/docs/Makefile | 4 +
.../state_trackers/d3d1x/docs/coding_style.txt | 85 +
.../d3d1x/docs/module_dependencies.dot | 25 +
.../state_trackers/d3d1x/docs/source_layout.txt | 17 +
src/gallium/state_trackers/d3d1x/dxgi/Makefile | 17 +
.../state_trackers/d3d1x/dxgi/src/dxgi_loader.cpp | 206 ++
.../state_trackers/d3d1x/dxgi/src/dxgi_native.cpp | 1314 +++++++++++
.../state_trackers/d3d1x/dxgi/src/dxgi_private.h | 50 +
.../state_trackers/d3d1x/dxgid3d10/Makefile | 4 +
.../state_trackers/d3d1x/dxgid3d10/dxgid3d10.cpp | 149 ++
.../state_trackers/d3d1x/dxgid3d11/Makefile | 4 +
.../state_trackers/d3d1x/dxgid3d11/dxgid3d11.cpp | 135 ++
src/gallium/state_trackers/d3d1x/gd3d10/Makefile | 19 +
src/gallium/state_trackers/d3d1x/gd3d10/d3d10.pl | 12 +
src/gallium/state_trackers/d3d1x/gd3d11/Makefile | 6 +
src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp | 236 ++
.../state_trackers/d3d1x/gd3d11/d3d11_context.h | 2033 ++++++++++++++++
.../state_trackers/d3d1x/gd3d11/d3d11_objects.h | 715 ++++++
.../state_trackers/d3d1x/gd3d11/d3d11_screen.h | 1447 ++++++++++++
src/gallium/state_trackers/d3d1x/gd3d1x/Makefile | 6 +
.../state_trackers/d3d1x/gd3d1x/d3d1x_private.h | 101 +
.../state_trackers/d3d1x/gd3d1x/d3d_enums.cpp | 147 ++
.../d3d1x/gd3d1x/tools/dxbc2tgsi.cpp | 82 +
.../state_trackers/d3d1x/gd3d1x/tpf_to_tgsi.cpp | 832 +++++++
.../state_trackers/d3d1x/gd3d1x/tpf_to_tgsi.h | 34 +
src/gallium/state_trackers/d3d1x/gd3dapi/Makefile | 4 +
.../state_trackers/d3d1x/gd3dapi/galliumcom.idl | 76 +
.../d3d1x/gd3dapi/galliumd3d10_1.idl | 30 +
.../state_trackers/d3d1x/gd3dapi/galliumd3d11.idl | 31 +
.../state_trackers/d3d1x/gd3dapi/galliumdxgi.idl | 77 +
.../state_trackers/d3d1x/mstools/download-mstools | 73 +
src/gallium/state_trackers/d3d1x/progs/Makefile | 32 +
.../state_trackers/d3d1x/progs/bin/d3d10tri.exe | Bin 0 -> 11776 bytes
.../state_trackers/d3d1x/progs/bin/d3d11gears.exe | Bin 0 -> 27136 bytes
.../d3d1x/progs/bin/d3d11spikysphere.exe | Bin 0 -> 17408 bytes
.../state_trackers/d3d1x/progs/bin/d3d11tex.exe | Bin 0 -> 22016 bytes
.../state_trackers/d3d1x/progs/bin/d3d11tri.exe | Bin 0 -> 11776 bytes
.../state_trackers/d3d1x/progs/d3d10app/d3d10app.h | 51 +
.../d3d1x/progs/d3d10app/d3d10winmain.cpp | 188 ++
.../d3d1x/progs/d3d10app/d3d10x11main.cpp | 164 ++
.../d3d1x/progs/d3d10tri/d3d10tri.cpp | 118 +
.../d3d1x/progs/d3d10tri/d3d10tri.hlsl | 50 +
.../d3d1x/progs/d3d10tri/d3d10tri.hlsl.ps.h | 112 +
.../d3d1x/progs/d3d10tri/d3d10tri.hlsl.vs.h | 128 +
.../d3d1x/progs/d3d10tri/d3d10tri.vcxproj | 98 +
.../state_trackers/d3d1x/progs/d3d11app/d3d11app.h | 51 +
.../d3d1x/progs/d3d11app/d3d11blit.hlsl | 53 +
.../d3d1x/progs/d3d11app/d3d11blit.hlsl.ps.h | 142 ++
.../d3d1x/progs/d3d11app/d3d11blit.hlsl.vs.h | 130 +
.../state_trackers/d3d1x/progs/d3d11app/d3d11u.h | 424 ++++
.../d3d1x/progs/d3d11app/d3d11winmain.cpp | 172 ++
.../d3d1x/progs/d3d11app/d3d11x11main.cpp | 124 +
.../d3d1x/progs/d3d11gears/d3d11gears.cpp | 573 +++++
.../d3d1x/progs/d3d11gears/d3d11gears.hlsl | 75 +
.../d3d1x/progs/d3d11gears/d3d11gears.hlsl.ps.h | 309 +++
.../d3d1x/progs/d3d11gears/d3d11gears.hlsl.vs.h | 308 +++
.../d3d1x/progs/d3d11gears/d3d11gears.vcxproj | 100 +
.../progs/d3d11spikysphere/d3d11spikysphere.cpp | 227 ++
.../progs/d3d11spikysphere/d3d11spikysphere.hlsl | 193 ++
.../d3d11spikysphere/d3d11spikysphere.hlsl.ds.h | 623 +++++
.../d3d11spikysphere/d3d11spikysphere.hlsl.hs.h | 297 +++
.../d3d11spikysphere/d3d11spikysphere.hlsl.ps.h | 211 ++
.../d3d11spikysphere/d3d11spikysphere.hlsl.vs.h | 105 +
.../d3d11spikysphere/d3d11spikysphere.vcxproj | 102 +
.../d3d1x/progs/d3d11tex/d3d11tex.cpp | 116 +
.../d3d1x/progs/d3d11tex/d3d11tex.hlsl | 66 +
.../d3d1x/progs/d3d11tex/d3d11tex.hlsl.ps.h | 234 ++
.../d3d1x/progs/d3d11tex/d3d11tex.hlsl.vs.h | 153 ++
.../d3d1x/progs/d3d11tex/d3d11tex.vcxproj | 98 +
.../d3d1x/progs/d3d11tri/d3d11tri.cpp | 120 +
.../d3d1x/progs/d3d11tri/d3d11tri.hlsl | 50 +
.../d3d1x/progs/d3d11tri/d3d11tri.hlsl.ps.h | 112 +
.../d3d1x/progs/d3d11tri/d3d11tri.hlsl.vs.h | 128 +
.../d3d1x/progs/d3d11tri/d3d11tri.vcxproj | 99 +
.../d3d1x/progs/data/cornell_box_image.h | 1028 ++++++++
.../state_trackers/d3d1x/progs/data/tux_image.h | 1028 ++++++++
src/gallium/state_trackers/d3d1x/progs/progs.sln | 49 +
src/gallium/state_trackers/d3d1x/tools/fxc | 16 +
src/gallium/state_trackers/d3d1x/w32api | 1 +
108 files changed, 26335 insertions(+)
create mode 100644 src/gallium/state_trackers/d3d1x/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/Makefile.inc
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/include/le32.h
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/include/tpf.h
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_dump.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/dxbc_parse.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_analyze.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_dump.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_parse.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/tpf_text.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/src/utils.h
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xshader/tools/fxdis.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xstutil/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h
create mode 100644 src/gallium/state_trackers/d3d1x/d3d1xstutil/src/dxgi_enums.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3d10.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3d10_1.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3d10misc.h
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3d10shader.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3d11.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3d11shader.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/d3dcommon.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/dxgi.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/dxgiformat.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/dxgitype.idl
create mode 100644 src/gallium/state_trackers/d3d1x/d3dapi/specstrings.h
create mode 100644 src/gallium/state_trackers/d3d1x/docs/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/docs/coding_style.txt
create mode 100644 src/gallium/state_trackers/d3d1x/docs/module_dependencies.dot
create mode 100644 src/gallium/state_trackers/d3d1x/docs/source_layout.txt
create mode 100644 src/gallium/state_trackers/d3d1x/dxgi/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_loader.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_private.h
create mode 100644 src/gallium/state_trackers/d3d1x/dxgid3d10/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/dxgid3d10/dxgid3d10.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/dxgid3d11/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/dxgid3d11/dxgid3d11.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d10/Makefile
create mode 100755 src/gallium/state_trackers/d3d1x/gd3d10/d3d10.pl
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d11/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d1x/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d1x/d3d1x_private.h
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d1x/d3d_enums.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d1x/tools/dxbc2tgsi.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d1x/tpf_to_tgsi.cpp
create mode 100644 src/gallium/state_trackers/d3d1x/gd3d1x/tpf_to_tgsi.h
create mode 100644 src/gallium/state_trackers/d3d1x/gd3dapi/Makefile
create mode 100644 src/gallium/state_trackers/d3d1x/gd3dapi/galliumcom.idl
create mode 100644 src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d10_1.idl
create mode 100644 src/gallium/state_trackers/d3d1x/gd3dapi/galliumd3d11.idl
create mode 100644 src/gallium/state_trackers/d3d1x/gd3dapi/galliumdxgi.idl
create mode 100755 src/gallium/state_trackers/d3d1x/mstools/download-mstools
create mode 100644 src/gallium/state_trackers/d3d1x/progs/Makefile
create mode 100755 src/gallium/state_trackers/d3d1x/progs/bin/d3d10tri.exe
create mode 100755 src/gallium/state_trackers/d3d1x/progs/bin/d3d11gears.exe
create mode 100755 src/gallium/state_trackers/d3d1x/progs/bin/d3d11spikysphere.exe
create mode 100755 src/gallium/state_trackers/d3d1x/progs/bin/d3d11tex.exe
create mode 100755 src/gallium/state_trackers/d3d1x/progs/bin/d3d11tri.exe
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10app.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10winmain.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10app/d3d10x11main.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.ps.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.hlsl.vs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d10tri/d3d10tri.vcxproj
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11app.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.ps.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11blit.hlsl.vs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11u.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11winmain.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11app/d3d11x11main.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.ps.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.hlsl.vs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11gears/d3d11gears.vcxproj
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ds.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.hs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.ps.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.hlsl.vs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11spikysphere/d3d11spikysphere.vcxproj
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.ps.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.hlsl.vs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tex/d3d11tex.vcxproj
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.cpp
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.ps.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.hlsl.vs.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/d3d11tri/d3d11tri.vcxproj
create mode 100755 src/gallium/state_trackers/d3d1x/progs/data/cornell_box_image.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/data/tux_image.h
create mode 100755 src/gallium/state_trackers/d3d1x/progs/progs.sln
create mode 100755 src/gallium/state_trackers/d3d1x/tools/fxc
create mode 120000 src/gallium/state_trackers/d3d1x/w32api
(limited to 'src/gallium')
diff --git a/src/gallium/state_trackers/d3d1x/Makefile b/src/gallium/state_trackers/d3d1x/Makefile
new file mode 100644
index 0000000000..6d55376be1
--- /dev/null
+++ b/src/gallium/state_trackers/d3d1x/Makefile
@@ -0,0 +1,11 @@
+SUBDIRS=d3dapi gd3dapi docs d3d1xstutil d3d1xshader gd3d1x gd3d11 gd3d10 dxgi dxgid3d11 dxgid3d10 progs
+
+all:
+ @for dir in $(SUBDIRS) ; do $(MAKE) -C "$$dir" || exit $?; done
+
+clean:
+ rm -f `find . -name \*.[oa]`
+ rm -f `find . -name depend`
+
+install:
+
diff --git a/src/gallium/state_trackers/d3d1x/Makefile.inc b/src/gallium/state_trackers/d3d1x/Makefile.inc
new file mode 100644
index 0000000000..1b9423b9d6
--- /dev/null
+++ b/src/gallium/state_trackers/d3d1x/Makefile.inc
@@ -0,0 +1,19 @@
+TOP=../../../../..
+include $(TOP)/configs/current
+
+IDL=$(wildcard *.idl include/*.idl)
+IDL_H=$(IDL:.idl=.h)
+LD=$(CXX)
+
+include ../../../Makefile.template
+
+idl: $(IDL_H)
+
+%.h: %.idl
+ widl -I../gd3dapi -I../d3dapi -I../w32api -U /dev/null -H $@ $^
+
+%.svg: %.dot
+ dot -Tsvg -o $@ $<
+
+%.pdf: %.dot
+ dot -Tpdf -o $@ $<
diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile
new file mode 100644
index 0000000000..6ac74d1895
--- /dev/null
+++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/Makefile
@@ -0,0 +1,7 @@
+LIBNAME=d3d1xshader
+CPP_SOURCES=$(wildcard src/*.cpp)
+LIBRARY_INCLUDES=-Iinclude -I../w32api -I../d3dapi
+PROGS=tools/fxdis
+LIBS=libd3d1xshader.a
+
+include ../Makefile.inc
diff --git a/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h
new file mode 100644
index 0000000000..44fce81079
--- /dev/null
+++ b/src/gallium/state_trackers/d3d1x/d3d1xshader/include/dxbc.h
@@ -0,0 +1,101 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Luca Barbieri
+ *
+ * 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 the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, 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 NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS 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.
+ *
+ **************************************************************************/
+
+#ifndef DXBC_H_
+#define DXBC_H_
+
+#include
+#include
+#include