radeong: Don't allocate HW BOs for constantbufs.

We have broken 1000 FPS. Hell yes.

Heavily inspired by Marek's patch, but using pipebuffer instead of
a roll-your-own malloc.
This commit is contained in:
Corbin Simpson
2010-01-18 02:30:49 -08:00
parent 673ae6266e
commit 0857f38c39
4 changed files with 41 additions and 12 deletions
@@ -58,6 +58,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
{
struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws;
struct radeon_pipe_buffer *radeon_buffer;
struct pb_desc desc;
uint32_t domain;
radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
@@ -70,6 +71,14 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
radeon_buffer->base.usage = usage;
radeon_buffer->base.size = size;
if (usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) {
/* Don't bother allocating a BO, as it'll never get to the card. */
desc.alignment = alignment;
desc.usage = usage;
radeon_buffer->pb = pb_malloc_buffer_create(size, &desc);
return &radeon_buffer->base;
}
domain = 0;
if (usage & PIPE_BUFFER_USAGE_PIXEL) {
@@ -133,8 +142,16 @@ static void radeon_buffer_del(struct pipe_buffer *buffer)
struct radeon_pipe_buffer *radeon_buffer =
(struct radeon_pipe_buffer*)buffer;
radeon_bo_unref(radeon_buffer->bo);
free(radeon_buffer);
if (radeon_buffer->pb) {
pipe_reference_init(&radeon_buffer->pb->base.reference, 0);
pb_destroy(radeon_buffer->pb);
}
if (radeon_buffer->bo) {
radeon_bo_unref(radeon_buffer->bo);
}
FREE(radeon_buffer);
}
static void *radeon_buffer_map(struct pipe_winsys *ws,
@@ -146,6 +163,10 @@ static void *radeon_buffer_map(struct pipe_winsys *ws,
(struct radeon_pipe_buffer*)buffer;
int write = 0;
if (radeon_buffer->pb) {
return pb_map(radeon_buffer->pb, flags);
}
if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
uint32_t domain;
@@ -174,7 +195,11 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws,
struct radeon_pipe_buffer *radeon_buffer =
(struct radeon_pipe_buffer*)buffer;
radeon_bo_unmap(radeon_buffer->bo);
if (radeon_buffer->pb) {
pb_unmap(radeon_buffer->pb);
} else {
radeon_bo_unmap(radeon_buffer->bo);
}
}
static void radeon_fence_reference(struct pipe_winsys *ws,
@@ -36,7 +36,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
//#include "state_tracker/st_public.h"
#include "pipebuffer/pb_buffer.h"
#include "util/u_memory.h"
@@ -49,7 +49,10 @@
struct radeon_pipe_buffer {
struct pipe_buffer base;
/* Pointer to GPU-backed BO. */
struct radeon_bo *bo;
/* Pointer to fallback PB buffer. */
struct pb_buffer *pb;
boolean flinked;
uint32_t flink;
};
@@ -120,14 +120,6 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys)
drmFreeVersion(version);
}
/* Guess at whether this chipset should use r300g.
*
* I believe that this check is valid, but I haven't been exhaustive. */
static boolean is_r3xx(int pciid)
{
return (pciid > 0x3150) && (pciid < 0x796f);
}
/* Create a pipe_screen. */
struct pipe_screen* radeon_create_screen(struct drm_api* api,
int drmFB,
@@ -77,4 +77,13 @@ boolean radeon_global_handle_from_buffer(struct drm_api* api,
unsigned* handle);
void radeon_destroy_drm_api(struct drm_api* api);
/* Guess at whether this chipset should use r300g.
*
* I believe that this check is valid, but I haven't been exhaustive. */
static boolean is_r3xx(int pciid)
{
return (pciid > 0x3150) && (pciid < 0x796f);
}
#endif