소스 검색

nouveau: give resources a start property

tags/mesa_20090313
Ben Skeggs 17 년 전
부모
커밋
1a3987240a

+ 1
- 0
src/mesa/drivers/dri/nouveau_winsys/Makefile 파일 보기

@@ -22,6 +22,7 @@ DRIVER_SOURCES = \
nouveau_lock.c \
nouveau_notifier.c \
nouveau_pushbuf.c \
nouveau_resource.c \
nouveau_screen.c \
nouveau_swapbuffers.c \
nouveau_winsys.c \

+ 2
- 1
src/mesa/drivers/dri/nouveau_winsys/nouveau_drmif.h 파일 보기

@@ -281,7 +281,8 @@ nouveau_bo_validate(struct nouveau_channel *, struct nouveau_bo *,
struct nouveau_fence *fence, uint32_t flags);

extern int
nouveau_resource_init(struct nouveau_resource **heap, int size);
nouveau_resource_init(struct nouveau_resource **heap, unsigned start,
unsigned size);

extern int
nouveau_resource_alloc(struct nouveau_resource *heap, int size, void *priv,

+ 3
- 3
src/mesa/drivers/dri/nouveau_winsys/nouveau_pushbuf.c 파일 보기

@@ -36,7 +36,7 @@ nouveau_pushbuf_init(struct nouveau_channel *chan)
return -EINVAL;

/* Everything except first 4KiB of the push buffer is managed by us */
if (nouveau_resource_init(&nvchan->pb_heap,
if (nouveau_resource_init(&nvchan->pb_heap, 4096,
nvchan->drm.cmdbuf_size - 4096))
return -EINVAL;

@@ -116,7 +116,7 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan)
#ifdef NOUVEAU_DMA_DEBUG
nvchan->dma.push_free = 1;
#endif
OUT_RING_CH(chan, 0x20000000 | (nvpb->res->start + 4096));
OUT_RING_CH(chan, 0x20000000 | nvpb->res->start);

/* Add JMP back to master pushbuf from indirect pushbuf */
(*nvpb->base.cur++) =
@@ -179,7 +179,7 @@ out_realloc:

nvpb->base.channel = chan;
nvpb->base.remaining = nvpb->res->size / 4;
nvpb->base.cur = &nvchan->pushbuf[(nvpb->res->start + 4096)/4];
nvpb->base.cur = &nvchan->pushbuf[nvpb->res->start/4];

if (nvchan->pb_tail) {
nouveau_pushbuf(nvchan->pb_tail)->next = &nvpb->base;

+ 111
- 0
src/mesa/drivers/dri/nouveau_winsys/nouveau_resource.c 파일 보기

@@ -0,0 +1,111 @@
/*
* Copyright 2007 Nouveau Project
*
* 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 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 <stdlib.h>
#include <errno.h>

#include "nouveau_drmif.h"
#include "nouveau_local.h"

int
nouveau_resource_init(struct nouveau_resource **heap,
unsigned start, unsigned size)
{
struct nouveau_resource *r;

r = calloc(1, sizeof(struct nouveau_resource));
if (!r)
return 1;

r->start = start;
r->size = size;
*heap = r;
return 0;
}

int
nouveau_resource_alloc(struct nouveau_resource *heap, int size, void *priv,
struct nouveau_resource **res)
{
struct nouveau_resource *r;

if (!heap || !size || !res || *res)
return 1;

while (heap) {
if (!heap->in_use && heap->size >= size) {
r = calloc(1, sizeof(struct nouveau_resource));
if (!r)
return 1;

r->start = (heap->start + heap->size) - size;
r->size = size;
r->in_use = 1;
r->priv = priv;

heap->size -= size;

r->next = heap->next;
if (heap->next)
heap->next->prev = r;
r->prev = heap;
heap->next = r;

*res = r;
return 0;
}
heap = heap->next;
}

return 1;
}

void
nouveau_resource_free(struct nouveau_resource **res)
{
struct nouveau_resource *r;

if (!res || !*res)
return;
r = *res;

if (r->prev && !r->prev->in_use) {
r->prev->next = r->next;
if (r->next)
r->next->prev = r->prev;
r->prev->size += r->size;
free(r);
} else
if (r->next && !r->next->in_use) {
r->next->prev = r->prev;
if (r->prev)
r->prev->next = r->next;
r->next->size += r->size;
r->next->start = r->start;
free(r);
} else {
r->in_use = 0;
}

*res = NULL;
}

+ 0
- 83
src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys.c 파일 보기

@@ -5,89 +5,6 @@

#include "pipe/nouveau/nouveau_winsys.h"

int
nouveau_resource_init(struct nouveau_resource **heap, int size)
{
struct nouveau_resource *r;

r = calloc(1, sizeof(struct nouveau_resource));
if (!r)
return 1;

r->start = 0;
r->size = size;
*heap = r;
return 0;
}

int
nouveau_resource_alloc(struct nouveau_resource *heap, int size, void *priv,
struct nouveau_resource **res)
{
struct nouveau_resource *r;

if (!heap || !size || !res || *res)
return 1;

while (heap) {
if (!heap->in_use && heap->size >= size) {
r = calloc(1, sizeof(struct nouveau_resource));
if (!r)
return 1;

r->start = (heap->start + heap->size) - size;
r->size = size;
r->in_use = TRUE;
r->priv = priv;

heap->size -= size;

r->next = heap->next;
if (heap->next)
heap->next->prev = r;
r->prev = heap;
heap->next = r;

*res = r;
return 0;
}
heap = heap->next;
}

return 1;
}

void
nouveau_resource_free(struct nouveau_resource **res)
{
struct nouveau_resource *r;

if (!res || !*res)
return;
r = *res;

if (r->prev && !r->prev->in_use) {
r->prev->next = r->next;
if (r->next)
r->next->prev = r->prev;
r->prev->size += r->size;
free(r);
} else
if (r->next && !r->next->in_use) {
r->next->prev = r->prev;
if (r->prev)
r->prev->next = r->next;
r->next->size += r->size;
r->next->start = r->start;
free(r);
} else {
r->in_use = FALSE;
}

*res = NULL;
}

static int
nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count,
struct nouveau_notifier **notify)

+ 2
- 1
src/mesa/pipe/nouveau/nouveau_winsys.h 파일 보기

@@ -17,7 +17,8 @@ struct nouveau_winsys {

struct nouveau_channel *channel;

int (*res_init)(struct nouveau_resource **heap, int size);
int (*res_init)(struct nouveau_resource **heap, unsigned start,
unsigned size);
int (*res_alloc)(struct nouveau_resource *heap, int size, void *priv,
struct nouveau_resource **);
void (*res_free)(struct nouveau_resource **);

+ 2
- 2
src/mesa/pipe/nv40/nv40_context.c 파일 보기

@@ -241,8 +241,8 @@ nv40_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
return NULL;
}

if (nvws->res_init(&nv40->vertprog.exec_heap, 512) ||
nvws->res_init(&nv40->vertprog.data_heap, 256)) {
if (nvws->res_init(&nv40->vertprog.exec_heap, 0, 512) ||
nvws->res_init(&nv40->vertprog.data_heap, 0, 256)) {
nvws->res_free(&nv40->vertprog.exec_heap);
nvws->res_free(&nv40->vertprog.data_heap);
free(nv40);

Loading…
취소
저장