aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-04-18 02:43:01 +0200
committerMarek Olšák <[email protected]>2010-04-18 02:56:09 +0200
commit0b4df63609e9fb25319debd56142a90b11d75671 (patch)
treeca7c0458e720352ee4990b484b2fda176b8a2921
parentd3e7dfc1fd7753d6305afb402e432ff45a7c0707 (diff)
r300g: various other cleanups
It seems to me that the resource management code is the most blurry. Also some of my notes about fastfill are wrong, removing them too.
-rw-r--r--src/gallium/drivers/r300/r300_blit.c15
-rw-r--r--src/gallium/drivers/r300/r300_context.c1
-rw-r--r--src/gallium/drivers/r300/r300_defines.h6
-rw-r--r--src/gallium/drivers/r300/r300_flush.c1
-rw-r--r--src/gallium/drivers/r300/r300_render.c2
-rw-r--r--src/gallium/drivers/r300/r300_render.h2
-rw-r--r--src/gallium/drivers/r300/r300_resource.c8
-rw-r--r--src/gallium/drivers/r300/r300_screen.h1
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.c13
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.h76
-rw-r--r--src/gallium/drivers/r300/r300_texture.c17
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h15
12 files changed, 71 insertions, 86 deletions
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index 322eaa83bd0..e84b79ae902 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -56,21 +56,10 @@ void r300_clear(struct pipe_context* pipe,
* 2) ZB_DEPTHCLEARVALUE is used to clear a zbuffer and Z Mask must be
* equal to 0.
*
- * 3) RB3D_COLOR_CLEAR_VALUE is used to clear a colorbuffer and
- * RB3D_COLOR_CHANNEL_MASK must be equal to 0.
- *
- * 4) ZB_CB_CLEAR can be used to make the ZB units help in clearing
- * the colorbuffer. The color clear value is supplied through both
- * RB3D_COLOR_CLEAR_VALUE and ZB_DEPTHCLEARVALUE, and the colorbuffer
- * must be set in ZB_DEPTHOFFSET and ZB_DEPTHPITCH in addition to
- * RB3D_COLOROFFSET and RB3D_COLORPITCH. It's obvious that the zbuffer
- * will not be cleared and multiple render targets cannot be cleared
- * this way either.
- *
- * 5) For 16-bit integer buffering, compression causes a hung with one or
+ * 3) For 16-bit integer buffering, compression causes a hung with one or
* two samples and should not be used.
*
- * 6) Fastfill must not be used if reading of compressed Z data is disabled
+ * 4) Fastfill must not be used if reading of compressed Z data is disabled
* and writing of compressed Z data is enabled (RD/WR_COMP_ENABLE),
* i.e. it cannot be used to compress the zbuffer.
* (what the hell does that mean and how does it fit in clearing
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 06af2c2fd8d..503af3e78a2 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -71,7 +71,6 @@ static void r300_destroy_context(struct pipe_context* context)
FREE(r300);
}
-
static void r300_flush_cb(void *data)
{
struct r300_context* const cs_context_copy = data;
diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h
index 8237c999aac..98ee3c1edec 100644
--- a/src/gallium/drivers/r300/r300_defines.h
+++ b/src/gallium/drivers/r300/r300_defines.h
@@ -30,6 +30,12 @@
#define R300_RESOURCE_FLAG_TRANSFER PIPE_RESOURCE_FLAG_DRV_PRIV
+/* XXX: this is just a bandaid on larger problems in
+ * r300_screen_buffer.h which doesn't seem to be fully ported to
+ * gallium-resources.
+ */
+#define R300_BIND_OQBO (1<<21)
+
/* Tiling flags. */
enum r300_buffer_tiling {
R300_BUFFER_LINEAR = 0,
diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c
index 5e61f528b64..e78c6a3624f 100644
--- a/src/gallium/drivers/r300/r300_flush.c
+++ b/src/gallium/drivers/r300/r300_flush.c
@@ -74,7 +74,6 @@ static void r300_flush(struct pipe_context* pipe,
}
}
-
void r300_init_flush_functions(struct r300_context* r300)
{
r300->context.flush = r300_flush;
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index fa7b70b0846..f6bc68c43ad 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -44,7 +44,7 @@
/* XXX The DRM rejects VAP_ALT_NUM_VERTICES.. */
//#define ENABLE_ALT_NUM_VERTS
-uint32_t r300_translate_primitive(unsigned prim)
+static uint32_t r300_translate_primitive(unsigned prim)
{
switch (prim) {
case PIPE_PRIM_POINTS:
diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h
index b8307c84d3d..85da6135f58 100644
--- a/src/gallium/drivers/r300/r300_render.h
+++ b/src/gallium/drivers/r300/r300_render.h
@@ -23,8 +23,6 @@
#ifndef R300_RENDER_H
#define R300_RENDER_H
-uint32_t r300_translate_primitive(unsigned prim);
-
void r500_emit_draw_arrays_immediate(struct r300_context *r300,
unsigned mode,
unsigned start,
diff --git a/src/gallium/drivers/r300/r300_resource.c b/src/gallium/drivers/r300/r300_resource.c
index 9b661a21246..7ed47eaa605 100644
--- a/src/gallium/drivers/r300/r300_resource.c
+++ b/src/gallium/drivers/r300/r300_resource.c
@@ -59,10 +59,7 @@ r300_resource_from_handle(struct pipe_screen * screen,
return r300_texture_from_handle(screen, templ, whandle);
}
-
-
-void
-r300_init_resource_functions(struct r300_context *r300)
+void r300_init_resource_functions(struct r300_context *r300)
{
r300->context.get_transfer = u_get_transfer_vtbl;
r300->context.transfer_map = u_transfer_map_vtbl;
@@ -73,8 +70,7 @@ r300_init_resource_functions(struct r300_context *r300)
r300->context.is_resource_referenced = u_is_resource_referenced_vtbl;
}
-void
-r300_init_screen_resource_functions(struct r300_screen *r300screen)
+void r300_init_screen_resource_functions(struct r300_screen *r300screen)
{
r300screen->screen.resource_create = r300_resource_create;
r300screen->screen.resource_from_handle = r300_resource_from_handle;
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 4077424e549..330bd9b36ba 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -94,4 +94,3 @@ void r300_init_debug(struct r300_screen* ctx);
void r300_init_screen_resource_functions(struct r300_screen *r300screen);
#endif /* R300_SCREEN_H */
-
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 28f10e0c541..ea10aeee24e 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -22,6 +22,7 @@
*
* Authors: Dave Airlie
*/
+
#include <stdio.h>
#include "util/u_inlines.h"
@@ -31,7 +32,6 @@
#include "util/u_math.h"
#include "r300_screen_buffer.h"
-
#include "r300_winsys.h"
static unsigned r300_buffer_is_referenced(struct pipe_context *context,
@@ -80,7 +80,7 @@ int r300_upload_index_buffer(struct r300_context *r300,
return ret;
}
-/* External helper, not required to implent u_resource_vtbl:
+/* External helper, not required to implement u_resource_vtbl:
*/
int r300_upload_user_buffers(struct r300_context *r300)
{
@@ -90,7 +90,6 @@ int r300_upload_user_buffers(struct r300_context *r300)
nr = r300->vertex_buffer_count;
for (i = 0; i < nr; i++) {
-
if (r300_buffer_is_user_buffer(r300->vertex_buffer[i].buffer)) {
struct pipe_resource *upload_buffer = NULL;
unsigned offset = 0; /*r300->vertex_buffer[i].buffer_offset * 4;*/
@@ -135,7 +134,6 @@ static void r300_winsys_buffer_destroy(struct r300_screen *r300screen,
}
}
-
static void r300_buffer_destroy(struct pipe_screen *screen,
struct pipe_resource *buf)
{
@@ -254,9 +252,6 @@ struct u_resource_vtbl r300_buffer_vtbl =
u_default_transfer_inline_write /* transfer_inline_write */
};
-
-
-
struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ)
{
@@ -276,7 +271,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
rbuf->b.b.screen = screen;
if (rbuf->b.b.bind & R300_BIND_OQBO)
- alignment = 4096;
+ alignment = 4096;
rbuf->buf = r300_winsys_buffer_create(r300screen,
alignment,
@@ -293,7 +288,6 @@ error1:
return NULL;
}
-
struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
void *ptr,
unsigned bytes,
@@ -323,4 +317,3 @@ struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
no_rbuf:
return NULL;
}
-
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h
index 9409bf32b81..82660d3e1a4 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.h
+++ b/src/gallium/drivers/r300/r300_screen_buffer.h
@@ -1,22 +1,49 @@
+/*
+ * Copyright 2010 Red Hat 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
+ * 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.
+ *
+ * Authors: Dave Airlie
+ */
+
#ifndef R300_SCREEN_BUFFER_H
#define R300_SCREEN_BUFFER_H
+
#include <stdio.h>
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "util/u_transfer.h"
-#include "r300_screen.h"
+#include "r300_screen.h"
#include "r300_winsys.h"
#include "r300_context.h"
#define R300_BUFFER_MAGIC 0xabcd1234
+#define R300_BUFFER_MAX_RANGES 32
struct r300_buffer_range {
uint32_t start;
uint32_t end;
};
-#define R300_BUFFER_MAX_RANGES 32
+/* Vertex buffer. */
struct r300_buffer
{
struct u_resource b;
@@ -32,8 +59,27 @@ struct r300_buffer
void *map;
};
-static INLINE struct r300_buffer *
-r300_buffer(struct pipe_resource *buffer)
+/* Functions. */
+
+int r300_upload_user_buffers(struct r300_context *r300);
+
+int r300_upload_index_buffer(struct r300_context *r300,
+ struct pipe_resource **index_buffer,
+ unsigned index_size,
+ unsigned start,
+ unsigned count);
+
+struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *templ);
+
+struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
+/* Inline functions. */
+
+static INLINE struct r300_buffer *r300_buffer(struct pipe_resource *buffer)
{
if (buffer) {
assert(((struct r300_buffer *)buffer)->magic == R300_BUFFER_MAGIC);
@@ -42,8 +88,7 @@ r300_buffer(struct pipe_resource *buffer)
return NULL;
}
-static INLINE boolean
-r300_buffer_is_user_buffer(struct pipe_resource *buffer)
+static INLINE boolean r300_buffer_is_user_buffer(struct pipe_resource *buffer)
{
return r300_buffer(buffer)->user_buffer ? true : false;
}
@@ -60,7 +105,6 @@ static INLINE boolean r300_add_buffer(struct r300_winsys_screen *rws,
return rws->add_buffer(rws, buf->buf, rd, wr);
}
-
static INLINE boolean r300_add_texture(struct r300_winsys_screen *rws,
struct r300_texture *tex,
int rd, int wr)
@@ -68,7 +112,6 @@ static INLINE boolean r300_add_texture(struct r300_winsys_screen *rws,
return rws->add_buffer(rws, tex->buffer, rd, wr);
}
-
static INLINE void r300_buffer_write_reloc(struct r300_winsys_screen *rws,
struct r300_buffer *buf,
uint32_t rd, uint32_t wd, uint32_t flags)
@@ -86,21 +129,4 @@ static INLINE void r300_texture_write_reloc(struct r300_winsys_screen *rws,
rws->write_cs_reloc(rws, texture->buffer, rd, wd, flags);
}
-int r300_upload_user_buffers(struct r300_context *r300);
-
-int r300_upload_index_buffer(struct r300_context *r300,
- struct pipe_resource **index_buffer,
- unsigned index_size,
- unsigned start,
- unsigned count);
-
-
-struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
- const struct pipe_resource *templ);
-
-struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes,
- unsigned usage);
-
#endif
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 0c3502ff936..a4a3f2166f8 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -896,13 +896,9 @@ static void r300_texture_destroy(struct pipe_screen *screen,
FREE(tex);
}
-
-
-
-static boolean
- r300_texture_get_handle(struct pipe_screen* screen,
- struct pipe_resource *texture,
- struct winsys_handle *whandle)
+static boolean r300_texture_get_handle(struct pipe_screen* screen,
+ struct pipe_resource *texture,
+ struct winsys_handle *whandle)
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
struct r300_texture* tex = (struct r300_texture*)texture;
@@ -919,8 +915,6 @@ static boolean
return TRUE;
}
-
-
struct u_resource_vtbl r300_texture_vtbl =
{
r300_texture_get_handle, /* get_handle */
@@ -934,8 +928,6 @@ struct u_resource_vtbl r300_texture_vtbl =
u_default_transfer_inline_write /* transfer_inline_write */
};
-
-
/* Create a new texture. */
struct pipe_resource* r300_texture_create(struct pipe_screen* screen,
const struct pipe_resource* base)
@@ -979,8 +971,6 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen,
return (struct pipe_resource*)tex;
}
-
-
/* Not required to implement u_resource_vtbl, consider moving to another file:
*/
struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
@@ -1097,4 +1087,3 @@ r300_texture_from_handle(struct pipe_screen* screen,
}
return (struct pipe_resource*)tex;
}
-
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 5ac997c8680..9c348d91158 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -32,20 +32,8 @@
#include "r300_defines.h"
-struct r300_winsys_screen;
-
-/* Creates a new r300 screen. */
-struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws);
-
struct r300_winsys_buffer;
-/* XXX: this is just a bandaid on larger problems in
- * r300_screen_buffer.h which doesn't seem to be fully ported to
- * gallium-resources.
- */
-#define R300_BIND_OQBO (1<<21)
-
-
enum r300_value_id {
R300_VID_PCI_ID,
R300_VID_GB_PIPES,
@@ -180,4 +168,7 @@ struct r300_winsys_screen {
struct r300_winsys_screen *
r300_winsys_screen(struct pipe_screen *screen);
+/* Creates a new r300 screen. */
+struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws);
+
#endif /* R300_WINSYS_H */