Lots of structural work, especially in getting the two parts to talk nicely.
Todo:
- Get damn blitter working.
- Add CS flush.
- Reverse order of above two items.
# Gallium directories and
GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
-GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple nv04 nv10 nv20 nv30 nv40 nv50 failover trace
+GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple nv04 nv10 nv20 nv30 nv40 nv50 failover r300
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = xlib egl_xlib
OUT_CS_REG(RADEON_DP_CNTL,
RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM);
OUT_CS_REG(RADEON_DST_PITCH_OFFSET, 0x0);
- /* XXX fix this shit -> OUT_RELOC(dst, 0, RADEON_GEM_DOMAIN_VRAM) */
+ OUT_CS_RELOC(dst_buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
/* Do the actual paint. */
OUT_CS_REG(RADEON_DST_Y_X, (y << 16) | x);
struct pipe_context* r300_create_context(struct pipe_screen* screen,
struct pipe_winsys* winsys,
- struct amd_winsys* amd_winsys)
+ struct r300_winsys* r300_winsys)
{
struct r300_context* r300 = CALLOC_STRUCT(r300_context);
if (!r300)
return NULL;
- r300->winsys = amd_winsys;
+ r300->winsys = r300_winsys;
r300->context.winsys = winsys;
- r300->context.screen = screen;
+ r300->context.screen = r300_create_screen(winsys, 0x0);
r300->context.destroy = r300_destroy_context;
/* Parent class */
struct pipe_context context;
- struct amd_winsys* winsys;
+ /* The interface to the windowing system, etc. */
+ struct r300_winsys* winsys;
+ /* Draw module. Used mostly for SW TCL. */
struct draw_context* draw;
-
- /* CS object. This is very much like Intel's batchbuffer.
- * Fill it full of dwords and relocs and then submit.
- * Repeat as needed. */
- /* Note: Unlike Mesa's version of this, we don't keep a copy of the CSM
- * that was used to create this CS. Is this a good idea? */
- struct radeon_cs* cs;
};
/* Convenience cast wrapper. */
struct pipe_context* r300_create_context(struct pipe_screen* screen,
struct pipe_winsys* winsys,
- struct amd_winsys* amd_winsys);
+ struct r300_winsys* r300_winsys);
#endif /* R300_CONTEXT_H */
\ No newline at end of file
#ifndef R300_CS_H
#define R300_CS_H
-#include "radeon_cs.h"
#include "radeon_reg.h"
+#include "r300_winsys.h"
+
/* Yes, I know macros are ugly. However, they are much prettier than the code
* that they neatly hide away, and don't have the cost of function setup,so
* we're going to use them. */
#define MAX_CS_SIZE 64 * 1024 / 4
+/* XXX stolen from radeon_drm.h */
+#define RADEON_GEM_DOMAIN_CPU 0x1
+#define RADEON_GEM_DOMAIN_GTT 0x2
+#define RADEON_GEM_DOMAIN_VRAM 0x4
+
#define CP_PACKET0(register, count) \
(RADEON_CP_PACKET0 | ((count) << 16) | ((register) >> 2))
#define CS_LOCALS(context) \
- struct radeon_cs* cs = context->cs
+ struct r300_winsys* cs_winsys = context->winsys; \
+ struct radeon_cs* cs = cs_winsys->cs
-#define CHECK_CS(size) do { \
- if ((cs->cdw + (size) + 128) > MAX_CS_SIZE || radeon_cs_need_flush(cs)) { \
- /* XXX flush the CS */ \
- } } while (0)
+#define CHECK_CS(size) \
+ cs_winsys->check_cs(cs, (size))
-/* XXX radeon_cs_begin is currently unimplemented on the backend, but let's
- * be future-proof, yeah? */
#define BEGIN_CS(size) do { \
CHECK_CS(size); \
- radeon_cs_begin(cs, (size), __FILE__, __FUNCTION__, __LINE__); \
+ cs_winsys->begin_cs(cs, (size), __FILE__, __FUNCTION__, __LINE__); \
} while (0)
#define OUT_CS(value) \
- radeon_cs_write_dword(cs, value)
+ cs_winsys->write_cs_dword(cs, value)
#define OUT_CS_REG(register, value) do { \
OUT_CS(CP_PACKET0(register, 0)); \
OUT_CS(value); } while (0)
#define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \
- radeon_cs_write_dword(cs, offset); \
- radeon_cs_write_reloc(cs, bo, rd, wd, flags); \
+ OUT_CS(offset); \
+ cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \
} while (0)
-/* XXX more future-proofing */
#define END_CS \
- radeon_cs_end(cs, __FILE__, __FUNCTION__, __LINE__)
+ cs_winsys->end_cs(cs, __FILE__, __FUNCTION__, __LINE__)
#endif /* R300_CS_H */
\ No newline at end of file
if (!r300screen)
return NULL;
- /* XXX break this into its own function? */
+ /* XXX break this into its own function?
switch (pci_id) {
default:
debug_printf("%s: unknown PCI ID 0x%x, cannot create screen!\n",
__FUNCTION__, pci_id);
return NULL;
- }
+ } */
r300screen->pci_id = pci_id;
r300screen->screen.winsys = winsys;
--- /dev/null
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * 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 R300_WINSYS_H
+#define R300_WINSYS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The public interface header for the r300 pipe driver.
+ * Any winsys hosting this pipe needs to implement r300_winsys and then
+ * call r300_create_context to start things. */
+
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
+
+struct radeon_cs;
+
+struct r300_winsys {
+
+ /* CS object. This is very much like Intel's batchbuffer.
+ * Fill it full of dwords and relocs and then submit.
+ * Repeat as needed. */
+ /* Note: Unlike Mesa's version of this, we don't keep a copy of the CSM
+ * that was used to create this CS. Is this a good idea? */
+ /* Note: The pipe driver doesn't know how to use this. This is purely
+ * for the winsys. */
+ struct radeon_cs* cs;
+
+ /* Check to see if there's room for commands. */
+ boolean (*check_cs)(struct radeon_cs* cs, int size);
+
+ /* Start a command emit. */
+ void (*begin_cs)(struct radeon_cs* cs,
+ int size,
+ const char* file,
+ const char* function,
+ int line);
+
+ /* Write a dword to the command buffer. */
+ /* XXX is this an okay name for this handle? */
+ void (*write_cs_dword)(struct radeon_cs* cs, uint32_t dword);
+
+ /* Write a relocated dword to the command buffer. */
+ void (*write_cs_reloc)(struct radeon_cs* cs,
+ struct pipe_buffer* bo,
+ uint32_t rd,
+ uint32_t wd,
+ uint32_t flags);
+
+ /* Finish a command emit. */
+ void (*end_cs)(struct radeon_cs* cs,
+ const char* file,
+ const char* function,
+ int line);
+
+};
+
+struct pipe_context* r300_create_context(struct pipe_screen* screen,
+ struct pipe_winsys* winsys,
+ struct r300_winsys* r300_winsys);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* R300_WINSYS_H */
\ No newline at end of file
MINIGLX_SOURCES =
PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a
DRIVER_SOURCES = \
amd_buffer.c \
amd_context.c \
+ amd_r300.c \
amd_screen.c \
amd_winsys_softpipe.c
ASM_SOURCES =
+DRIVER_DEFINES = -I../../../drivers/r300
+
include ../Makefile.template
DRI_LIB_DEPS += -ldrm_radeon
}
if (GL_TRUE) {
- /* XXX second arg should be PCI ID, but damned if I know why */
- amd_context->pipe_screen = r300_create_screen(amd_context->pipe_winsys,
- 0x0);
- pipe = r300_create_context(amd_context->pipe_screen,
+ fprintf(stderr, "Creating r300 context...");
+ pipe = r300_create_context(NULL,
amd_context->pipe_winsys,
- (struct amd_pipe_winsys*)amd_context->pipe_winsys);
+ amd_create_r300_winsys(amd_context->drm_fd));
} else {
pipe = amd_create_softpipe(amd_context);
}
#include "state_tracker/st_context.h"
#include "amd_screen.h"
+#include "amd_r300.h"
+
struct amd_framebuffer {
struct st_framebuffer *st_framebuffer;
unsigned attachments;
--- /dev/null
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * 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 "amd_r300.h"
+
+static boolean amd_r300_check_cs(struct radeon_cs* cs, int size)
+{
+ /* XXX check size here, lazy ass! */
+ return TRUE;
+}
+
+static void amd_r300_write_cs_reloc(struct radeon_cs* cs,
+ struct pipe_buffer* pbuffer,
+ uint32_t rd,
+ uint32_t wd,
+ uint32_t flags)
+{
+ radeon_cs_write_reloc(cs, ((struct amd_pipe_buffer*)pbuffer)->bo, rd, wd, flags);
+}
+
+struct r300_winsys* amd_create_r300_winsys(int fd)
+{
+ struct r300_winsys* winsys = calloc(1, sizeof(struct r300_winsys));
+
+ struct radeon_cs_manager* csm = radeon_cs_manager_gem_ctor(fd);
+
+ winsys->cs = radeon_cs_create(csm, 1024 * 64 / 4);
+
+ winsys->check_cs = amd_r300_check_cs;
+ winsys->begin_cs = radeon_cs_begin;
+ winsys->write_cs_dword = radeon_cs_write_dword;
+ winsys->write_cs_reloc = amd_r300_write_cs_reloc;
+ winsys->end_cs = radeon_cs_end;
+
+ return winsys;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * 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 "radeon_cs.h"
+
+#include "r300_winsys.h"
+
+#include "amd_buffer.h"
+
+struct r300_winsys* amd_create_r300_winsys(int fd);