Compare commits
52 Commits
unichrome-
...
rotating_g
Author | SHA1 | Date | |
---|---|---|---|
|
e443d1ec47 | ||
|
92d47e79f1 | ||
|
11374bdb86 | ||
|
24b5e49141 | ||
|
179cc373f1 | ||
|
c664f0c515 | ||
|
8be4747fd6 | ||
|
4a04f002db | ||
|
8f1ba083ba | ||
|
58cc2e9124 | ||
|
18551e75ea | ||
|
6fcc6c4965 | ||
|
bcd1a9ed68 | ||
|
2269445f6d | ||
|
b53030a94c | ||
|
a656dc251e | ||
|
51050efe0e | ||
|
7d8c1fb03a | ||
|
74bf43051c | ||
|
5be14fd59a | ||
|
490e764d7a | ||
|
ef494c06b6 | ||
|
54ef88109b | ||
|
e158292ee3 | ||
|
e972497310 | ||
|
f102f7ae3d | ||
|
cb0cc796d2 | ||
|
3b486d795d | ||
|
13ae06cf36 | ||
|
7b05b70c2a | ||
|
4c3f041862 | ||
|
5bdb4652f9 | ||
|
6a50fc43cb | ||
|
c6cca6a3b8 | ||
|
29c88396db | ||
|
d9fcfa2797 | ||
|
0983c9dd99 | ||
|
c3eaa17b37 | ||
|
99edafd4e8 | ||
|
83fcf49647 | ||
|
3cbc2bd833 | ||
|
1b2a655521 | ||
|
46a35b2284 | ||
|
1c86c7ad9c | ||
|
3deaf21745 | ||
|
9876730f7a | ||
|
15da29b5e7 | ||
|
7db50bb3a8 | ||
|
922bfd70ff | ||
|
80dd3c7917 | ||
|
8bdaa927eb | ||
|
990dec7ea0 |
@@ -49,6 +49,5 @@ WINDOW_SYSTEM=dri
|
||||
|
||||
# ffb and gamma are missing because they have not been converted to use the new
|
||||
# interface.
|
||||
DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx \
|
||||
unichrome savage sis
|
||||
|
||||
DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon s3v \
|
||||
savage sis tdfx trident unichrome
|
||||
|
@@ -1263,23 +1263,23 @@ CARD8 __glXSetupForCommand(Display *dpy)
|
||||
return priv->majorOpcode;
|
||||
}
|
||||
|
||||
/*
|
||||
** Flush the drawing command transport buffer.
|
||||
*/
|
||||
/**
|
||||
* Flush the drawing command transport buffer.
|
||||
*
|
||||
* \param ctx Context whose transport buffer is to be flushed.
|
||||
* \param pc Pointer to first unused buffer location.
|
||||
*
|
||||
* \todo
|
||||
* Modify this function to use \c ctx->pc instead of the explicit
|
||||
* \c pc parameter.
|
||||
*/
|
||||
GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
|
||||
{
|
||||
Display *dpy;
|
||||
Display * const dpy = ctx->currentDpy;
|
||||
xGLXRenderReq *req;
|
||||
GLint size;
|
||||
const GLint size = pc - ctx->buf;
|
||||
|
||||
if (!(dpy = ctx->currentDpy)) {
|
||||
/* Using the dummy context */
|
||||
ctx->pc = ctx->buf;
|
||||
return ctx->pc;
|
||||
}
|
||||
|
||||
size = pc - ctx->buf;
|
||||
if (size) {
|
||||
if ( (dpy != NULL) && (size > 0) ) {
|
||||
/* Send the entire buffer as an X request */
|
||||
LockDisplay(dpy);
|
||||
GetReq(GLXRender,req);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -145,7 +145,7 @@ intelTryReadPixels( GLcontext *ctx,
|
||||
GLvoid *pixels )
|
||||
{
|
||||
intelContextPtr intel = INTEL_CONTEXT(ctx);
|
||||
GLint size;
|
||||
GLint size = 0;
|
||||
GLint pitch = pack->RowLength ? pack->RowLength : width;
|
||||
|
||||
if (INTEL_DEBUG & DEBUG_PIXEL)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# src/mesa/drivers/dri/r300/Makefile
|
||||
|
||||
|
||||
TOP = ../../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
@@ -31,6 +32,7 @@ DRIVER_SOURCES = \
|
||||
r300_cmdbuf.c \
|
||||
r300_state.c \
|
||||
r300_render.c \
|
||||
r300_lib.c \
|
||||
\
|
||||
r200_context.c \
|
||||
r200_ioctl.c \
|
||||
|
94
src/mesa/drivers/dri/r300/pixel_shader.h
Normal file
94
src/mesa/drivers/dri/r300/pixel_shader.h
Normal file
@@ -0,0 +1,94 @@
|
||||
#ifndef __PIXEL_SHADER_H__
|
||||
#define __PIXEL_SHADER_H__
|
||||
|
||||
#include "r300_reg.h"
|
||||
|
||||
|
||||
/* INSTR 0 */
|
||||
|
||||
#define PFS_OP_MAD 0
|
||||
#define PFS_OP_DP3 1
|
||||
#define PFS_OP_DP4 2
|
||||
#define PFS_OP_MIN 4
|
||||
#define PFS_OP_MAX 5
|
||||
#define PFS_OP_CMP 8
|
||||
#define PFS_OP_FRC 9
|
||||
#define PFS_OP_OUTC_REPL_ALPHA 10
|
||||
|
||||
/* "or" these with arg0 value to negate or take absolute value of an argument */
|
||||
#define PFS_ARG_NEG (1<<5)
|
||||
#define PFS_ARG_ABS (1<<6)
|
||||
|
||||
#define MAKE_PFS_INSTR0(op, arg0, arg1, arg2, flags) \
|
||||
( ((op)<<23) \
|
||||
| ((arg0)<<R300_FPI0_ARG0C_SHIFT) \
|
||||
| ((arg1)<<R300_FPI0_ARG1C_SHIFT) \
|
||||
| ((arg2)<<R300_FPI0_ARG2C_SHIFT) \
|
||||
| (flags) \
|
||||
)
|
||||
|
||||
#define PFS_FLAG_X 1
|
||||
#define PFS_FLAG_Y 2
|
||||
#define PFS_FLAG_XY 3
|
||||
#define PFS_FLAG_Z 4
|
||||
#define PFS_FLAG_XZ 5
|
||||
#define PFS_FLAG_YZ 6
|
||||
#define PFS_FLAG_ALL 7
|
||||
#define PFS_FLAG_NONE 0
|
||||
|
||||
#define EASY_PFS_INSTR0(op, arg0, arg1, arg2) \
|
||||
MAKE_PFS_INSTR0(PFS_OP_##op, \
|
||||
R300_FPI0_ARGC_##arg0, \
|
||||
R300_FPI0_ARGC_##arg1, \
|
||||
R300_FPI0_ARGC_##arg2, \
|
||||
0)
|
||||
|
||||
/* INSTR 1 */
|
||||
|
||||
#define PFS_FLAG_CONST (1<<5)
|
||||
|
||||
#define MAKE_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
|
||||
((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
|
||||
| ((src2)<<R300_FPI1_SRC2C_SHIFT) \
|
||||
| ((dstc) << R300_FPI1_DSTC_SHIFT) \
|
||||
| ((reg) << 23) | ((output)<<26))
|
||||
|
||||
#define EASY_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
|
||||
MAKE_PFS_INSTR1(dstc, src0, src1, src2, PFS_FLAG_##reg, PFS_FLAG_##output)
|
||||
|
||||
/* INSTR 2 */
|
||||
|
||||
/* you can "or" PFS_ARG_NEG with these values to negate them */
|
||||
|
||||
#define MAKE_PFS_INSTR2(op, arg0, arg1, arg2, flags) \
|
||||
(((op) << 23) | \
|
||||
((arg0)<<R300_FPI2_ARG0A_SHIFT) | \
|
||||
((arg1)<<R300_FPI2_ARG1A_SHIFT) | \
|
||||
((arg2)<<R300_FPI2_ARG2A_SHIFT) | \
|
||||
(flags))
|
||||
|
||||
#define EASY_PFS_INSTR2(op, arg0, arg1, arg2) \
|
||||
MAKE_PFS_INSTR2(R300_FPI2_OUTA_##op, \
|
||||
R300_FPI2_ARGA_##arg0, \
|
||||
R300_FPI2_ARGA_##arg1, \
|
||||
R300_FPI2_ARGA_##arg2, \
|
||||
0)
|
||||
|
||||
|
||||
/* INSTR 3 */
|
||||
|
||||
#define PFS_FLAG_NONE 0
|
||||
#define PFS_FLAG_REG 1
|
||||
#define PFS_FLAG_OUTPUT 2
|
||||
#define PFS_FLAG_BOTH 3
|
||||
|
||||
#define MAKE_PFS_INSTR3(dstc, src0, src1, src2, flags) \
|
||||
((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
|
||||
| ((src2)<<R300_FPI1_SRC2C_SHIFT) \
|
||||
| ((dstc) << R300_FPI1_DSTC_SHIFT) \
|
||||
| ((flags) << 23))
|
||||
|
||||
#define EASY_PFS_INSTR3(dstc, src0, src1, src2, flag) \
|
||||
MAKE_PFS_INSTR3(dstc, src0, src1, src2, PFS_FLAG_##flag)
|
||||
|
||||
#endif
|
@@ -284,8 +284,8 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
r300->hw.unk2080.cmd[0] = cmducs(0x2080, 1);
|
||||
ALLOC_STATE( ovf, always, R300_OVF_CMDSIZE, "ovf", 0 );
|
||||
r300->hw.ovf.cmd[R300_OVF_CMD_0] = cmducs(R300_VAP_OUTPUT_VTX_FMT_0, 2);
|
||||
ALLOC_STATE( unk20B0, always, 3, "unk20B0", 0 );
|
||||
r300->hw.unk20B0.cmd[0] = cmducs(0x20B0, 2);
|
||||
ALLOC_STATE( vte, always, 3, "vte", 0 );
|
||||
r300->hw.vte.cmd[0] = cmducs(R300_SE_VTE_CNTL, 2);
|
||||
ALLOC_STATE( unk2134, always, 3, "unk2134", 0 );
|
||||
r300->hw.unk2134.cmd[0] = cmducs(0x2134, 2);
|
||||
ALLOC_STATE( unk2140, always, 2, "unk2140", 0 );
|
||||
@@ -304,12 +304,14 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
r300->hw.unk2220.cmd[0] = cmducs(0x2220, 4);
|
||||
ALLOC_STATE( unk2288, always, 2, "unk2288", 0 );
|
||||
r300->hw.unk2288.cmd[0] = cmducs(0x2288, 1);
|
||||
ALLOC_STATE( vof, always, R300_VOF_CMDSIZE, "vof", 0 );
|
||||
r300->hw.vof.cmd[R300_VOF_CMD_0] = cmducs(R300_VAP_OUTPUT_VTX_FMT_0, 2);
|
||||
ALLOC_STATE( pvs, always, R300_PVS_CMDSIZE, "pvs", 0 );
|
||||
r300->hw.pvs.cmd[R300_PVS_CMD_0] = cmducs(R300_VAP_PVS_CNTL_1, 3);
|
||||
ALLOC_STATE( unk4008, always, 2, "unk4008", 0 );
|
||||
r300->hw.unk4008.cmd[0] = cmducs(0x4008, 1);
|
||||
ALLOC_STATE( unk4010, always, 6, "unk4010", 0 );
|
||||
r300->hw.unk4010.cmd[0] = cmducs(0x4010, 5);
|
||||
ALLOC_STATE( gb_enable, always, 2, "gb_enable", 0 );
|
||||
r300->hw.gb_enable.cmd[0] = cmducs(R300_GB_ENABLE, 1);
|
||||
ALLOC_STATE( gb_misc, always, R300_GB_MISC_CMDSIZE, "gb_misc", 0 );
|
||||
r300->hw.gb_misc.cmd[0] = cmducs(R300_GB_MSPOS0, 5);
|
||||
ALLOC_STATE( txe, always, R300_TXE_CMDSIZE, "txe", 0 );
|
||||
r300->hw.txe.cmd[R300_TXE_CMD_0] = cmducs(R300_TX_ENABLE, 1);
|
||||
ALLOC_STATE( unk4200, always, 5, "unk4200", 0 );
|
||||
@@ -380,6 +382,8 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
r300->hw.unk4E50.cmd[0] = cmducs(0x4E50, 9);
|
||||
ALLOC_STATE( unk4E88, always, 2, "unk4E88", 0 );
|
||||
r300->hw.unk4E88.cmd[0] = cmducs(0x4E88, 1);
|
||||
ALLOC_STATE( unk4EA0, always, 3, "unk4EA0 R350 only", 0 );
|
||||
r300->hw.unk4EA0.cmd[0] = cmducs(0x4EA0, 2);
|
||||
ALLOC_STATE( zc, always, R300_ZC_CMDSIZE, "zc", 0 );
|
||||
r300->hw.zc.cmd[R300_ZC_CMD_0] = cmducs(R300_RB3D_ZCNTL_0, 2);
|
||||
ALLOC_STATE( unk4F08, always, 2, "unk4F08", 0 );
|
||||
@@ -411,7 +415,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.vpt);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2080);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.ovf);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk20B0);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.vte);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2134);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2140);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[0]);
|
||||
@@ -421,9 +425,10 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk221C);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2220);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2288);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.vof);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.pvs);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4008);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4010);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_enable);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_misc);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.txe);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4200);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4214);
|
||||
@@ -458,6 +463,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.cb);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E50);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E88);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4EA0);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.zc);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F08);
|
||||
insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F10);
|
||||
|
@@ -115,12 +115,26 @@ struct r300_state_atom {
|
||||
#define R300_VIC_CNTL_1 2
|
||||
#define R300_VIC_CMDSIZE 3
|
||||
|
||||
#define R300_VOF_CMD_0 0
|
||||
#define R300_VOF_CNTL_0 1
|
||||
#define R300_VOF_CNTL_1 2
|
||||
#define R300_VOF_CMDSIZE 3
|
||||
|
||||
|
||||
#define R300_PVS_CMD_0 0
|
||||
#define R300_PVS_CNTL_1 1
|
||||
#define R300_PVS_CNTL_2 2
|
||||
#define R300_PVS_CNTL_3 3
|
||||
#define R300_PVS_CMDSIZE 4
|
||||
|
||||
#define R300_GB_MISC_CMD_0 0
|
||||
#define R300_GB_MISC_MSPOS_0 1
|
||||
#define R300_GB_MISC_MSPOS_1 2
|
||||
#define R300_GB_MISC_TILE_CONFIG 3
|
||||
#define R300_GB_MISC_SELECT 4
|
||||
#define R300_GB_MISC_AA_CONFIG 5
|
||||
#define R300_GB_MISC_CMDSIZE 6
|
||||
|
||||
#define R300_TXE_CMD_0 0
|
||||
#define R300_TXE_ENABLE 1
|
||||
#define R300_TXE_CMDSIZE 2
|
||||
@@ -232,7 +246,7 @@ struct r300_hw_state {
|
||||
struct r300_state_atom vpt; /* viewport (1D98) */
|
||||
struct r300_state_atom unk2080; /* (2080) */
|
||||
struct r300_state_atom ovf; /* output vertex format (2090) */
|
||||
struct r300_state_atom unk20B0; /* (20B0) */
|
||||
struct r300_state_atom vte; /* (20B0) */
|
||||
struct r300_state_atom unk2134; /* (2134) */
|
||||
struct r300_state_atom unk2140; /* (2140) */
|
||||
struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */
|
||||
@@ -242,8 +256,9 @@ struct r300_hw_state {
|
||||
struct r300_state_atom unk2220; /* (2220) */
|
||||
struct r300_state_atom unk2288; /* (2288) */
|
||||
struct r300_state_atom pvs; /* pvs_cntl (22D0) */
|
||||
struct r300_state_atom unk4008; /* (4008) */
|
||||
struct r300_state_atom unk4010; /* (4010) */
|
||||
struct r300_state_atom vof; /* VAP output format register 0x4000 */
|
||||
struct r300_state_atom gb_enable; /* (4008) */
|
||||
struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */
|
||||
struct r300_state_atom txe; /* tex enable (4104) */
|
||||
struct r300_state_atom unk4200; /* (4200) */
|
||||
struct r300_state_atom unk4214; /* (4214) */
|
||||
@@ -275,6 +290,7 @@ struct r300_hw_state {
|
||||
struct r300_state_atom cb; /* colorbuffer (4E28) */
|
||||
struct r300_state_atom unk4E50; /* (4E50) */
|
||||
struct r300_state_atom unk4E88; /* (4E88) */
|
||||
struct r300_state_atom unk4EA0; /* (4E88) I saw it only written on RV350 hardware.. */
|
||||
struct r300_state_atom zc; /* z control (4F00) */
|
||||
struct r300_state_atom unk4F08; /* (4F08) */
|
||||
struct r300_state_atom unk4F10; /* (4F10) */
|
||||
@@ -308,7 +324,13 @@ struct r300_cmdbuf {
|
||||
/**
|
||||
* State cache
|
||||
*/
|
||||
|
||||
struct r300_depthbuffer_state {
|
||||
GLfloat scale;
|
||||
};
|
||||
|
||||
struct r300_state {
|
||||
struct r300_depthbuffer_state depth;
|
||||
};
|
||||
|
||||
|
||||
@@ -321,6 +343,11 @@ struct r300_context {
|
||||
struct r300_hw_state hw;
|
||||
struct r300_cmdbuf cmdbuf;
|
||||
struct r300_state state;
|
||||
|
||||
/* Vertex buffers */
|
||||
int elt_count; /* size of the buffer for vertices */
|
||||
int attrib_count; /* size of the buffer for vertex attributes.. Somehow it can be different ? */
|
||||
|
||||
};
|
||||
|
||||
#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
|
||||
|
184
src/mesa/drivers/dri/r300/r300_emit.h
Normal file
184
src/mesa/drivers/dri/r300/r300_emit.h
Normal file
@@ -0,0 +1,184 @@
|
||||
#ifndef __EMIT_H__
|
||||
#define __EMIT_H__
|
||||
#include "glheader.h"
|
||||
#include "r300_context.h"
|
||||
#include "r300_cmdbuf.h"
|
||||
|
||||
/* convenience macros */
|
||||
#define RADEON_CP_PACKET0 0x00000000
|
||||
#define RADEON_CP_PACKET1 0x40000000
|
||||
#define RADEON_CP_PACKET2 0x80000000
|
||||
#define RADEON_CP_PACKET3 0xC0000000
|
||||
|
||||
#define RADEON_CP_PACKET3_NOP 0xC0001000
|
||||
#define RADEON_CP_PACKET3_NEXT_CHAR 0xC0001900
|
||||
#define RADEON_CP_PACKET3_PLY_NEXTSCAN 0xC0001D00
|
||||
#define RADEON_CP_PACKET3_SET_SCISSORS 0xC0001E00
|
||||
#define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
|
||||
#define RADEON_CP_PACKET3_LOAD_MICROCODE 0xC0002400
|
||||
#define RADEON_CP_PACKET3_WAIT_FOR_IDLE 0xC0002600
|
||||
#define RADEON_CP_PACKET3_3D_DRAW_VBUF 0xC0002800
|
||||
#define RADEON_CP_PACKET3_3D_DRAW_IMMD 0xC0002900
|
||||
#define RADEON_CP_PACKET3_3D_DRAW_INDX 0xC0002A00
|
||||
#define RADEON_CP_PACKET3_LOAD_PALETTE 0xC0002C00
|
||||
#define RADEON_CP_PACKET3_3D_DRAW_VBUF_2 0xC0003400
|
||||
#define RADEON_CP_PACKET3_3D_DRAW_IMMD_2 0xC0003500
|
||||
#define RADEON_CP_PACKET3_3D_DRAW_INDX_2 0xC0003600
|
||||
#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
|
||||
#define RADEON_CP_PACKET3_CNTL_PAINT 0xC0009100
|
||||
#define RADEON_CP_PACKET3_CNTL_BITBLT 0xC0009200
|
||||
#define RADEON_CP_PACKET3_CNTL_SMALLTEXT 0xC0009300
|
||||
#define RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
|
||||
#define RADEON_CP_PACKET3_CNTL_POLYLINE 0xC0009500
|
||||
#define RADEON_CP_PACKET3_CNTL_POLYSCANLINES 0xC0009800
|
||||
#define RADEON_CP_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
|
||||
#define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
|
||||
#define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
|
||||
#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK 0xC0003202
|
||||
#define RADEON_CP_PACKET3_3D_CLEAR_CMASK 0xC0003802
|
||||
#define RADEON_CP_PACKET3_3D_CLEAR_HIZ 0xC0003702
|
||||
|
||||
#define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
|
||||
|
||||
/* Glue to R300 Mesa driver */
|
||||
#define LOCAL_VARS int cmd_reserved=0;\
|
||||
int cmd_written=0; \
|
||||
drm_radeon_cmd_header_t *cmd=NULL;
|
||||
|
||||
#define PREFIX_VOID r300ContextPtr rmesa
|
||||
|
||||
#define PREFIX PREFIX_VOID ,
|
||||
|
||||
#define PASS_PREFIX_VOID rmesa
|
||||
#define PASS_PREFIX rmesa ,
|
||||
|
||||
typedef GLuint CARD32;
|
||||
|
||||
/* This files defines functions for accessing R300 hardware.
|
||||
It needs to be customized to whatever code r300_lib.c is used
|
||||
in */
|
||||
|
||||
void static inline check_space(int dwords)
|
||||
{
|
||||
}
|
||||
|
||||
static __inline__ uint32_t cmducs(int reg, int count)
|
||||
{
|
||||
drm_r300_cmd_header_t cmd;
|
||||
|
||||
cmd.unchecked_state.cmd_type = R300_CMD_UNCHECKED_STATE;
|
||||
cmd.unchecked_state.count = count;
|
||||
cmd.unchecked_state.reghi = ((unsigned int)reg & 0xFF00) >> 8;
|
||||
cmd.unchecked_state.reglo = ((unsigned int)reg & 0x00FF);
|
||||
|
||||
return cmd.u;
|
||||
}
|
||||
|
||||
static __inline__ uint32_t cmdvpu(int addr, int count)
|
||||
{
|
||||
drm_r300_cmd_header_t cmd;
|
||||
|
||||
cmd.vpu.cmd_type = R300_CMD_VPU;
|
||||
cmd.vpu.count = count;
|
||||
cmd.vpu.adrhi = ((unsigned int)addr & 0xFF00) >> 8;
|
||||
cmd.vpu.adrlo = ((unsigned int)addr & 0x00FF);
|
||||
|
||||
return cmd.u;
|
||||
}
|
||||
|
||||
static __inline__ uint32_t cmdpacket3(int packet)
|
||||
{
|
||||
drm_r300_cmd_header_t cmd;
|
||||
|
||||
cmd.packet3.cmd_type = R300_CMD_PACKET3;
|
||||
cmd.packet3.packet = packet;
|
||||
|
||||
return cmd.u;
|
||||
}
|
||||
|
||||
/* Prepare to write a register value to register at address reg.
|
||||
If num_extra > 0 then the following extra values are written
|
||||
to registers with address +4, +8 and so on.. */
|
||||
#define reg_start(reg, num_extra) \
|
||||
{ \
|
||||
int _n; \
|
||||
_n=(num_extra); \
|
||||
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
|
||||
(_n+2), \
|
||||
__FUNCTION__); \
|
||||
cmd_reserved=_n+2; \
|
||||
cmd_written=1; \
|
||||
cmd[0].i=cmducs((reg), _n+1); \
|
||||
}
|
||||
|
||||
/* Prepare to write a register value to register at address reg.
|
||||
If num_extra > 0 then the following extra values are written
|
||||
into the same register. */
|
||||
/* It is here to permit r300_lib to compile and link anyway, but
|
||||
complain if actually called */
|
||||
#define reg_start_pump(reg, num_extra) \
|
||||
{ \
|
||||
fprintf(stderr, "I am not defined.. Error ! in %s::%s at line %d\n", \
|
||||
__FILE__, __FUNCTION__, __LINE__); \
|
||||
exit(-1); \
|
||||
}
|
||||
|
||||
/* Emit CARD32 freestyle*/
|
||||
#define e32(dword) { \
|
||||
if(cmd_written<cmd_reserved){\
|
||||
cmd[cmd_written].i=(dword); \
|
||||
cmd_written++; \
|
||||
} else { \
|
||||
fprintf(stderr, "e32 but no previous packet declaration.. Aborting! in %s::%s at line %d\n", \
|
||||
__FILE__, __FUNCTION__, __LINE__); \
|
||||
exit(-1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define efloat(f) e32(r300PackFloat32(f))
|
||||
|
||||
#define vsf_start_fragment(dest, length) \
|
||||
{ \
|
||||
int _n; \
|
||||
_n=(length); \
|
||||
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
|
||||
(_n+1), \
|
||||
__FUNCTION__); \
|
||||
cmd_reserved=_n+2; \
|
||||
cmd_written=1; \
|
||||
cmd[0].i=cmdvpu((dest), _n/4); \
|
||||
}
|
||||
|
||||
#define start_packet3(packet, count) \
|
||||
{ \
|
||||
int _n; \
|
||||
CARD32 _p; \
|
||||
_n=(count); \
|
||||
_p=(packet); \
|
||||
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
|
||||
(_n+3), \
|
||||
__FUNCTION__); \
|
||||
cmd_reserved=_n+3; \
|
||||
cmd_written=2; \
|
||||
if(_n>0x3fff) {\
|
||||
fprintf(stderr,"Too big packet3 %08x: cannot store %d dwords\n", \
|
||||
_p, _n); \
|
||||
exit(-1); \
|
||||
} \
|
||||
cmd[0].i=cmdpacket3(R300_CMD_PACKET3_RAW); \
|
||||
cmd[1].i=_p | ((_n & 0x3fff)<<16); \
|
||||
}
|
||||
|
||||
/* must be sent to switch to 2d commands */
|
||||
void static inline end_3d(PREFIX_VOID)
|
||||
{
|
||||
LOCAL_VARS
|
||||
|
||||
cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
|
||||
0, \
|
||||
__FUNCTION__); \
|
||||
|
||||
cmd[0].header.cmd_type=R300_CMD_END3D;
|
||||
}
|
||||
|
||||
#endif
|
@@ -17,14 +17,47 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
#define R300_SE_VPORT_ZOFFSET 0x1DAC
|
||||
|
||||
|
||||
// BEGIN: Wild guesses
|
||||
/* This register is written directly and also starts data section in many 3d CP_PACKET3's */
|
||||
#define R300_VAP_VF_CNTL 0x2084
|
||||
|
||||
# define R300_VAP_VF_CNTL__PRIM_TYPE__SHIFT 0
|
||||
# define R300_VAP_VF_CNTL__PRIM_NONE (0<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_POINTS (1<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_LINES (2<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_LINE_STRIP (3<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_TRIANGLES (4<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN (5<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP (6<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_LINE_LOOP (12<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_QUADS (13<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_QUAD_STRIP (14<<0)
|
||||
# define R300_VAP_VF_CNTL__PRIM_POLYGON (15<<0)
|
||||
|
||||
# define R300_VAP_VF_CNTL__PRIM_WALK__SHIFT 4
|
||||
/* State based - direct writes to registers trigger vertex generation */
|
||||
# define R300_VAP_VF_CNTL__PRIM_WALK_STATE_BASED (0<<4)
|
||||
# define R300_VAP_VF_CNTL__PRIM_WALK_INDICES (1<<4)
|
||||
# define R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST (2<<4)
|
||||
# define R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED (3<<4)
|
||||
|
||||
/* I don't think I saw these three used.. */
|
||||
# define R300_VAP_VF_CNTL__COLOR_ORDER__SHIFT 6
|
||||
# define R300_VAP_VF_CNTL__TCL_OUTPUT_CTL_ENA__SHIFT 9
|
||||
# define R300_VAP_VF_CNTL__PROG_STREAM_ENA__SHIFT 10
|
||||
|
||||
/* index size - when not set the indices are assumed to be 16 bit */
|
||||
# define R300_VAP_VF_CNTL__INDEX_SIZE_32bit (1<<11)
|
||||
/* number of vertices */
|
||||
# define R300_VAP_VF_CNTL__NUM_VERTICES__SHIFT 16
|
||||
|
||||
/* BEGIN: Wild guesses */
|
||||
#define R300_VAP_OUTPUT_VTX_FMT_0 0x2090
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT (1<<0)
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT (1<<1)
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2) // GUESS
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3) // GUESS
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4) // GUESS
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) // GUESS
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2) /* GUESS */
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3) /* GUESS */
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4) /* GUESS */
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
|
||||
|
||||
#define R300_VAP_OUTPUT_VTX_FMT_1 0x2094
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
|
||||
@@ -35,11 +68,24 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
|
||||
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
|
||||
// END
|
||||
/* END */
|
||||
|
||||
// BEGIN: Vertex data assembly - lots of uncertainties
|
||||
#define R300_SE_VTE_CNTL 0x20b0
|
||||
# define R300_VPORT_X_SCALE_ENA 0x00000001
|
||||
# define R300_VPORT_X_OFFSET_ENA 0x00000002
|
||||
# define R300_VPORT_Y_SCALE_ENA 0x00000004
|
||||
# define R300_VPORT_Y_OFFSET_ENA 0x00000008
|
||||
# define R300_VPORT_Z_SCALE_ENA 0x00000010
|
||||
# define R300_VPORT_Z_OFFSET_ENA 0x00000020
|
||||
# define R300_VTX_XY_FMT 0x00000100
|
||||
# define R300_VTX_Z_FMT 0x00000200
|
||||
# define R300_VTX_W0_FMT 0x00000400
|
||||
# define R300_VTX_W0_NORMALIZE 0x00000800
|
||||
# define R300_VTX_ST_DENORMALIZED 0x00001000
|
||||
|
||||
/* BEGIN: Vertex data assembly - lots of uncertainties */
|
||||
/* gap */
|
||||
// Where do we get our vertex data?
|
||||
/* Where do we get our vertex data?
|
||||
//
|
||||
// Vertex data either comes either from immediate mode registers or from
|
||||
// vertex arrays.
|
||||
@@ -60,29 +106,30 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// The corresponding input is routed into the register with the given index.
|
||||
// The list is ended by a word with INPUT_ROUTE_END set.
|
||||
//
|
||||
// Always set COMPONENTS_4 in immediate mode.
|
||||
// Always set COMPONENTS_4 in immediate mode. */
|
||||
|
||||
#define R300_VAP_INPUT_ROUTE_0_0 0x2150
|
||||
# define R300_INPUT_ROUTE_COMPONENTS_1 (0 << 0)
|
||||
# define R300_INPUT_ROUTE_COMPONENTS_2 (1 << 0)
|
||||
# define R300_INPUT_ROUTE_COMPONENTS_3 (2 << 0)
|
||||
# define R300_INPUT_ROUTE_COMPONENTS_4 (3 << 0)
|
||||
# define R300_INPUT_ROUTE_COMPONENTS_RGBA (4 << 0) // GUESS
|
||||
# define R300_INPUT_ROUTE_COMPONENTS_RGBA (4 << 0) /* GUESS */
|
||||
# define R300_VAP_INPUT_ROUTE_IDX_SHIFT 8
|
||||
# define R300_VAP_INPUT_ROUTE_IDX_MASK (31 << 8) // GUESS
|
||||
# define R300_VAP_INPUT_ROUTE_IDX_MASK (31 << 8) /* GUESS */
|
||||
# define R300_VAP_INPUT_ROUTE_END (1 << 13)
|
||||
# define R300_INPUT_ROUTE_IMMEDIATE_MODE (0 << 14) // GUESS
|
||||
# define R300_INPUT_ROUTE_FLOAT (1 << 14) // GUESS
|
||||
# define R300_INPUT_ROUTE_UNSIGNED_BYTE (2 << 14) // GUESS
|
||||
# define R300_INPUT_ROUTE_FLOAT_COLOR (3 << 14) // GUESS
|
||||
# define R300_INPUT_ROUTE_IMMEDIATE_MODE (0 << 14) /* GUESS */
|
||||
# define R300_INPUT_ROUTE_FLOAT (1 << 14) /* GUESS */
|
||||
# define R300_INPUT_ROUTE_UNSIGNED_BYTE (2 << 14) /* GUESS */
|
||||
# define R300_INPUT_ROUTE_FLOAT_COLOR (3 << 14) /* GUESS */
|
||||
#define R300_VAP_INPUT_ROUTE_0_1 0x2154
|
||||
#define R300_VAP_INPUT_ROUTE_0_2 0x2158
|
||||
#define R300_VAP_INPUT_ROUTE_0_3 0x215C
|
||||
|
||||
/* gap */
|
||||
// Notes:
|
||||
/* Notes:
|
||||
// - always set up to produce at least two attributes:
|
||||
// if vertex program uses only position, fglrx will set normal, too
|
||||
// - INPUT_CNTL_0_COLOR and INPUT_CNTL_COLOR bits are always equal
|
||||
// - INPUT_CNTL_0_COLOR and INPUT_CNTL_COLOR bits are always equal */
|
||||
#define R300_VAP_INPUT_CNTL_0 0x2180
|
||||
# define R300_INPUT_CNTL_0_COLOR 0x00000001
|
||||
#define R300_VAP_INPUT_CNTL_1 0x2184
|
||||
@@ -91,20 +138,20 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_INPUT_CNTL_COLOR 0x00000004
|
||||
# define R300_INPUT_CNTL_TC0 0x00000400
|
||||
# define R300_INPUT_CNTL_TC1 0x00000800
|
||||
# define R300_INPUT_CNTL_TC2 0x00001000 // GUESS
|
||||
# define R300_INPUT_CNTL_TC3 0x00002000 // GUESS
|
||||
# define R300_INPUT_CNTL_TC4 0x00004000 // GUESS
|
||||
# define R300_INPUT_CNTL_TC5 0x00008000 // GUESS
|
||||
# define R300_INPUT_CNTL_TC6 0x00010000 // GUESS
|
||||
# define R300_INPUT_CNTL_TC7 0x00020000 // GUESS
|
||||
# define R300_INPUT_CNTL_TC2 0x00001000 /* GUESS */
|
||||
# define R300_INPUT_CNTL_TC3 0x00002000 /* GUESS */
|
||||
# define R300_INPUT_CNTL_TC4 0x00004000 /* GUESS */
|
||||
# define R300_INPUT_CNTL_TC5 0x00008000 /* GUESS */
|
||||
# define R300_INPUT_CNTL_TC6 0x00010000 /* GUESS */
|
||||
# define R300_INPUT_CNTL_TC7 0x00020000 /* GUESS */
|
||||
|
||||
/* gap */
|
||||
// Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
|
||||
/* Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
|
||||
// are set to a swizzling bit pattern, other words are 0.
|
||||
//
|
||||
// In immediate mode, the pattern is always set to xyzw. In vertex array
|
||||
// mode, the swizzling pattern is e.g. used to set zw components in texture
|
||||
// coordinates with only tweo components.
|
||||
// coordinates with only tweo components. */
|
||||
#define R300_VAP_INPUT_ROUTE_1_0 0x21E0
|
||||
# define R300_INPUT_ROUTE_SELECT_X 0
|
||||
# define R300_INPUT_ROUTE_SELECT_Y 1
|
||||
@@ -122,10 +169,10 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
#define R300_VAP_INPUT_ROUTE_1_2 0x21E8
|
||||
#define R300_VAP_INPUT_ROUTE_1_3 0x21EC
|
||||
|
||||
// END
|
||||
/* END */
|
||||
|
||||
/* gap */
|
||||
// BEGIN: Upload vertex program and data
|
||||
/* BEGIN: Upload vertex program and data
|
||||
// The programmable vertex shader unit has a memory bank of unknown size
|
||||
// that can be written to in 16 byte units by writing the address into
|
||||
// UPLOAD_ADDRESS, followed by data in UPLOAD_DATA (multiples of 4 DWORDs).
|
||||
@@ -147,37 +194,37 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// as there is also the R300_RE_POINTSIZE register.
|
||||
//
|
||||
// Multiple vertex programs and parameter sets can be loaded at once,
|
||||
// which could explain the size discrepancy.
|
||||
// which could explain the size discrepancy. */
|
||||
#define R300_VAP_PVS_UPLOAD_ADDRESS 0x2200
|
||||
# define R300_PVS_UPLOAD_PROGRAM 0x00000000
|
||||
# define R300_PVS_UPLOAD_PARAMETERS 0x00000200
|
||||
# define R300_PVS_UPLOAD_POINTSIZE 0x00000406
|
||||
/* gap */
|
||||
#define R300_VAP_PVS_UPLOAD_DATA 0x2208
|
||||
// END
|
||||
/* END */
|
||||
|
||||
/* gap */
|
||||
// I do not know the purpose of this register. However, I do know that
|
||||
/* I do not know the purpose of this register. However, I do know that
|
||||
// it is set to 221C_CLEAR for clear operations and to 221C_NORMAL
|
||||
// for normal rendering.
|
||||
// for normal rendering. */
|
||||
#define R300_VAP_UNKNOWN_221C 0x221C
|
||||
# define R300_221C_NORMAL 0x00000000
|
||||
# define R300_221C_CLEAR 0x0001C000
|
||||
|
||||
/* gap */
|
||||
// Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
|
||||
/* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
|
||||
// rendering commands and overwriting vertex program parameters.
|
||||
// Therefore, I suspect writing zero to 0x2284 synchronizes the engine and
|
||||
// avoids bugs caused by still running shaders reading bad data from memory.
|
||||
#define R300_VAP_PVS_WAITIDLE 0x2284 // GUESS
|
||||
// avoids bugs caused by still running shaders reading bad data from memory. */
|
||||
#define R300_VAP_PVS_WAITIDLE 0x2284 /* GUESS */
|
||||
|
||||
// Absolutely no clue what this register is about.
|
||||
/* Absolutely no clue what this register is about. */
|
||||
#define R300_VAP_UNKNOWN_2288 0x2288
|
||||
# define R300_2288_R300 0x00750000 // -- nh
|
||||
# define R300_2288_RV350 0x0000FFFF // -- Vladimir
|
||||
# define R300_2288_R300 0x00750000 /* -- nh */
|
||||
# define R300_2288_RV350 0x0000FFFF /* -- Vladimir */
|
||||
|
||||
/* gap */
|
||||
// Addresses are relative to the vertex program instruction area of the
|
||||
/* Addresses are relative to the vertex program instruction area of the
|
||||
// memory bank. PROGRAM_END points to the last instruction of the active
|
||||
// program
|
||||
//
|
||||
@@ -185,58 +232,166 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// experiments so far have shown that both *must* point to an instruction
|
||||
// inside the vertex program, otherwise the GPU locks up.
|
||||
// fglrx usually sets CNTL_3_UNKNOWN to the end of the program and
|
||||
// CNTL_1_UNKNOWN somewhere in the middle, but the criteria are not clear.
|
||||
// CNTL_1_UNKNOWN somewhere in the middle, but the criteria are not clear. */
|
||||
#define R300_VAP_PVS_CNTL_1 0x22D0
|
||||
# define R300_PVS_CNTL_1_PROGRAM_START_SHIFT 0
|
||||
# define R300_PVS_CNTL_1_UNKNOWN_SHIFT 10
|
||||
# define R300_PVS_CNTL_1_PROGRAM_END_SHIFT 20
|
||||
// Addresses are relative the the vertex program parameters area.
|
||||
/* Addresses are relative the the vertex program parameters area. */
|
||||
#define R300_VAP_PVS_CNTL_2 0x22D4
|
||||
# define R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0
|
||||
# define R300_PVS_CNTL_2_PARAM_COUNT_SHIFT 16
|
||||
#define R300_VAP_PVS_CNTL_3 0x22D8
|
||||
# define R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT 10
|
||||
# define R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT 0
|
||||
|
||||
// The entire range from 0x2300 to 0x2AC inclusive seems to be used for
|
||||
// immediate vertices
|
||||
/* The entire range from 0x2300 to 0x2AC inclusive seems to be used for
|
||||
// immediate vertices */
|
||||
#define R300_VAP_VTX_COLOR_R 0x2464
|
||||
#define R300_VAP_VTX_COLOR_G 0x2468
|
||||
#define R300_VAP_VTX_COLOR_B 0x246C
|
||||
#define R300_VAP_VTX_POS_0_X_1 0x2490 // used for glVertex2*()
|
||||
#define R300_VAP_VTX_POS_0_X_1 0x2490 /* used for glVertex2*() */
|
||||
#define R300_VAP_VTX_POS_0_Y_1 0x2494
|
||||
#define R300_VAP_VTX_COLOR_PKD 0x249C // RGBA
|
||||
#define R300_VAP_VTX_POS_0_X_2 0x24A0 // used for glVertex3*()
|
||||
#define R300_VAP_VTX_COLOR_PKD 0x249C /* RGBA */
|
||||
#define R300_VAP_VTX_POS_0_X_2 0x24A0 /* used for glVertex3*() */
|
||||
#define R300_VAP_VTX_POS_0_Y_2 0x24A4
|
||||
#define R300_VAP_VTX_POS_0_Z_2 0x24A8
|
||||
#define R300_VAP_VTX_END_OF_PKT 0x24AC // write 0 to indicate end of packet?
|
||||
#define R300_VAP_VTX_END_OF_PKT 0x24AC /* write 0 to indicate end of packet? */
|
||||
|
||||
/* gap */
|
||||
// BEGIN: !unverified!
|
||||
#define R300_GB_TILE_CONFIG 0x4018
|
||||
#define R300_GB_TILE_ENABLE (1 << 0)
|
||||
#define R300_GB_TILE_PIPE_COUNT_R300 (0 << 1)
|
||||
#define R300_GB_TILE_PIPE_COUNT_RV300 (3 << 1)
|
||||
#define R300_GB_TILE_SIZE_8 (0 << 4)
|
||||
#define R300_GB_TILE_SIZE_16 (1 << 4)
|
||||
#define R300_GB_TILE_SIZE_32 (2 << 4)
|
||||
#define R300_GB_SUPER_SIZE_1 (0 << 6)
|
||||
#define R300_GB_SUPER_SIZE_2 (1 << 6)
|
||||
#define R300_GB_SUPER_SIZE_4 (2 << 6)
|
||||
#define R300_GB_SUPER_SIZE_8 (3 << 6)
|
||||
#define R300_GB_SUPER_SIZE_16 (4 << 6)
|
||||
#define R300_GB_SUPER_SIZE_32 (5 << 6)
|
||||
#define R300_GB_SUPER_SIZE_64 (6 << 6)
|
||||
#define R300_GB_SUPER_SIZE_128 (7 << 6)
|
||||
#define R300_GB_SUPER_X_SHIFT 9 // 3 bits wide
|
||||
#define R300_GB_SUPER_Y_SHIFT 12 // 3 bits wide
|
||||
#define R300_GB_SUPER_TILE_A (0 << 15)
|
||||
#define R300_GB_SUPER_TILE_B (1 << 15)
|
||||
#define R300_GB_SUBPIXEL_1_12 (0 << 16)
|
||||
#define R300_GB_SUBPIXEL_1_16 (1 << 16)
|
||||
// END
|
||||
|
||||
/* These are values from r300_reg/r300_reg.h - they are known to be correct
|
||||
and are here so we can use one register file instead of several
|
||||
- Vladimir */
|
||||
#define R300_GB_VAP_RASTER_VTX_FMT_0 0x4000
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__POS_PRESENT (1<<0)
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_0_PRESENT (1<<1)
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_1_PRESENT (1<<2)
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_2_PRESENT (1<<3)
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_3_PRESENT (1<<4)
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_SPACE (0xf<<5)
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_0__PT_SIZE_PRESENT (0x1<<16)
|
||||
|
||||
#define R300_GB_VAP_RASTER_VTX_FMT_1 0x4004
|
||||
/* each of the following is 3 bits wide, specifies number
|
||||
of components */
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
|
||||
# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
|
||||
|
||||
#define R300_GB_ENABLE 0x4008
|
||||
# define R300_GB_POINT_STUFF_ENABLE (1<<0)
|
||||
# define R300_GB_LINE_STUFF_ENABLE (1<<1)
|
||||
# define R300_GB_TRIANGLE_STUFF_ENABLE (1<<2)
|
||||
# define R300_GB_STENCIL_AUTO_ENABLE (1<<4)
|
||||
/* each of the following is 2 bits wide */
|
||||
#define R300_GB_TEX_REPLICATE 0
|
||||
#define R300_GB_TEX_ST 1
|
||||
#define R300_GB_TEX_STR 2
|
||||
# define R300_GB_TEX0_SOURCE_SHIFT 16
|
||||
# define R300_GB_TEX1_SOURCE_SHIFT 18
|
||||
# define R300_GB_TEX2_SOURCE_SHIFT 20
|
||||
# define R300_GB_TEX3_SOURCE_SHIFT 22
|
||||
# define R300_GB_TEX4_SOURCE_SHIFT 24
|
||||
# define R300_GB_TEX5_SOURCE_SHIFT 26
|
||||
# define R300_GB_TEX6_SOURCE_SHIFT 28
|
||||
# define R300_GB_TEX7_SOURCE_SHIFT 30
|
||||
|
||||
/* MSPOS - positions for multisample antialiasing (?) */
|
||||
#define R300_GB_MSPOS0 0x4010
|
||||
/* shifts - each of the fields is 4 bits */
|
||||
# define R300_GB_MSPOS0__MS_X0_SHIFT 0
|
||||
# define R300_GB_MSPOS0__MS_Y0_SHIFT 4
|
||||
# define R300_GB_MSPOS0__MS_X1_SHIFT 8
|
||||
# define R300_GB_MSPOS0__MS_Y1_SHIFT 12
|
||||
# define R300_GB_MSPOS0__MS_X2_SHIFT 16
|
||||
# define R300_GB_MSPOS0__MS_Y2_SHIFT 20
|
||||
# define R300_GB_MSPOS0__MSBD0_Y 24
|
||||
# define R300_GB_MSPOS0__MSBD0_X 28
|
||||
|
||||
#define R300_GB_MSPOS1 0x4014
|
||||
# define R300_GB_MSPOS1__MS_X3_SHIFT 0
|
||||
# define R300_GB_MSPOS1__MS_Y3_SHIFT 4
|
||||
# define R300_GB_MSPOS1__MS_X4_SHIFT 8
|
||||
# define R300_GB_MSPOS1__MS_Y4_SHIFT 12
|
||||
# define R300_GB_MSPOS1__MS_X5_SHIFT 16
|
||||
# define R300_GB_MSPOS1__MS_Y5_SHIFT 20
|
||||
# define R300_GB_MSPOS1__MSBD1 24
|
||||
|
||||
|
||||
#define R300_GB_TILE_CONFIG 0x4018
|
||||
# define R300_GB_TILE_ENABLE (1<<0)
|
||||
# define R300_GB_TILE_PIPE_COUNT_RV300 0
|
||||
# define R300_GB_TILE_PIPE_COUNT_R300 (3<<1)
|
||||
# define R300_GB_TILE_SIZE_8 0
|
||||
# define R300_GB_TILE_SIZE_16 (1<<4)
|
||||
# define R300_GB_TILE_SIZE_32 (2<<4)
|
||||
# define R300_GB_SUPER_SIZE_1 (0<<6)
|
||||
# define R300_GB_SUPER_SIZE_2 (1<<6)
|
||||
# define R300_GB_SUPER_SIZE_4 (2<<6)
|
||||
# define R300_GB_SUPER_SIZE_8 (3<<6)
|
||||
# define R300_GB_SUPER_SIZE_16 (4<<6)
|
||||
# define R300_GB_SUPER_SIZE_32 (5<<6)
|
||||
# define R300_GB_SUPER_SIZE_64 (6<<6)
|
||||
# define R300_GB_SUPER_SIZE_128 (7<<6)
|
||||
# define R300_GB_SUPER_X_SHIFT 9 /* 3 bits wide */
|
||||
# define R300_GB_SUPER_Y_SHIFT 12 /* 3 bits wide */
|
||||
# define R300_GB_SUPER_TILE_A 0
|
||||
# define R300_GB_SUPER_TILE_B (1<<15)
|
||||
# define R300_GB_SUBPIXEL_1_12 0
|
||||
# define R300_GB_SUBPIXEL_1_16 (1<<16)
|
||||
|
||||
#define R300_GB_FIFO_SIZE 0x4024
|
||||
/* each of the following is 2 bits wide */
|
||||
#define R300_GB_FIFO_SIZE_32 0
|
||||
#define R300_GB_FIFO_SIZE_64 1
|
||||
#define R300_GB_FIFO_SIZE_128 2
|
||||
#define R300_GB_FIFO_SIZE_256 3
|
||||
# define R300_SC_IFIFO_SIZE_SHIFT 0
|
||||
# define R300_SC_TZFIFO_SIZE_SHIFT 2
|
||||
# define R300_SC_BFIFO_SIZE_SHIFT 4
|
||||
|
||||
# define R300_US_OFIFO_SIZE_SHIFT 12
|
||||
# define R300_US_WFIFO_SIZE_SHIFT 14
|
||||
/* the following use the same constants as above, but meaning is
|
||||
is times 2 (i.e. instead of 32 words it means 64 */
|
||||
# define R300_RS_TFIFO_SIZE_SHIFT 6
|
||||
# define R300_RS_CFIFO_SIZE_SHIFT 8
|
||||
# define R300_US_RAM_SIZE_SHIFT 10
|
||||
/* watermarks, 3 bits wide */
|
||||
# define R300_RS_HIGHWATER_COL_SHIFT 16
|
||||
# define R300_RS_HIGHWATER_TEX_SHIFT 19
|
||||
# define R300_OFIFO_HIGHWATER_SHIFT 22 /* two bits only */
|
||||
# define R300_CUBE_FIFO_HIGHWATER_COL_SHIFT 24
|
||||
|
||||
#define R300_GB_SELECT 0x401C
|
||||
# define R300_GB_FOG_SELECT_C0A 0
|
||||
# define R300_GB_FOG_SELECT_C1A 1
|
||||
# define R300_GB_FOG_SELECT_C2A 2
|
||||
# define R300_GB_FOG_SELECT_C3A 3
|
||||
# define R300_GB_FOG_SELECT_1_1_W 4
|
||||
# define R300_GB_FOG_SELECT_Z 5
|
||||
# define R300_GB_DEPTH_SELECT_Z 0
|
||||
# define R300_GB_DEPTH_SELECT_1_1_W (1<<3)
|
||||
# define R300_GB_W_SELECT_1_W 0
|
||||
# define R300_GB_W_SELECT_1 (1<<4)
|
||||
|
||||
#define R300_GB_AA_CONFIG 0x4020
|
||||
# define R300_AA_ENABLE 0x01
|
||||
# define R300_AA_SUBSAMPLES_2 0
|
||||
# define R300_AA_SUBSAMPLES_3 (1<<1)
|
||||
# define R300_AA_SUBSAMPLES_4 (2<<1)
|
||||
# define R300_AA_SUBSAMPLES_6 (3<<1)
|
||||
|
||||
/* END */
|
||||
|
||||
/* gap */
|
||||
// The upper enable bits are guessed, based on fglrx reported limits.
|
||||
/* The upper enable bits are guessed, based on fglrx reported limits. */
|
||||
#define R300_TX_ENABLE 0x4104
|
||||
# define R300_TX_ENABLE_0 (1 << 0)
|
||||
# define R300_TX_ENABLE_1 (1 << 1)
|
||||
@@ -255,14 +410,21 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_TX_ENABLE_14 (1 << 14)
|
||||
# define R300_TX_ENABLE_15 (1 << 15)
|
||||
|
||||
// The pointsize is given in multiples of 6. The pointsize can be
|
||||
/* The pointsize is given in multiples of 6. The pointsize can be
|
||||
// enormous: Clear() renders a single point that fills the entire
|
||||
// framebuffer.
|
||||
// framebuffer. */
|
||||
#define R300_RE_POINTSIZE 0x421C
|
||||
# define R300_POINTSIZE_Y_SHIFT 0
|
||||
# define R300_POINTSIZE_Y_MASK (0xFFFF << 0) // GUESS
|
||||
# define R300_POINTSIZE_Y_MASK (0xFFFF << 0) /* GUESS */
|
||||
# define R300_POINTSIZE_X_SHIFT 16
|
||||
# define R300_POINTSIZE_X_MASK (0xFFFF << 16) // GUESS
|
||||
# define R300_POINTSIZE_X_MASK (0xFFFF << 16) /* GUESS */
|
||||
|
||||
/* This register needs to be set to (1<<1) for RV350 to correctly
|
||||
perform depth test (see --vb-triangles in r300_demo)
|
||||
Don't know about other chips. - Vladimir
|
||||
*/
|
||||
#define R300_RE_OCCLUSION_CNTL 0x42B4
|
||||
# define R300_OCCLUSION_ON (1<<1)
|
||||
|
||||
#define R300_RE_CULL_CNTL 0x42B8
|
||||
# define R300_CULL_FRONT (1 << 0)
|
||||
@@ -271,21 +433,21 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_FRONT_FACE_CW (1 << 2)
|
||||
|
||||
|
||||
// BEGIN: Rasterization / Interpolators - many guesses
|
||||
/* BEGIN: Rasterization / Interpolators - many guesses
|
||||
// So far, 0_UNKOWN_7 has always been set.
|
||||
// 0_UNKNOWN_18 has always been set except for clear operations.
|
||||
// TC_CNT is the number of incoming texture coordinate sets (i.e. it depends
|
||||
// on the vertex program, *not* the fragment program)
|
||||
// on the vertex program, *not* the fragment program) */
|
||||
#define R300_RS_CNTL_0 0x4300
|
||||
# define R300_RS_CNTL_TC_CNT_SHIFT 2
|
||||
# define R300_RS_CNTL_TC_CNT_MASK (7 << 2)
|
||||
# define R300_RS_CNTL_0_UNKNOWN_7 (1 << 7)
|
||||
# define R300_RS_CNTL_0_UNKNOWN_18 (1 << 18)
|
||||
// Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n register.
|
||||
/* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n register. */
|
||||
#define R300_RS_CNTL_1 0x4304
|
||||
|
||||
/* gap */
|
||||
// Only used for texture coordinates (color seems to be always interpolated).
|
||||
/* Only used for texture coordinates (color seems to be always interpolated).
|
||||
// Use the source field to route texture coordinate input from the vertex program
|
||||
// to the desired interpolator. Note that the source field is relative to the
|
||||
// outputs the vertex program *actually* writes. If a vertex program only writes
|
||||
@@ -295,7 +457,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// I haven't seen it used that way.
|
||||
//
|
||||
// Note: The _UNKNOWN constants are always set in their respective register.
|
||||
// I don't know if this is necessary.
|
||||
// I don't know if this is necessary. */
|
||||
#define R300_RS_INTERP_0 0x4310
|
||||
#define R300_RS_INTERP_1 0x4314
|
||||
# define R300_RS_INTERP_1_UNKNOWN 0x40
|
||||
@@ -311,37 +473,37 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_RS_INTERP_SRC_MASK (7 << 2)
|
||||
# define R300_RS_INTERP_USED 0x00D10000
|
||||
|
||||
// These DWORDs control how vertex data is routed into fragment program
|
||||
// registers, after interpolators.
|
||||
/* These DWORDs control how vertex data is routed into fragment program
|
||||
// registers, after interpolators. */
|
||||
#define R300_RS_ROUTE_0 0x4330
|
||||
#define R300_RS_ROUTE_1 0x4334
|
||||
#define R300_RS_ROUTE_2 0x4338
|
||||
#define R300_RS_ROUTE_3 0x433C // GUESS
|
||||
#define R300_RS_ROUTE_4 0x4340 // GUESS
|
||||
#define R300_RS_ROUTE_5 0x4344 // GUESS
|
||||
#define R300_RS_ROUTE_6 0x4348 // GUESS
|
||||
#define R300_RS_ROUTE_7 0x434C // GUESS
|
||||
#define R300_RS_ROUTE_3 0x433C /* GUESS */
|
||||
#define R300_RS_ROUTE_4 0x4340 /* GUESS */
|
||||
#define R300_RS_ROUTE_5 0x4344 /* GUESS */
|
||||
#define R300_RS_ROUTE_6 0x4348 /* GUESS */
|
||||
#define R300_RS_ROUTE_7 0x434C /* GUESS */
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_0 0
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_1 1
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_2 2
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_3 3
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_4 4
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_5 5 // GUESS
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_6 6 // GUESS
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_7 7 // GUESS
|
||||
# define R300_RS_ROUTE_ENABLE (1 << 3) // GUESS
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_5 5 /* GUESS */
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_6 6 /* GUESS */
|
||||
# define R300_RS_ROUTE_SOURCE_INTERP_7 7 /* GUESS */
|
||||
# define R300_RS_ROUTE_ENABLE (1 << 3) /* GUESS */
|
||||
# define R300_RS_ROUTE_DEST_SHIFT 6
|
||||
# define R300_RS_ROUTE_DEST_MASK (31 << 6) // GUESS
|
||||
# define R300_RS_ROUTE_DEST_MASK (31 << 6) /* GUESS */
|
||||
|
||||
// Special handling for color: When the fragment program uses color,
|
||||
/* Special handling for color: When the fragment program uses color,
|
||||
// the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
|
||||
// color register index.
|
||||
// color register index. */
|
||||
# define R300_RS_ROUTE_0_COLOR (1 << 14)
|
||||
# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT (1 << 17)
|
||||
# define R300_RS_ROUTE_0_COLOR_DEST_MASK (31 << 6) // GUESS
|
||||
// END
|
||||
# define R300_RS_ROUTE_0_COLOR_DEST_MASK (31 << 6) /* GUESS */
|
||||
/* END */
|
||||
|
||||
// BEGIN: Scissors and cliprects
|
||||
/* BEGIN: Scissors and cliprects
|
||||
// There are four clipping rectangles. Their corner coordinates are inclusive.
|
||||
// Every pixel is assigned a number from 0 and 15 by setting bits 0-3 depending
|
||||
// on whether the pixel is inside cliprects 0-3, respectively. For example,
|
||||
@@ -354,7 +516,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// scissors rectangle are drawn. (coordinates are inclusive)
|
||||
//
|
||||
// For some reason, the top-left corner of the framebuffer is at (1440, 1440)
|
||||
// for the purpose of clipping and scissors.
|
||||
// for the purpose of clipping and scissors. */
|
||||
#define R300_RE_CLIPRECT_TL_0 0x43B0
|
||||
#define R300_RE_CLIPRECT_BR_0 0x43B4
|
||||
#define R300_RE_CLIPRECT_TL_1 0x43B8
|
||||
@@ -395,12 +557,12 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_SCISSORS_X_MASK (0x1FFF << 0)
|
||||
# define R300_SCISSORS_Y_SHIFT 13
|
||||
# define R300_SCISSORS_Y_MASK (0x1FFF << 13)
|
||||
// END
|
||||
/* END */
|
||||
|
||||
// BEGIN: Texture specification
|
||||
/* BEGIN: Texture specification
|
||||
// The texture specification dwords are grouped by meaning and not by texture unit.
|
||||
// This means that e.g. the offset for texture image unit N is found in register
|
||||
// TX_OFFSET_0 + (4*N)
|
||||
// TX_OFFSET_0 + (4*N) */
|
||||
#define R300_TX_FILTER_0 0x4400
|
||||
# define R300_TX_REPEAT 0
|
||||
# define R300_TX_CLAMP_TO_EDGE 1
|
||||
@@ -422,23 +584,23 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_TX_WIDTHMASK_MASK (2047 << 0)
|
||||
# define R300_TX_HEIGHTMASK_SHIFT 11
|
||||
# define R300_TX_HEIGHTMASK_MASK (2047 << 11)
|
||||
# define R300_TX_SIZE_SHIFT 26 // largest of width, height
|
||||
# define R300_TX_SIZE_SHIFT 26 /* largest of width, height */
|
||||
# define R300_TX_SIZE_MASK (15 << 26)
|
||||
#define R300_TX_FORMAT_0 0x44C0
|
||||
#define R300_TX_OFFSET_0 0x4540
|
||||
// BEGIN: Guess from R200
|
||||
/* BEGIN: Guess from R200 */
|
||||
# define R300_TXO_ENDIAN_NO_SWAP (0 << 0)
|
||||
# define R300_TXO_ENDIAN_BYTE_SWAP (1 << 0)
|
||||
# define R300_TXO_ENDIAN_WORD_SWAP (2 << 0)
|
||||
# define R300_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
|
||||
# define R300_TXO_OFFSET_MASK 0xffffffe0
|
||||
# define R300_TXO_OFFSET_SHIFT 5
|
||||
// END
|
||||
/* END */
|
||||
#define R300_TX_UNK4_0 0x4580
|
||||
#define R300_TX_UNK5_0 0x45C0
|
||||
// END
|
||||
/* END */
|
||||
|
||||
// BEGIN: Fragment program instruction set
|
||||
/* BEGIN: Fragment program instruction set
|
||||
// Fragment programs are written directly into register space.
|
||||
// There are separate instruction streams for texture instructions and ALU
|
||||
// instructions.
|
||||
@@ -453,32 +615,32 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// 1 node, a value of 3 means 4 nodes.
|
||||
// The total amount of instructions is defined in PFS_CNTL_2. The offsets are
|
||||
// offsets into the respective instruction streams, while *_END points to the
|
||||
// last instruction relative to this offset.
|
||||
// last instruction relative to this offset. */
|
||||
#define R300_PFS_CNTL_0 0x4600
|
||||
# define R300_PFS_CNTL_LAST_NODES_SHIFT 0
|
||||
# define R300_PFS_CNTL_LAST_NODES_MASK (3 << 0)
|
||||
# define R300_PFS_CNTL_FIRST_NODE_HAS_TEX (1 << 3)
|
||||
#define R300_PFS_CNTL_1 0x4604
|
||||
// There is an unshifted value here which has so far always been equal to the
|
||||
// index of the highest used temporary register.
|
||||
/* There is an unshifted value here which has so far always been equal to the
|
||||
// index of the highest used temporary register. */
|
||||
#define R300_PFS_CNTL_2 0x4608
|
||||
# define R300_PFS_CNTL_ALU_OFFSET_SHIFT 0
|
||||
# define R300_PFS_CNTL_ALU_OFFSET_MASK (63 << 0)
|
||||
# define R300_PFS_CNTL_ALU_END_SHIFT 6
|
||||
# define R300_PFS_CNTL_ALU_END_MASK (63 << 0)
|
||||
# define R300_PFS_CNTL_TEX_OFFSET_SHIFT 12
|
||||
# define R300_PFS_CNTL_TEX_OFFSET_MASK (31 << 12) // GUESS
|
||||
# define R300_PFS_CNTL_TEX_OFFSET_MASK (31 << 12) /* GUESS */
|
||||
# define R300_PFS_CNTL_TEX_END_SHIFT 18
|
||||
# define R300_PFS_CNTL_TEX_END_MASK (31 << 18) // GUESS
|
||||
# define R300_PFS_CNTL_TEX_END_MASK (31 << 18) /* GUESS */
|
||||
|
||||
/* gap */
|
||||
// Nodes are stored backwards. The last active node is always stored in
|
||||
/* Nodes are stored backwards. The last active node is always stored in
|
||||
// PFS_NODE_3.
|
||||
// Example: In a 2-node program, NODE_0 and NODE_1 are set to 0. The
|
||||
// first node is stored in NODE_2, the second node is stored in NODE_3.
|
||||
//
|
||||
// Offsets are relative to the master offset from PFS_CNTL_2.
|
||||
// LAST_NODE is set for the last node, and only for the last node.
|
||||
// LAST_NODE is set for the last node, and only for the last node. */
|
||||
#define R300_PFS_NODE_0 0x4610
|
||||
#define R300_PFS_NODE_1 0x4614
|
||||
#define R300_PFS_NODE_2 0x4618
|
||||
@@ -493,20 +655,20 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_PFS_NODE_TEX_END_MASK (31 << 17)
|
||||
# define R300_PFS_NODE_LAST_NODE (1 << 22)
|
||||
|
||||
// TEX
|
||||
/* TEX
|
||||
// As far as I can tell, texture instructions cannot write into output
|
||||
// registers directly. A subsequent ALU instruction is always necessary,
|
||||
// even if it's just MAD o0, r0, 1, 0
|
||||
// even if it's just MAD o0, r0, 1, 0 */
|
||||
#define R300_PFS_TEXI_0 0x4620
|
||||
# define R300_FPITX_SRC_SHIFT 0
|
||||
# define R300_FPITX_SRC_MASK (31 << 0)
|
||||
# define R300_FPITX_SRC_CONST (1 << 5) // GUESS
|
||||
# define R300_FPITX_SRC_CONST (1 << 5) /* GUESS */
|
||||
# define R300_FPITX_DST_SHIFT 6
|
||||
# define R300_FPITX_DST_MASK (31 << 6)
|
||||
# define R300_FPITX_IMAGE_SHIFT 11
|
||||
# define R300_FPITX_IMAGE_MASK (15 << 11) // GUESS based on layout and native limits
|
||||
# define R300_FPITX_IMAGE_MASK (15 << 11) /* GUESS based on layout and native limits */
|
||||
|
||||
// ALU
|
||||
/* ALU
|
||||
// The ALU instructions register blocks are enumerated according to the order
|
||||
// in which fglrx. I assume there is space for 64 instructions, since
|
||||
// each block has space for a maximum of 64 DWORDs, and this matches reported
|
||||
@@ -556,7 +718,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// The destination register index is in FPI1 (color) and FPI3 (alpha) together
|
||||
// with enable bits.
|
||||
// There are separate enable bits for writing into temporary registers
|
||||
// (DSTC_REG_*/DSTA_REG) and and program output registers (DSTC_OUTPUT_*/DSTA_OUTPUT).
|
||||
// (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_* /DSTA_OUTPUT).
|
||||
// You can write to both at once, or not write at all (the same index
|
||||
// must be used for both).
|
||||
//
|
||||
@@ -565,7 +727,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// - Operation is MAD
|
||||
// - ARG1 is set to ARGC_SRC1C_LRP/ARGC_SRC1A_LRP
|
||||
// - Set FPI0/FPI2_SPECIAL_LRP
|
||||
// Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD
|
||||
// Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD */
|
||||
#define R300_PFS_INSTR1_0 0x46C0
|
||||
# define R300_FPI1_SRC0C_SHIFT 0
|
||||
# define R300_FPI1_SRC0C_MASK (31 << 0)
|
||||
@@ -619,7 +781,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_FPI0_ARGC_SRC1C_LRP 15
|
||||
# define R300_FPI0_ARGC_ZERO 20
|
||||
# define R300_FPI0_ARGC_ONE 21
|
||||
# define R300_FPI0_ARGC_HALF 22 // GUESS
|
||||
# define R300_FPI0_ARGC_HALF 22 /* GUESS */
|
||||
# define R300_FPI0_ARGC_SRC0C_YZX 23
|
||||
# define R300_FPI0_ARGC_SRC1C_YZX 24
|
||||
# define R300_FPI0_ARGC_SRC2C_YZX 25
|
||||
@@ -670,7 +832,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_FPI2_ARGA_SRC1A_LRP 15
|
||||
# define R300_FPI2_ARGA_ZERO 16
|
||||
# define R300_FPI2_ARGA_ONE 17
|
||||
# define R300_FPI2_ARGA_HALF 18 // GUESS
|
||||
# define R300_FPI2_ARGA_HALF 18 /* GUESS */
|
||||
|
||||
# define R300_FPI2_ARG0A_SHIFT 0
|
||||
# define R300_FPI2_ARG0A_MASK (31 << 0)
|
||||
@@ -694,7 +856,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_FPI2_OUTA_RSQ (11 << 23)
|
||||
# define R300_FPI2_OUTA_SAT (1 << 30)
|
||||
# define R300_FPI2_UNKNOWN_31 (1 << 31)
|
||||
// END
|
||||
/* END */
|
||||
|
||||
/* gap */
|
||||
#define R300_PP_ALPHA_TEST 0x4BD4
|
||||
@@ -711,22 +873,22 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
# define R300_ALPHA_TEST_ENABLE (1 << 11)
|
||||
|
||||
/* gap */
|
||||
// Fragment program parameters in 7.16 floating point
|
||||
/* Fragment program parameters in 7.16 floating point */
|
||||
#define R300_PFS_PARAM_0_X 0x4C00
|
||||
#define R300_PFS_PARAM_0_Y 0x4C04
|
||||
#define R300_PFS_PARAM_0_Z 0x4C08
|
||||
#define R300_PFS_PARAM_0_W 0x4C0C
|
||||
// GUESS: PARAM_31 is last, based on native limits reported by fglrx
|
||||
/* GUESS: PARAM_31 is last, based on native limits reported by fglrx */
|
||||
#define R300_PFS_PARAM_31_X 0x4DF0
|
||||
#define R300_PFS_PARAM_31_Y 0x4DF4
|
||||
#define R300_PFS_PARAM_31_Z 0x4DF8
|
||||
#define R300_PFS_PARAM_31_W 0x4DFC
|
||||
|
||||
// Notes:
|
||||
/* Notes:
|
||||
// - AFAIK fglrx always sets BLEND_UNKNOWN when blending is used in the application
|
||||
// - AFAIK fglrx always sets BLEND_NO_SEPARATE when CBLEND and ABLEND are set to the same
|
||||
// function (both registers are always set up completely in any case)
|
||||
// - Most blend flags are simply copied from R200 and not tested yet
|
||||
// - Most blend flags are simply copied from R200 and not tested yet */
|
||||
#define R300_RB3D_CBLEND 0x4E04
|
||||
#define R300_RB3D_ABLEND 0x4E08
|
||||
/* the following only appear in CBLEND */
|
||||
@@ -770,61 +932,63 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
|
||||
/* gap */
|
||||
#define R300_RB3D_COLOROFFSET0 0x4E28
|
||||
# define R300_COLOROFFSET_MASK 0xFFFFFFF0 // GUESS
|
||||
#define R300_RB3D_COLOROFFSET1 0x4E2C // GUESS
|
||||
#define R300_RB3D_COLOROFFSET2 0x4E30 // GUESS
|
||||
#define R300_RB3D_COLOROFFSET3 0x4E34 // GUESS
|
||||
# define R300_COLOROFFSET_MASK 0xFFFFFFF0 /* GUESS */
|
||||
#define R300_RB3D_COLOROFFSET1 0x4E2C /* GUESS */
|
||||
#define R300_RB3D_COLOROFFSET2 0x4E30 /* GUESS */
|
||||
#define R300_RB3D_COLOROFFSET3 0x4E34 /* GUESS */
|
||||
/* gap */
|
||||
// Bit 16: Larger tiles
|
||||
/* Bit 16: Larger tiles
|
||||
// Bit 17: 4x2 tiles
|
||||
// Bit 18: Extremely weird tile like, but some pixels duplicated?
|
||||
// Bit 18: Extremely weird tile like, but some pixels duplicated? */
|
||||
#define R300_RB3D_COLORPITCH0 0x4E38
|
||||
# define R300_COLORPITCH_MASK 0x00001FF8 // GUESS
|
||||
# define R300_COLOR_TILE_ENABLE (1 << 16) // GUESS
|
||||
# define R300_COLOR_MICROTILE_ENABLE (1 << 17) // GUESS
|
||||
# define R300_COLOR_ENDIAN_NO_SWAP (0 << 18) // GUESS
|
||||
# define R300_COLOR_ENDIAN_WORD_SWAP (1 << 18) // GUESS
|
||||
# define R300_COLOR_ENDIAN_DWORD_SWAP (2 << 18) // GUESS
|
||||
# define R300_COLOR_UNKNOWN_22_23 (3 << 22) // GUESS: Format?
|
||||
#define R300_RB3D_COLORPITCH1 0x4E3C // GUESS
|
||||
#define R300_RB3D_COLORPITCH2 0x4E40 // GUESS
|
||||
#define R300_RB3D_COLORPITCH3 0x4E44 // GUESS
|
||||
# define R300_COLORPITCH_MASK 0x00001FF8 /* GUESS */
|
||||
# define R300_COLOR_TILE_ENABLE (1 << 16) /* GUESS */
|
||||
# define R300_COLOR_MICROTILE_ENABLE (1 << 17) /* GUESS */
|
||||
# define R300_COLOR_ENDIAN_NO_SWAP (0 << 18) /* GUESS */
|
||||
# define R300_COLOR_ENDIAN_WORD_SWAP (1 << 18) /* GUESS */
|
||||
# define R300_COLOR_ENDIAN_DWORD_SWAP (2 << 18) /* GUESS */
|
||||
# define R300_COLOR_UNKNOWN_22_23 (3 << 22) /* GUESS: Format? */
|
||||
#define R300_RB3D_COLORPITCH1 0x4E3C /* GUESS */
|
||||
#define R300_RB3D_COLORPITCH2 0x4E40 /* GUESS */
|
||||
#define R300_RB3D_COLORPITCH3 0x4E44 /* GUESS */
|
||||
|
||||
/* gap */
|
||||
// Guess by Vladimir.
|
||||
// Set to 0A before 3D operations, set to 02 afterwards.
|
||||
/* Guess by Vladimir.
|
||||
// Set to 0A before 3D operations, set to 02 afterwards. */
|
||||
#define R300_RB3D_DSTCACHE_CTLSTAT 0x4E4C
|
||||
# define R300_RB3D_DSTCACHE_02 0x00000002
|
||||
# define R300_RB3D_DSTCACHE_0A 0x0000000A
|
||||
|
||||
/* gap */
|
||||
// There seems to be no "write only" setting, so use Z-test = ALWAYS for this.
|
||||
/* There seems to be no "write only" setting, so use Z-test = ALWAYS for this. */
|
||||
/* Bit (1<<8) is the "test" bit. so plain write is 6 - vd */
|
||||
#define R300_RB3D_ZCNTL_0 0x4F00
|
||||
# define R300_RB3D_Z_DISABLED_1 0x00000010 // GUESS
|
||||
# define R300_RB3D_Z_DISABLED_2 0x00000014 // GUESS
|
||||
# define R300_RB3D_Z_DISABLED_1 0x00000010 /* GUESS */
|
||||
# define R300_RB3D_Z_DISABLED_2 0x00000014 /* GUESS */
|
||||
# define R300_RB3D_Z_TEST 0x00000012
|
||||
# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016
|
||||
# define R300_RB3D_Z_WRITE_ONLY 0x00000006
|
||||
#define R300_RB3D_ZCNTL_1 0x4F04
|
||||
# define R300_Z_TEST_NEVER (0 << 0) // GUESS (based on R200)
|
||||
# define R300_Z_TEST_NEVER (0 << 0) /* GUESS (based on R200) */
|
||||
# define R300_Z_TEST_LESS (1 << 0)
|
||||
# define R300_Z_TEST_LEQUAL (2 << 0)
|
||||
# define R300_Z_TEST_EQUAL (3 << 0) // GUESS
|
||||
# define R300_Z_TEST_GEQUAL (4 << 0) // GUESS
|
||||
# define R300_Z_TEST_GREATER (5 << 0) // GUESS
|
||||
# define R300_Z_TEST_EQUAL (3 << 0) /* GUESS */
|
||||
# define R300_Z_TEST_GEQUAL (4 << 0) /* GUESS */
|
||||
# define R300_Z_TEST_GREATER (5 << 0) /* GUESS */
|
||||
# define R300_Z_TEST_NEQUAL (6 << 0)
|
||||
# define R300_Z_TEST_ALWAYS (7 << 0)
|
||||
# define R300_Z_TEST_MASK (7 << 0)
|
||||
/* gap */
|
||||
#define R300_RB3D_DEPTHOFFSET 0x4F20
|
||||
#define R300_RB3D_DEPTHPITCH 0x4F24
|
||||
# define R300_DEPTHPITCH_MASK 0x00001FF8 // GUESS
|
||||
# define R300_DEPTH_TILE_ENABLE (1 << 16) // GUESS
|
||||
# define R300_DEPTH_MICROTILE_ENABLE (1 << 17) // GUESS
|
||||
# define R300_DEPTH_ENDIAN_NO_SWAP (0 << 18) // GUESS
|
||||
# define R300_DEPTH_ENDIAN_WORD_SWAP (1 << 18) // GUESS
|
||||
# define R300_DEPTH_ENDIAN_DWORD_SWAP (2 << 18) // GUESS
|
||||
# define R300_DEPTHPITCH_MASK 0x00001FF8 /* GUESS */
|
||||
# define R300_DEPTH_TILE_ENABLE (1 << 16) /* GUESS */
|
||||
# define R300_DEPTH_MICROTILE_ENABLE (1 << 17) /* GUESS */
|
||||
# define R300_DEPTH_ENDIAN_NO_SWAP (0 << 18) /* GUESS */
|
||||
# define R300_DEPTH_ENDIAN_WORD_SWAP (1 << 18) /* GUESS */
|
||||
# define R300_DEPTH_ENDIAN_DWORD_SWAP (2 << 18) /* GUESS */
|
||||
|
||||
// BEGIN: Vertex program instruction set
|
||||
/* BEGIN: Vertex program instruction set
|
||||
// Every instruction is four dwords long:
|
||||
// DWORD 0: output and opcode
|
||||
// DWORD 1: first argument
|
||||
@@ -851,7 +1015,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
// Second argument: xyzx
|
||||
// Third argument: xyzw
|
||||
// Whenever the result is used later in the fragment program, fglrx forces x and w
|
||||
// to be 1.0 in the input selection; I don't know whether this is strictly necessary
|
||||
// to be 1.0 in the input selection; I don't know whether this is strictly necessary */
|
||||
#define R300_VPI_OUT_OP_DOT (1 << 0)
|
||||
#define R300_VPI_OUT_OP_MUL (2 << 0)
|
||||
#define R300_VPI_OUT_OP_ADD (3 << 0)
|
||||
@@ -876,7 +1040,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
#define R300_VPI_OUT_REG_CLASS_MASK (31 << 8)
|
||||
|
||||
#define R300_VPI_OUT_REG_INDEX_SHIFT 13
|
||||
#define R300_VPI_OUT_REG_INDEX_MASK (31 << 13) // GUESS based on fglrx native limits
|
||||
#define R300_VPI_OUT_REG_INDEX_MASK (31 << 13) /* GUESS based on fglrx native limits */
|
||||
|
||||
#define R300_VPI_OUT_WRITE_X (1 << 20)
|
||||
#define R300_VPI_OUT_WRITE_Y (1 << 21)
|
||||
@@ -887,14 +1051,14 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
#define R300_VPI_IN_REG_CLASS_ATTRIBUTE (1 << 0)
|
||||
#define R300_VPI_IN_REG_CLASS_PARAMETER (2 << 0)
|
||||
#define R300_VPI_IN_REG_CLASS_NONE (9 << 0)
|
||||
#define R300_VPI_IN_REG_CLASS_MASK (31 << 0) // GUESS
|
||||
#define R300_VPI_IN_REG_CLASS_MASK (31 << 0) /* GUESS */
|
||||
|
||||
#define R300_VPI_IN_REG_INDEX_SHIFT 5
|
||||
#define R300_VPI_IN_REG_INDEX_MASK (255 << 5) // GUESS based on fglrx native limits
|
||||
#define R300_VPI_IN_REG_INDEX_MASK (255 << 5) /* GUESS based on fglrx native limits */
|
||||
|
||||
// The R300 can select components from the input register arbitrarily.
|
||||
/* The R300 can select components from the input register arbitrarily.
|
||||
// Use the following constants, shifted by the component shift you
|
||||
// want to select
|
||||
// want to select */
|
||||
#define R300_VPI_IN_SELECT_X 0
|
||||
#define R300_VPI_IN_SELECT_Y 1
|
||||
#define R300_VPI_IN_SELECT_Z 2
|
||||
@@ -912,6 +1076,6 @@ I am fairly certain that they are correct unless stated otherwise in comments.
|
||||
#define R300_VPI_IN_NEG_Y (1 << 26)
|
||||
#define R300_VPI_IN_NEG_Z (1 << 27)
|
||||
#define R300_VPI_IN_NEG_W (1 << 28)
|
||||
// END
|
||||
/* END */
|
||||
|
||||
#endif // _R300_REG_H
|
||||
#endif /* _R300_REG_H */
|
||||
|
@@ -53,6 +53,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "r300_reg.h"
|
||||
#include "r300_program.h"
|
||||
|
||||
#include "r300_lib.h"
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Hardware rasterization
|
||||
@@ -61,6 +63,585 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* rasterization hardware for rendering.
|
||||
**********************************************************************/
|
||||
|
||||
static int r300_get_primitive_type(r300ContextPtr rmesa,
|
||||
GLcontext *ctx,
|
||||
int start,
|
||||
int end,
|
||||
int prim)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
int type=-1, min_vertices=0;
|
||||
char *name="UNKNOWN";
|
||||
|
||||
if(end<=start)return -1; /* do we need to watch for this ? */
|
||||
|
||||
switch (prim & PRIM_MODE_MASK) {
|
||||
case GL_POINTS:
|
||||
name="P";
|
||||
type=R300_VAP_VF_CNTL__PRIM_POINTS;
|
||||
min_vertices=1;
|
||||
break;
|
||||
case GL_LINES:
|
||||
name="L";
|
||||
type=R300_VAP_VF_CNTL__PRIM_LINES;
|
||||
min_vertices=2;
|
||||
break;
|
||||
case GL_LINE_STRIP:
|
||||
name="LS";
|
||||
type=R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
|
||||
min_vertices=2;
|
||||
break;
|
||||
case GL_LINE_LOOP:
|
||||
name="LL";
|
||||
min_vertices=2;
|
||||
return -1;
|
||||
break;
|
||||
case GL_TRIANGLES:
|
||||
name="T";
|
||||
type=R300_VAP_VF_CNTL__PRIM_TRIANGLES;
|
||||
min_vertices=3;
|
||||
break;
|
||||
case GL_TRIANGLE_STRIP:
|
||||
name="TS";
|
||||
type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
|
||||
min_vertices=3;
|
||||
break;
|
||||
case GL_TRIANGLE_FAN:
|
||||
name="TF";
|
||||
type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
|
||||
min_vertices=3;
|
||||
break;
|
||||
case GL_QUADS:
|
||||
name="Q";
|
||||
type=R300_VAP_VF_CNTL__PRIM_QUADS;
|
||||
min_vertices=4;
|
||||
break;
|
||||
case GL_QUAD_STRIP:
|
||||
name="QS";
|
||||
type=R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
|
||||
min_vertices=4;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Cannot handle primitive %02x ", prim & PRIM_MODE_MASK);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
#if 1
|
||||
fprintf(stderr, "[%d-%d]%s ", start, end, name);
|
||||
#endif
|
||||
if(start+min_vertices>=end){
|
||||
fprintf(stderr, "Not enough vertices\n");
|
||||
return -1;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Immediate implementation - vertex data is sent via command stream */
|
||||
|
||||
static GLfloat default_vector[4]={0.0, 0.0, 0.0, 1.0};
|
||||
|
||||
#define output_vector(v, i) \
|
||||
{ \
|
||||
int _i; \
|
||||
for(_i=0;_i<v->size;_i++){ \
|
||||
efloat(VEC_ELT(v, GLfloat, i)[_i]); \
|
||||
} \
|
||||
for(_i=v->size;_i<4;_i++){ \
|
||||
efloat(default_vector[_i]); \
|
||||
} \
|
||||
}
|
||||
|
||||
static void r300_render_flat_primitive(r300ContextPtr rmesa,
|
||||
GLcontext *ctx,
|
||||
int start,
|
||||
int end,
|
||||
int prim)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
int k, type;
|
||||
LOCAL_VARS
|
||||
|
||||
type=r300_get_primitive_type(rmesa, ctx, start, end, prim);
|
||||
|
||||
fprintf(stderr,"ObjPtr: size=%d stride=%d\n",
|
||||
VB->ObjPtr->size, VB->ObjPtr->stride);
|
||||
fprintf(stderr,"ColorPtr[0]: size=%d stride=%d\n",
|
||||
VB->ColorPtr[0]->size, VB->ColorPtr[0]->stride);
|
||||
|
||||
if(type<0)return;
|
||||
|
||||
|
||||
start_immediate_packet(end-start, type, 8);
|
||||
|
||||
for(i=start;i<end;i++){
|
||||
#if 0
|
||||
fprintf(stderr, "* (%f %f %f %f) (%f %f %f %f)\n",
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[0],
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[1],
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[2],
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[3],
|
||||
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0],
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1],
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2],
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3]
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
/* coordinates */
|
||||
output_vector(VB->ObjPtr, i);
|
||||
|
||||
/* color components */
|
||||
output_vector(VB->ColorPtr[0], i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static GLboolean r300_run_flat_render(GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
r300ContextPtr rmesa = R300_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
AOS_DATA vb_arrays[2];
|
||||
LOCAL_VARS
|
||||
|
||||
if (RADEON_DEBUG == DEBUG_PRIMS)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
/* setup array of structures data */
|
||||
|
||||
/* Note: immediate vertex data includes all coordinates.
|
||||
To save bandwidth use either VBUF or state-based vertex generation */
|
||||
/* xyz */
|
||||
vb_arrays[0].element_size=4;
|
||||
vb_arrays[0].stride=4;
|
||||
vb_arrays[0].offset=0; /* Not used */
|
||||
vb_arrays[0].format=AOS_FORMAT_FLOAT;
|
||||
vb_arrays[0].ncomponents=4;
|
||||
vb_arrays[0].reg=REG_COORDS;
|
||||
|
||||
/* color */
|
||||
vb_arrays[1].element_size=4;
|
||||
vb_arrays[1].stride=4;
|
||||
vb_arrays[1].offset=0; /* Not used */
|
||||
vb_arrays[1].format=AOS_FORMAT_FLOAT_COLOR;
|
||||
vb_arrays[1].ncomponents=4;
|
||||
vb_arrays[1].reg=REG_COLOR0;
|
||||
|
||||
|
||||
/* needed before starting 3d operation .. */
|
||||
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
|
||||
e32(0x0000000a);
|
||||
|
||||
reg_start(0x4f18,0);
|
||||
e32(0x00000003);
|
||||
|
||||
rmesa->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
|
||||
| R300_VPORT_X_OFFSET_ENA
|
||||
| R300_VPORT_Y_SCALE_ENA
|
||||
| R300_VPORT_Y_OFFSET_ENA
|
||||
| R300_VTX_W0_FMT;
|
||||
R300_STATECHANGE(rmesa, vte);
|
||||
|
||||
r300EmitState(rmesa);
|
||||
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].length=16;
|
||||
memcpy(FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
|
||||
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.length=4;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[0]=0.0;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[1]=0.0;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[2]=1.0;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[3]=0.0;
|
||||
|
||||
program_pipeline(PASS_PREFIX &FLAT_COLOR_PIPELINE);
|
||||
|
||||
/* We need LOAD_VBPNTR to setup AOS_ATTR fields.. the offsets are irrelevant */
|
||||
setup_AOS(PASS_PREFIX vb_arrays, 2);
|
||||
|
||||
for(i=0; i < VB->PrimitiveCount; i++){
|
||||
GLuint prim = VB->Primitive[i].mode;
|
||||
GLuint start = VB->Primitive[i].start;
|
||||
GLuint length = VB->Primitive[i].count;
|
||||
r300_render_flat_primitive(rmesa, ctx, start, start + length, prim);
|
||||
}
|
||||
|
||||
end_3d(PASS_PREFIX_VOID);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* vertex buffer implementation */
|
||||
|
||||
/* We use the start part of GART texture buffer for vertices */
|
||||
|
||||
/* 8 is somewhat bogus... it is probably something like 24 */
|
||||
#define R300_MAX_AOS_ARRAYS 8
|
||||
|
||||
static void upload_vertex_buffer(r300ContextPtr rmesa,
|
||||
GLcontext *ctx, AOS_DATA *array, int *n_arrays)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
int offset=0, idx=0;
|
||||
int i,j;
|
||||
radeonScreenPtr rsp=rmesa->radeon.radeonScreen;
|
||||
/* Not the most efficient implementation, but, for now, I just want something that
|
||||
works */
|
||||
/* to do - make single memcpy per column (is it possible ?) */
|
||||
/* to do - use dirty flags to avoid redundant copies */
|
||||
#define UPLOAD_VECTOR(v, r, f)\
|
||||
{ \
|
||||
/* Is the data dirty ? */ \
|
||||
if (v->flags & ((1<<v->size)-1)) { \
|
||||
fprintf(stderr, "size=%d vs stride=%d\n", v->size, v->stride); \
|
||||
if(v->size*4==v->stride){\
|
||||
/* fast path */ \
|
||||
memcpy(rsp->gartTextures.map+offset, v->data, v->stride*VB->Count); \
|
||||
} else { \
|
||||
for(i=0;i<VB->Count;i++){ \
|
||||
/* copy one vertex at a time*/ \
|
||||
memcpy(rsp->gartTextures.map+offset+i*v->size*4, VEC_ELT(v, GLfloat, i), v->size*4); \
|
||||
} \
|
||||
} \
|
||||
/* v->flags &= ~((1<<v->size)-1);*/ \
|
||||
} \
|
||||
array[idx].element_size=v->size; \
|
||||
array[idx].stride=v->size; \
|
||||
array[idx].format=(f); \
|
||||
array[idx].ncomponents=v->size; \
|
||||
array[idx].offset=rsp->gartTextures.handle+offset; \
|
||||
array[idx].reg=r; \
|
||||
offset+=v->size*4*VB->Count; \
|
||||
idx++; \
|
||||
}
|
||||
|
||||
UPLOAD_VECTOR(VB->ObjPtr, REG_COORDS, AOS_FORMAT_FLOAT);
|
||||
UPLOAD_VECTOR(VB->ColorPtr[0], REG_COLOR0, AOS_FORMAT_FLOAT_COLOR);
|
||||
|
||||
*n_arrays=idx;
|
||||
if(idx>=R300_MAX_AOS_ARRAYS){
|
||||
fprintf(stderr, "Aieee ! Maximum AOS arrays count exceeded.. \n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static void r300_render_vb_flat_primitive(r300ContextPtr rmesa,
|
||||
GLcontext *ctx,
|
||||
int start,
|
||||
int end,
|
||||
int prim)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
int k, type, n_arrays;
|
||||
LOCAL_VARS
|
||||
|
||||
if(end<=start)return; /* do we need to watch for this ? */
|
||||
|
||||
type=r300_get_primitive_type(rmesa, ctx, start, end, prim);
|
||||
if(type<0)return;
|
||||
|
||||
fire_AOS(PASS_PREFIX end-start, type);
|
||||
}
|
||||
|
||||
static VERTEX_SHADER_FRAGMENT default_vector_vsf={
|
||||
length: 4,
|
||||
body: {
|
||||
f: {0.0, 0.0, 0.0, 1.0}
|
||||
}
|
||||
};
|
||||
|
||||
static GLboolean r300_run_vb_flat_render(GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
r300ContextPtr rmesa = R300_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
int i, j, n_arrays;
|
||||
AOS_DATA vb_arrays[R300_MAX_AOS_ARRAYS];
|
||||
AOS_DATA vb_arrays2[R300_MAX_AOS_ARRAYS];
|
||||
LOCAL_VARS
|
||||
|
||||
if (RADEON_DEBUG == DEBUG_PRIMS)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
/* setup array of structures data */
|
||||
|
||||
upload_vertex_buffer(rmesa, ctx, vb_arrays, &n_arrays);
|
||||
fprintf(stderr, "Using %d AOS arrays\n", n_arrays);
|
||||
|
||||
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
|
||||
e32(0x0000000a);
|
||||
|
||||
reg_start(0x4f18,0);
|
||||
e32(0x00000003);
|
||||
|
||||
r300EmitState(rmesa);
|
||||
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].length=16;
|
||||
memcpy(FLAT_COLOR_PIPELINE.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
|
||||
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.length=4;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[0]=0.0;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[1]=0.0;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[2]=1.0;
|
||||
FLAT_COLOR_PIPELINE.vertex_shader.unknown2.body.f[3]=0.0;
|
||||
|
||||
program_pipeline(PASS_PREFIX &FLAT_COLOR_PIPELINE);
|
||||
|
||||
set_quad0(PASS_PREFIX 1.0,1.0,1.0,1.0);
|
||||
set_init21(PASS_PREFIX 0.0,1.0);
|
||||
|
||||
for(i=0; i < VB->PrimitiveCount; i++){
|
||||
GLuint prim = VB->Primitive[i].mode;
|
||||
GLuint start = VB->Primitive[i].start;
|
||||
GLuint length = VB->Primitive[i].count;
|
||||
|
||||
/* copy arrays */
|
||||
memcpy(vb_arrays2, vb_arrays, sizeof(AOS_DATA)*n_arrays);
|
||||
for(j=0;j<n_arrays;j++){
|
||||
vb_arrays2[j].offset+=vb_arrays2[j].stride*start*4;
|
||||
}
|
||||
|
||||
setup_AOS(PASS_PREFIX vb_arrays2, n_arrays);
|
||||
|
||||
r300_render_vb_flat_primitive(rmesa, ctx, start, start + length, prim);
|
||||
}
|
||||
|
||||
end_3d(PASS_PREFIX_VOID);
|
||||
|
||||
/* Flush state - we are done drawing.. */
|
||||
r300Flush(ctx);
|
||||
fprintf(stderr, "\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Textures... */
|
||||
|
||||
/* Immediate implementation - vertex data is sent via command stream */
|
||||
|
||||
static void r300_render_tex_primitive(r300ContextPtr rmesa,
|
||||
GLcontext *ctx,
|
||||
int start,
|
||||
int end,
|
||||
int prim)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
int k, type;
|
||||
LOCAL_VARS
|
||||
|
||||
type=r300_get_primitive_type(rmesa, ctx, start, end, prim);
|
||||
|
||||
fprintf(stderr,"ObjPtr: size=%d stride=%d\n",
|
||||
VB->ObjPtr->size, VB->ObjPtr->stride);
|
||||
fprintf(stderr,"ColorPtr[0]: size=%d stride=%d\n",
|
||||
VB->ColorPtr[0]->size, VB->ColorPtr[0]->stride);
|
||||
|
||||
if(type<0)return;
|
||||
|
||||
|
||||
start_immediate_packet(end-start, type, 8);
|
||||
|
||||
for(i=start;i<end;i++){
|
||||
#if 0
|
||||
fprintf(stderr, "* (%f %f %f %f) (%f %f %f %f)\n",
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[0],
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[1],
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[2],
|
||||
VEC_ELT(VB->ObjPtr, GLfloat, i)[3],
|
||||
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0],
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1],
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2],
|
||||
VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3]
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
/* coordinates */
|
||||
output_vector(VB->ObjPtr, i);
|
||||
|
||||
/* color components */
|
||||
output_vector(VB->TexCoordPtr[0], i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static GLboolean r300_run_tex_render(GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
r300ContextPtr rmesa = R300_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
AOS_DATA vb_arrays[2];
|
||||
/* Only do 2d textures */
|
||||
struct gl_texture_object *to=ctx->Texture.Unit[0].Current2D;
|
||||
radeonScreenPtr rsp=rmesa->radeon.radeonScreen;
|
||||
LOCAL_VARS
|
||||
|
||||
|
||||
fprintf(stderr, "%s Fixme ! I am broken\n", __FUNCTION__);
|
||||
return GL_TRUE;
|
||||
|
||||
if (RADEON_DEBUG == DEBUG_PRIMS)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
/* setup array of structures data */
|
||||
|
||||
/* Note: immediate vertex data includes all coordinates.
|
||||
To save bandwidth use either VBUF or state-based vertex generation */
|
||||
/* xyz */
|
||||
vb_arrays[0].element_size=4;
|
||||
vb_arrays[0].stride=4;
|
||||
vb_arrays[0].offset=0; /* Not used */
|
||||
vb_arrays[0].format=AOS_FORMAT_FLOAT;
|
||||
vb_arrays[0].ncomponents=4;
|
||||
vb_arrays[0].reg=REG_COORDS;
|
||||
|
||||
/* color */
|
||||
vb_arrays[1].element_size=4;
|
||||
vb_arrays[1].stride=4;
|
||||
vb_arrays[1].offset=0; /* Not used */
|
||||
vb_arrays[1].format=AOS_FORMAT_FLOAT;
|
||||
vb_arrays[1].ncomponents=4;
|
||||
vb_arrays[1].reg=REG_TEX0;
|
||||
|
||||
|
||||
/* needed before starting 3d operation .. */
|
||||
reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
|
||||
e32(0x0000000a);
|
||||
|
||||
reg_start(0x4f18,0);
|
||||
e32(0x00000003);
|
||||
|
||||
|
||||
r300EmitState(rmesa);
|
||||
|
||||
SINGLE_TEXTURE_PIPELINE.vertex_shader.matrix[0].length=16;
|
||||
memcpy(SINGLE_TEXTURE_PIPELINE.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
|
||||
|
||||
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.length=4;
|
||||
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[0]=0.0;
|
||||
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[1]=0.0;
|
||||
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[2]=1.0;
|
||||
SINGLE_TEXTURE_PIPELINE.vertex_shader.unknown2.body.f[3]=0.0;
|
||||
|
||||
/* Put it in the beginning of texture memory */
|
||||
SINGLE_TEXTURE_PIPELINE.texture_unit[0].offset=rsp->gartTextures.handle;
|
||||
|
||||
/* Upload texture, a hack, really we can do a lot better */
|
||||
#if 0
|
||||
memcpy(rsp->gartTextures.map, to->Image[0][0]->Data, to->Image[0][0]->RowStride*to->Image[0][0]->Height*4);
|
||||
#endif
|
||||
|
||||
reg_start(0x4e0c,0);
|
||||
e32(0x0000000f);
|
||||
|
||||
reg_start(0x427c,1);
|
||||
/* XG_427c(427c) */
|
||||
e32(0x00000000);
|
||||
/* XG_4280(4280) */
|
||||
e32(0x00000000);
|
||||
|
||||
reg_start(0x4e04,1);
|
||||
/* XG_4e04(4e04) */
|
||||
e32(0x20220000);
|
||||
/* XG_4e08(4e08) */
|
||||
e32(0x00000000);
|
||||
|
||||
reg_start(0x4f14,0);
|
||||
e32(0x00000001);
|
||||
|
||||
reg_start(0x4f1c,0);
|
||||
e32(0x00000000);
|
||||
|
||||
/* gap */
|
||||
sync_VAP(PASS_PREFIX_VOID);
|
||||
|
||||
reg_start(R300_RS_CNTL_0,1);
|
||||
/* R300_RS_CNTL_0(4300) */
|
||||
e32(0x00040084);
|
||||
/* RS_INST_COUNT(4304) */
|
||||
e32(0x000000c0);
|
||||
|
||||
reg_start(R300_RS_ROUTE_0,0);
|
||||
e32(0x00024008);
|
||||
|
||||
reg_start(R300_RS_INTERP_0,7);
|
||||
/* X_MEM0_0(4310) */
|
||||
e32(0x00d10000);
|
||||
/* X_MEM0_1(4314) */
|
||||
e32(0x00d10044);
|
||||
/* X_MEM0_2(4318) */
|
||||
e32(0x00d10084);
|
||||
/* X_MEM0_3(431c) */
|
||||
e32(0x00d100c4);
|
||||
/* X_MEM0_4(4320) */
|
||||
e32(0x00d10004);
|
||||
/* X_MEM0_5(4324) */
|
||||
e32(0x00d10004);
|
||||
/* X_MEM0_6(4328) */
|
||||
e32(0x00d10004);
|
||||
/* X_MEM0_7(432c) */
|
||||
e32(0x00d10004);
|
||||
|
||||
reg_start(0x221c,0);
|
||||
e32(0x00000000);
|
||||
|
||||
reg_start(0x20b0,0);
|
||||
e32(0x0000043f);
|
||||
|
||||
reg_start(0x4bd8,0);
|
||||
e32(0x00000000);
|
||||
|
||||
reg_start(0x4e04,0);
|
||||
e32(0x20220000);
|
||||
|
||||
reg_start(0x20b4,0);
|
||||
e32(0x0000000c);
|
||||
|
||||
reg_start(0x4288,0);
|
||||
e32(0x00000000);
|
||||
|
||||
reg_start(0x4e0c,0);
|
||||
e32(0x0000000f);
|
||||
|
||||
reg_start(R300_RS_CNTL_0,0);
|
||||
e32(0x00040084);
|
||||
|
||||
program_pipeline(PASS_PREFIX &SINGLE_TEXTURE_PIPELINE);
|
||||
|
||||
/* We need LOAD_VBPNTR to setup AOS_ATTR fields.. the offsets are irrelevant */
|
||||
setup_AOS(PASS_PREFIX vb_arrays, 2);
|
||||
|
||||
for(i=0; i < VB->PrimitiveCount; i++){
|
||||
GLuint prim = VB->Primitive[i].mode;
|
||||
GLuint start = VB->Primitive[i].start;
|
||||
GLuint length = VB->Primitive[i].count;
|
||||
r300_render_tex_primitive(rmesa, ctx, start, start + length, prim);
|
||||
}
|
||||
|
||||
end_3d(PASS_PREFIX_VOID);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by the pipeline manager to render a batch of primitives.
|
||||
@@ -71,10 +652,23 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
static GLboolean r300_run_render(GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
r300ContextPtr rmesa = R300_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
|
||||
if (RADEON_DEBUG == DEBUG_PRIMS)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
#if 1
|
||||
/* Just switch between pipelines.. We could possibly do better.. (?) */
|
||||
if(ctx->Texture.Unit[0].Enabled)
|
||||
return r300_run_tex_render(ctx, stage);
|
||||
else
|
||||
return r300_run_flat_render(ctx, stage);
|
||||
#else
|
||||
return GL_TRUE;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||
@@ -164,10 +758,15 @@ static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST
|
||||
FALLBACK_IF(ctx->Multisample.Enabled); // GL_MULTISAMPLE_ARB
|
||||
|
||||
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
|
||||
/* One step at a time - let one texture pass.. */
|
||||
for (i = 1; i < ctx->Const.MaxTextureUnits; i++)
|
||||
FALLBACK_IF(ctx->Texture.Unit[i].Enabled);
|
||||
|
||||
|
||||
/* let r300_run_render do its job */
|
||||
#if 0
|
||||
stage->active = GL_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -225,6 +225,58 @@ static void r300ColorMask(GLcontext* ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Window position and viewport transformation
|
||||
*/
|
||||
|
||||
/*
|
||||
* To correctly position primitives:
|
||||
*/
|
||||
#define SUBPIXEL_X 0.125
|
||||
#define SUBPIXEL_Y 0.125
|
||||
|
||||
void r300UpdateWindow(GLcontext * ctx)
|
||||
{
|
||||
r300ContextPtr rmesa = R300_CONTEXT(ctx);
|
||||
__DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
|
||||
GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
|
||||
GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
|
||||
const GLfloat *v = ctx->Viewport._WindowMap.m;
|
||||
|
||||
GLfloat sx = v[MAT_SX];
|
||||
GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
|
||||
GLfloat sy = -v[MAT_SY];
|
||||
GLfloat ty = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y;
|
||||
GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
|
||||
GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
|
||||
|
||||
R300_FIREVERTICES(rmesa);
|
||||
R300_STATECHANGE(rmesa, vpt);
|
||||
|
||||
rmesa->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(sx);
|
||||
rmesa->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(tx);
|
||||
rmesa->hw.vpt.cmd[R300_VPT_YSCALE] = r300PackFloat32(sy);
|
||||
rmesa->hw.vpt.cmd[R300_VPT_YOFFSET] = r300PackFloat32(ty);
|
||||
rmesa->hw.vpt.cmd[R300_VPT_ZSCALE] = r300PackFloat32(sz);
|
||||
rmesa->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(tz);
|
||||
}
|
||||
|
||||
static void r300Viewport(GLcontext * ctx, GLint x, GLint y,
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
/* Don't pipeline viewport changes, conflict with window offset
|
||||
* setting below. Could apply deltas to rescue pipelined viewport
|
||||
* values, or keep the originals hanging around.
|
||||
*/
|
||||
R200_FIREVERTICES(R200_CONTEXT(ctx));
|
||||
r300UpdateWindow(ctx);
|
||||
}
|
||||
|
||||
static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
|
||||
{
|
||||
r300UpdateWindow(ctx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by Mesa after an internal state update.
|
||||
@@ -255,26 +307,8 @@ void r300ResetHwState(r300ContextPtr r300)
|
||||
if (RADEON_DEBUG & DEBUG_STATE)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
|
||||
GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
|
||||
GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
|
||||
const GLfloat *v = ctx->Viewport._WindowMap.m;
|
||||
|
||||
r300->hw.vpt.cmd[R300_VPT_XSCALE] =
|
||||
r300PackFloat32(v[MAT_SX]);
|
||||
r300->hw.vpt.cmd[R300_VPT_XOFFSET] =
|
||||
r300PackFloat32(v[MAT_TX] + xoffset);
|
||||
r300->hw.vpt.cmd[R300_VPT_YSCALE] =
|
||||
r300PackFloat32(-v[MAT_SY]);
|
||||
r300->hw.vpt.cmd[R300_VPT_YOFFSET] =
|
||||
r300PackFloat32(-v[MAT_TY] + yoffset);
|
||||
r300->hw.vpt.cmd[R300_VPT_ZSCALE] =
|
||||
r300PackFloat32(v[MAT_SZ]);
|
||||
r300->hw.vpt.cmd[R300_VPT_ZOFFSET] =
|
||||
r300PackFloat32(v[MAT_TZ]);
|
||||
}
|
||||
|
||||
r300UpdateWindow(ctx);
|
||||
|
||||
r300ColorMask(ctx,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
@@ -293,8 +327,14 @@ void r300ResetHwState(r300ContextPtr r300)
|
||||
r300->hw.ovf.cmd[R300_OVF_FMT_0] = 0x00000003;
|
||||
r300->hw.ovf.cmd[R300_OVF_FMT_1] = 0x00000000;
|
||||
|
||||
r300->hw.unk20B0.cmd[1] = 0x0000040A;
|
||||
r300->hw.unk20B0.cmd[2] = 0x00000008;
|
||||
r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
|
||||
| R300_VPORT_X_OFFSET_ENA
|
||||
| R300_VPORT_Y_SCALE_ENA
|
||||
| R300_VPORT_Y_OFFSET_ENA
|
||||
| R300_VPORT_Z_SCALE_ENA
|
||||
| R300_VPORT_Z_OFFSET_ENA
|
||||
| R300_VTX_W0_FMT;
|
||||
r300->hw.vte.cmd[2] = 0x00000008;
|
||||
|
||||
r300->hw.unk2134.cmd[1] = 0x00FFFFFF;
|
||||
r300->hw.unk2134.cmd[2] = 0x00000000;
|
||||
@@ -324,20 +364,30 @@ void r300ResetHwState(r300ContextPtr r300)
|
||||
else
|
||||
r300->hw.unk2288.cmd[1] = R300_2288_RV350;
|
||||
|
||||
r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT
|
||||
| R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
|
||||
r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */
|
||||
|
||||
r300->hw.pvs.cmd[R300_PVS_CNTL_1] = 0;
|
||||
r300->hw.pvs.cmd[R300_PVS_CNTL_2] = 0;
|
||||
r300->hw.pvs.cmd[R300_PVS_CNTL_3] = 0;
|
||||
|
||||
r300->hw.unk4008.cmd[1] = 0x00000007;
|
||||
r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE
|
||||
| R300_GB_LINE_STUFF_ENABLE
|
||||
| R300_GB_TRIANGLE_STUFF_ENABLE;
|
||||
|
||||
r300->hw.unk4010.cmd[1] = 0x66666666;
|
||||
r300->hw.unk4010.cmd[2] = 0x06666666;
|
||||
r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666;
|
||||
r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666;
|
||||
if (GET_CHIP(r300->radeon.radeonScreen) == RADEON_CHIP_R300)
|
||||
r300->hw.unk4010.cmd[3] = 0x00000017;
|
||||
r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
|
||||
| R300_GB_TILE_PIPE_COUNT_R300
|
||||
| R300_GB_TILE_SIZE_16;
|
||||
else
|
||||
r300->hw.unk4010.cmd[3] = 0x00000011;
|
||||
r300->hw.unk4010.cmd[4] = 0x00000000;
|
||||
r300->hw.unk4010.cmd[5] = 0x00000000;
|
||||
r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
|
||||
| R300_GB_TILE_PIPE_COUNT_RV300
|
||||
| R300_GB_TILE_SIZE_16;
|
||||
r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = 0x00000000;
|
||||
r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = 0x00000000; /* No antialiasing */
|
||||
|
||||
r300->hw.txe.cmd[R300_TXE_ENABLE] = 0;
|
||||
|
||||
@@ -377,15 +427,20 @@ void r300ResetHwState(r300ContextPtr r300)
|
||||
r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF;
|
||||
r300->hw.unk42C0.cmd[2] = 0x00000000;
|
||||
|
||||
r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7;
|
||||
/* The second constant is needed to get glxgears display anything .. */
|
||||
r300->hw.rc.cmd[1] = R300_RS_CNTL_0_UNKNOWN_7 | R300_RS_CNTL_0_UNKNOWN_18;
|
||||
r300->hw.rc.cmd[2] = 0;
|
||||
|
||||
for(i = 1; i <= 8; ++i)
|
||||
r300->hw.ri.cmd[i] = 0;
|
||||
r300->hw.ri.cmd[i] = 0x00d10000;
|
||||
r300->hw.ri.cmd[R300_RI_INTERP_1] |= R300_RS_INTERP_1_UNKNOWN;
|
||||
r300->hw.ri.cmd[R300_RI_INTERP_2] |= R300_RS_INTERP_2_UNKNOWN;
|
||||
r300->hw.ri.cmd[R300_RI_INTERP_3] |= R300_RS_INTERP_3_UNKNOWN;
|
||||
|
||||
((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->unchecked_state.count = 1;
|
||||
for(i = 1; i <= 8; ++i)
|
||||
r300->hw.rr.cmd[1] = 0;
|
||||
r300->hw.rr.cmd[i] = 0;
|
||||
r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0x4000;
|
||||
|
||||
r300->hw.unk43A4.cmd[1] = 0x0000001C;
|
||||
r300->hw.unk43A4.cmd[2] = 0x2DA49525;
|
||||
@@ -451,6 +506,9 @@ void r300ResetHwState(r300ContextPtr r300)
|
||||
|
||||
r300->hw.unk4E88.cmd[1] = 0;
|
||||
|
||||
r300->hw.unk4EA0.cmd[1] = 0x00000000;
|
||||
r300->hw.unk4EA0.cmd[2] = 0xffffffff;
|
||||
|
||||
r300->hw.unk4F08.cmd[1] = 0x00FFFF00;
|
||||
|
||||
r300->hw.unk4F10.cmd[1] = 0x00000002; // depthbuffer format?
|
||||
@@ -504,11 +562,14 @@ void r300ResetHwState(r300ContextPtr r300)
|
||||
void r300InitState(r300ContextPtr r300)
|
||||
{
|
||||
radeonInitState(&r300->radeon);
|
||||
|
||||
r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
|
||||
|
||||
r300ResetHwState(r300);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize driver's state callback functions
|
||||
*/
|
||||
@@ -523,5 +584,9 @@ void r300InitStateFuncs(struct dd_function_table* functions)
|
||||
functions->DepthMask = r300DepthMask;
|
||||
functions->CullFace = r300CullFace;
|
||||
functions->FrontFace = r300FrontFace;
|
||||
|
||||
/* Viewport related */
|
||||
functions->Viewport = r300Viewport;
|
||||
functions->DepthRange = r300DepthRange;
|
||||
}
|
||||
|
||||
|
@@ -43,6 +43,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
r300->hw.is_dirty = GL_TRUE; \
|
||||
} while(0)
|
||||
|
||||
/* Fire the buffered vertices no matter what.
|
||||
TODO: This has not been implemented yet
|
||||
*/
|
||||
#define R300_FIREVERTICES( r300 ) \
|
||||
do { \
|
||||
/* \
|
||||
if ( (r300)->store.cmd_used || (r300)->dma.flush ) { \
|
||||
radeonFlush( (r300)->radeon.glCtx ); \
|
||||
} \
|
||||
*/ \
|
||||
} while (0)
|
||||
|
||||
|
||||
extern void r300ResetHwState(r300ContextPtr r300);
|
||||
|
||||
extern void r300InitState(r300ContextPtr r300);
|
||||
|
90
src/mesa/drivers/dri/r300/vertex_shader.h
Normal file
90
src/mesa/drivers/dri/r300/vertex_shader.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef __VERTEX_SHADER_H__
|
||||
#define __VERTEX_SHADER_H__
|
||||
|
||||
#include "r300_reg.h"
|
||||
|
||||
typedef struct {
|
||||
CARD32 op;
|
||||
CARD32 src1;
|
||||
CARD32 src2;
|
||||
CARD32 src3;
|
||||
} VERTEX_SHADER_INSTRUCTION;
|
||||
|
||||
#define VSF_FLAG_X 1
|
||||
#define VSF_FLAG_Y 2
|
||||
#define VSF_FLAG_Z 4
|
||||
#define VSF_FLAG_W 8
|
||||
#define VSF_FLAG_ALL 0xf
|
||||
#define VSF_FLAG_NONE 0
|
||||
|
||||
#define VSF_OUT_CLASS_TMP 0
|
||||
#define VSF_OUT_CLASS_RESULT 2
|
||||
|
||||
|
||||
/* first CARD32 of an instruction */
|
||||
|
||||
/* possible operations:
|
||||
DOT, MUL, ADD, MAD, FRC, MAX, MIN, SGE, SLT, EXP, LOG, LIT, POW, RCP, RSQ, EX2,
|
||||
LG2, MAD_2 */
|
||||
|
||||
#define MAKE_VSF_OP(op, out_reg_index, out_reg_fields, class) \
|
||||
((op) \
|
||||
| ((out_reg_index) << R300_VPI_OUT_REG_INDEX_SHIFT) \
|
||||
| ((out_reg_fields) << 20) \
|
||||
| ( (class) << 8 ) )
|
||||
|
||||
#define EASY_VSF_OP(op, out_reg_index, out_reg_fields, class) \
|
||||
MAKE_VSF_OP(R300_VPI_OUT_OP_##op, out_reg_index, VSF_FLAG_##out_reg_fields, VSF_OUT_CLASS_##class) \
|
||||
|
||||
/* according to Nikolai, the subsequent 3 CARD32 are sources, use same define for each */
|
||||
|
||||
#define VSF_IN_CLASS_TMP 0
|
||||
#define VSF_IN_CLASS_ATTR 1
|
||||
#define VSF_IN_CLASS_PARAM 2
|
||||
#define VSF_IN_CLASS_NONE 9
|
||||
|
||||
#define VSF_IN_COMPONENT_X 0
|
||||
#define VSF_IN_COMPONENT_Y 1
|
||||
#define VSF_IN_COMPONENT_Z 2
|
||||
#define VSF_IN_COMPONENT_W 3
|
||||
#define VSF_IN_COMPONENT_ZERO 4
|
||||
#define VSF_IN_COMPONENT_ONE 5
|
||||
|
||||
#define MAKE_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
|
||||
( ((in_reg_index)<<R300_VPI_IN_REG_INDEX_SHIFT) \
|
||||
| ((comp_x)<<R300_VPI_IN_X_SHIFT) \
|
||||
| ((comp_y)<<R300_VPI_IN_Y_SHIFT) \
|
||||
| ((comp_z)<<R300_VPI_IN_Z_SHIFT) \
|
||||
| ((comp_w)<<R300_VPI_IN_W_SHIFT) \
|
||||
| ((negate)<<25) | ((class)))
|
||||
|
||||
#define EASY_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
|
||||
MAKE_VSF_SOURCE(in_reg_index, \
|
||||
VSF_IN_COMPONENT_##comp_x, \
|
||||
VSF_IN_COMPONENT_##comp_y, \
|
||||
VSF_IN_COMPONENT_##comp_z, \
|
||||
VSF_IN_COMPONENT_##comp_w, \
|
||||
VSF_IN_CLASS_##class, VSF_FLAG_##negate)
|
||||
|
||||
/* special sources: */
|
||||
|
||||
/* (1.0,1.0,1.0,1.0) vector (ATTR, plain ) */
|
||||
#define VSF_ATTR_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, ATTR, NONE)
|
||||
#define VSF_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, NONE, NONE)
|
||||
|
||||
/* contents of unmodified register */
|
||||
#define VSF_REG(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, ATTR, NONE)
|
||||
|
||||
/* contents of unmodified parameter */
|
||||
#define VSF_PARAM(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, PARAM, NONE)
|
||||
|
||||
/* contents of unmodified temporary register */
|
||||
#define VSF_TMP(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, TMP, NONE)
|
||||
|
||||
/* components of ATTR register */
|
||||
#define VSF_ATTR_X(reg) EASY_VSF_SOURCE(reg, X, X, X, X, ATTR, NONE)
|
||||
#define VSF_ATTR_Y(reg) EASY_VSF_SOURCE(reg, Y, Y, Y, Y, ATTR, NONE)
|
||||
#define VSF_ATTR_Z(reg) EASY_VSF_SOURCE(reg, Z, Z, Z, Z, ATTR, NONE)
|
||||
#define VSF_ATTR_W(reg) EASY_VSF_SOURCE(reg, W, W, W, W, ATTR, NONE)
|
||||
|
||||
#endif
|
46
src/mesa/drivers/dri/s3v/Makefile
Normal file
46
src/mesa/drivers/dri/s3v/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
# src/mesa/drivers/dri/s3v/Makefile
|
||||
|
||||
TOP = ../../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
LIBNAME = s3v_dri.so
|
||||
|
||||
# Doesn't exist yet.
|
||||
#MINIGLX_SOURCES = server/savage_dri.c
|
||||
|
||||
COMMON_SOURCES = \
|
||||
../../common/driverfuncs.c \
|
||||
../common/mm.c \
|
||||
../common/utils.c \
|
||||
../common/texmem.c \
|
||||
../common/vblank.c \
|
||||
../common/xmlconfig.c \
|
||||
../common/dri_util.c \
|
||||
../common/glcontextmodes.c
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
s3v_context.c \
|
||||
s3v_dd.c \
|
||||
s3v_inithw.c \
|
||||
s3v_lock.c \
|
||||
s3v_render.c \
|
||||
s3v_screen.c \
|
||||
s3v_span.c \
|
||||
s3v_state.c \
|
||||
s3v_tex.c \
|
||||
s3v_texmem.c \
|
||||
s3v_texstate.c \
|
||||
s3v_tris.c \
|
||||
s3v_vb.c \
|
||||
s3v_xmesa.c
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DRIVER_SOURCES)
|
||||
|
||||
ASM_SOURCES =
|
||||
|
||||
|
||||
include ../Makefile.template
|
||||
|
||||
symlinks:
|
83
src/mesa/drivers/dri/s3v/s3v_common.h
Normal file
83
src/mesa/drivers/dri/s3v/s3v_common.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Author: Max Lingua <sunmax@libero.it>
|
||||
*/
|
||||
|
||||
/* WARNING: If you change any of these defines, make sure to change
|
||||
* the kernel include file as well (s3v_drm.h)
|
||||
*/
|
||||
|
||||
#ifndef _XF86DRI_S3V_H_
|
||||
#define _XF86DRI_S3V_H_
|
||||
|
||||
#ifndef _S3V_DEFINES_
|
||||
#define _S3V_DEFINES_
|
||||
#define S3V_USE_BATCH 1
|
||||
|
||||
/* #define S3V_BUF_4K 1 */
|
||||
|
||||
#ifdef S3V_BUF_4K
|
||||
#define S3V_DMA_BUF_ORDER 12
|
||||
#define S3V_DMA_BUF_NR 256
|
||||
#else
|
||||
#define S3V_DMA_BUF_ORDER 16 /* -much- better */
|
||||
#define S3V_DMA_BUF_NR 16
|
||||
#endif
|
||||
/* on s3virge you can only choose between *
|
||||
* 4k (2^12) and 64k (2^16) dma bufs */
|
||||
#define S3V_DMA_BUF_SZ (1<<S3V_DMA_BUF_ORDER)
|
||||
|
||||
#define S3V_NR_SAREA_CLIPRECTS 8
|
||||
|
||||
/* Each region is a minimum of 16k (64*64@4bpp)
|
||||
* and there are at most 40 of them.
|
||||
*/
|
||||
#define S3V_NR_TEX_REGIONS 64 /* was 40 */
|
||||
#define S3V_LOG_TEX_GRANULARITY 16 /* was 4 */
|
||||
/* 40 * (2 ^ 4) = 640k, that's all we have for tex on 4mb gfx card */
|
||||
/* FIXME: will it work with card with less than 4mb? */
|
||||
/* FIXME: we should set this at run time */
|
||||
|
||||
#endif /* _S3V_DEFINES */
|
||||
|
||||
/*
|
||||
* WARNING: If you change any of these defines, make sure to change
|
||||
* the kernel include file as well (gamma_drm.h)
|
||||
*/
|
||||
|
||||
/* Driver specific DRM command indices
|
||||
* NOTE: these are not OS specific, but they are driver specific
|
||||
*/
|
||||
#define DRM_S3V_INIT_DMA 0x00
|
||||
#define DRM_S3V_CLEANUP_DMA 0x01
|
||||
|
||||
typedef struct _drmS3VInit {
|
||||
enum {
|
||||
S3V_INIT_DMA = 0x01,
|
||||
S3V_CLEANUP_DMA = 0x02
|
||||
} func;
|
||||
|
||||
unsigned int pcimode; /* bool: 1=pci 0=agp */
|
||||
|
||||
unsigned int mmio_offset;
|
||||
unsigned int buffers_offset;
|
||||
unsigned int sarea_priv_offset;
|
||||
|
||||
unsigned int front_offset;
|
||||
unsigned int front_width;
|
||||
unsigned int front_height;
|
||||
unsigned int front_pitch;
|
||||
|
||||
unsigned int back_offset;
|
||||
unsigned int back_width;
|
||||
unsigned int back_height;
|
||||
unsigned int back_pitch;
|
||||
|
||||
unsigned int depth_offset;
|
||||
unsigned int depth_width;
|
||||
unsigned int depth_height;
|
||||
unsigned int depth_pitch;
|
||||
|
||||
unsigned int texture_offset;
|
||||
} drmS3VInit;
|
||||
|
||||
#endif
|
@@ -13,24 +13,22 @@
|
||||
|
||||
#include "context.h"
|
||||
#include "simple_list.h"
|
||||
#include "mem.h"
|
||||
#include "matrix.h"
|
||||
#include "extensions.h"
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "X86/common_x86_asm.h"
|
||||
#endif
|
||||
#include "simple_list.h"
|
||||
#include "mem.h"
|
||||
#include "mm.h"
|
||||
|
||||
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
#include "s3v_vb.h"
|
||||
#include "s3v_tris.h"
|
||||
|
||||
#if 0
|
||||
extern const struct gl_pipeline_stage _s3v_render_stage;
|
||||
extern const struct tnl_pipeline_stage _s3v_render_stage;
|
||||
|
||||
static const struct gl_pipeline_stage *s3v_pipeline[] = {
|
||||
static const struct tnl_pipeline_stage *s3v_pipeline[] = {
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
@@ -46,16 +44,17 @@ static const struct gl_pipeline_stage *s3v_pipeline[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
GLboolean s3vCreateContext( Display *dpy, const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
GLcontext *ctx, *shareCtx;
|
||||
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
|
||||
s3vContextPtr vmesa;
|
||||
s3vScreenPtr s3vScrn;
|
||||
S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA)+
|
||||
sizeof(XF86DRISAREARec));
|
||||
S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) +
|
||||
sizeof(drm_sarea_t));
|
||||
struct dd_function_table functions;
|
||||
|
||||
DEBUG_WHERE(("*** s3vCreateContext ***\n"));
|
||||
|
||||
@@ -68,20 +67,21 @@ GLboolean s3vCreateContext( Display *dpy, const __GLcontextModes *glVisual,
|
||||
else
|
||||
shareCtx = NULL;
|
||||
|
||||
vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, vmesa, GL_TRUE);
|
||||
_mesa_init_driver_functions(&functions);
|
||||
|
||||
vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions,
|
||||
(void *)vmesa);
|
||||
if (!vmesa->glCtx) {
|
||||
FREE(vmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
vmesa->display = dpy;
|
||||
|
||||
vmesa->driContext = driContextPriv;
|
||||
vmesa->driScreen = sPriv;
|
||||
vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
|
||||
|
||||
vmesa->hHWContext = driContextPriv->hHWContext;
|
||||
vmesa->driHwLock = &sPriv->pSAREA->lock;
|
||||
vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
|
||||
vmesa->driFd = sPriv->fd;
|
||||
vmesa->sarea = saPriv;
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "s3v_regs.h"
|
||||
#include "s3v_macros.h"
|
||||
#include "s3v_screen.h"
|
||||
#include "colormac.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "drm.h"
|
||||
@@ -32,8 +33,7 @@
|
||||
extern void s3vDDUpdateHWState(GLcontext *ctx);
|
||||
extern s3vScreenPtr s3vCreateScreen(__DRIscreenPrivate *sPriv);
|
||||
extern void s3vDestroyScreen(__DRIscreenPrivate *sPriv);
|
||||
extern GLboolean s3vCreateContext( Display *dpy,
|
||||
const __GLcontextModes *glVisual,
|
||||
extern GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
|
||||
@@ -129,17 +129,17 @@ struct s3v_texture_object_t {
|
||||
int internalFormat;
|
||||
} image[S3V_TEX_MAXLEVELS];
|
||||
|
||||
CARD32 TextureCMD;
|
||||
GLuint TextureCMD;
|
||||
|
||||
CARD32 TextureColorMode;
|
||||
CARD32 TextureFilterMode;
|
||||
CARD32 TextureBorderColor;
|
||||
CARD32 TextureWrap;
|
||||
CARD32 TextureMipSize;
|
||||
GLuint TextureColorMode;
|
||||
GLuint TextureFilterMode;
|
||||
GLuint TextureBorderColor;
|
||||
GLuint TextureWrap;
|
||||
GLuint TextureMipSize;
|
||||
|
||||
CARD32 TextureBaseAddr[S3V_TEX_MAXLEVELS];
|
||||
CARD32 TextureFormat;
|
||||
CARD32 TextureReadMode;
|
||||
GLuint TextureBaseAddr[S3V_TEX_MAXLEVELS];
|
||||
GLuint TextureFormat;
|
||||
GLuint TextureReadMode;
|
||||
};
|
||||
|
||||
#define S3V_NO_PALETTE 0x0
|
||||
@@ -222,17 +222,16 @@ struct s3v_context {
|
||||
|
||||
/* Mirrors of some DRI state
|
||||
*/
|
||||
Display *display; /* X server display */
|
||||
|
||||
drmContext hHWContext;
|
||||
drm_context_t hHWContext;
|
||||
drmLock *driHwLock;
|
||||
int driFd;
|
||||
|
||||
GLuint numClipRects; /* Cliprects for the draw buffer */
|
||||
XF86DRIClipRectPtr pClipRects;
|
||||
drm_clip_rect_t *pClipRects;
|
||||
|
||||
CARD32* buf; /* FIXME */
|
||||
CARD32* _buf[2];
|
||||
GLuint* buf; /* FIXME */
|
||||
GLuint* _buf[2];
|
||||
int _bufNum;
|
||||
int bufIndex[2];
|
||||
int bufSize;
|
||||
@@ -281,40 +280,40 @@ struct s3v_context {
|
||||
|
||||
unsigned int S3V_REG[S3V_REGS_NUM];
|
||||
|
||||
CARD32 texMode;
|
||||
CARD32 alphaMode;
|
||||
CARD32 lightMode;
|
||||
GLuint texMode;
|
||||
GLuint alphaMode;
|
||||
GLuint lightMode;
|
||||
|
||||
CARD32 SrcBase;
|
||||
CARD32 DestBase;
|
||||
CARD32 DestBlit;
|
||||
CARD32 ScissorLR;
|
||||
CARD32 ScissorTB;
|
||||
CARD32 ScissorWH; /* SubScissorWH */ /* RectWH */
|
||||
CARD32 FrontStride;
|
||||
CARD32 BackStride;
|
||||
CARD32 SrcStride;
|
||||
CARD32 DestStride;
|
||||
CARD32 SrcXY;
|
||||
CARD32 DestXY;
|
||||
GLuint SrcBase;
|
||||
GLuint DestBase;
|
||||
GLuint DestBlit;
|
||||
GLuint ScissorLR;
|
||||
GLuint ScissorTB;
|
||||
GLuint ScissorWH; /* SubScissorWH */ /* RectWH */
|
||||
GLuint FrontStride;
|
||||
GLuint BackStride;
|
||||
GLuint SrcStride;
|
||||
GLuint DestStride;
|
||||
GLuint SrcXY;
|
||||
GLuint DestXY;
|
||||
|
||||
CARD32 ClearColor;
|
||||
CARD32 Color;
|
||||
CARD32 DitherMode;
|
||||
CARD32 ClearDepth;
|
||||
GLuint ClearColor;
|
||||
GLuint Color;
|
||||
GLuint DitherMode;
|
||||
GLuint ClearDepth;
|
||||
|
||||
CARD32 TextureBorderColor;
|
||||
CARD32 TexOffset;
|
||||
CARD32 TexStride;
|
||||
GLuint TextureBorderColor;
|
||||
GLuint TexOffset;
|
||||
GLuint TexStride;
|
||||
|
||||
CARD32 CMD;
|
||||
CARD32 prim_cmd;
|
||||
CARD32 _tri[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */
|
||||
CARD32 alpha_cmd; /* actual alpha cmd */
|
||||
CARD32 _alpha[2];
|
||||
CARD32 _alpha_tex; /* tex alpha type */
|
||||
GLuint CMD;
|
||||
GLuint prim_cmd;
|
||||
GLuint _tri[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */
|
||||
GLuint alpha_cmd; /* actual alpha cmd */
|
||||
GLuint _alpha[2];
|
||||
GLuint _alpha_tex; /* tex alpha type */
|
||||
/* (3d_mode) 0 = 3d line/gourad tri; 1 = 3d tex tri */
|
||||
CARD32 _3d_mode;
|
||||
GLuint _3d_mode;
|
||||
|
||||
GLfloat backface_sign;
|
||||
GLfloat cull_zero;
|
||||
@@ -323,14 +322,14 @@ struct s3v_context {
|
||||
|
||||
/* *** 2check *** */
|
||||
|
||||
CARD32 FogMode;
|
||||
CARD32 AreaStippleMode;
|
||||
CARD32 LBReadFormat;
|
||||
CARD32 LBWriteFormat;
|
||||
CARD32 LineMode;
|
||||
CARD32 PointMode;
|
||||
CARD32 TriangleMode;
|
||||
CARD32 AntialiasMode;
|
||||
GLuint FogMode;
|
||||
GLuint AreaStippleMode;
|
||||
GLuint LBReadFormat;
|
||||
GLuint LBWriteFormat;
|
||||
GLuint LineMode;
|
||||
GLuint PointMode;
|
||||
GLuint TriangleMode;
|
||||
GLuint AntialiasMode;
|
||||
GLfloat ViewportScaleX;
|
||||
GLfloat ViewportScaleY;
|
||||
GLfloat ViewportScaleZ;
|
||||
|
143
src/mesa/drivers/dri/s3v/s3v_dri.h
Normal file
143
src/mesa/drivers/dri/s3v/s3v_dri.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Author: Max Lingua <sunmax@libero.it>
|
||||
*/
|
||||
|
||||
#ifndef _S3V_DRI
|
||||
#define _S3V_DRI
|
||||
|
||||
#include "s3v_common.h"
|
||||
|
||||
#define S3V_MAX_DRAWABLES (S3V_DMA_BUF_NR/2) /* 32 */ /* 256 */ /* FIXME */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int deviceID;
|
||||
int width;
|
||||
int height;
|
||||
int mem;
|
||||
int cpp;
|
||||
int bitsPerPixel;
|
||||
|
||||
int fbOffset;
|
||||
int fbStride;
|
||||
|
||||
int logTextureGranularity;
|
||||
int textureOffset;
|
||||
|
||||
drm_handle_t regs;
|
||||
drmSize regsSize;
|
||||
|
||||
unsigned int sarea_priv_offset;
|
||||
/*
|
||||
drmAddress regsMap;
|
||||
|
||||
drmSize textureSize;
|
||||
drm_handle_t textures;
|
||||
*/
|
||||
|
||||
#if 0
|
||||
drm_handle_t agp_buffers;
|
||||
drmSize agp_buf_size;
|
||||
#endif
|
||||
|
||||
/*
|
||||
drmBufMapPtr drmBufs;
|
||||
int irq;
|
||||
unsigned int sarea_priv_offset;
|
||||
*/
|
||||
|
||||
/* FIXME: cleanup ! */
|
||||
|
||||
drmSize registerSize; /* == S3V_MMIO_REGSIZE */
|
||||
drm_handle_t registerHandle;
|
||||
|
||||
drmSize pciSize;
|
||||
drm_handle_t pciMemHandle;
|
||||
|
||||
drmSize frontSize; /* == videoRambytes */
|
||||
/* drm_handle_t frontHandle; */
|
||||
unsigned long frontOffset; /* == fbOffset */
|
||||
int frontPitch;
|
||||
/* unsigned char *front; */
|
||||
|
||||
unsigned int bufferSize; /* size of depth/back buffer */
|
||||
|
||||
drmSize backSize;
|
||||
/* drm_handle_t backHandle; */
|
||||
unsigned long backOffset;
|
||||
int backPitch;
|
||||
/* unsigned char *back; */
|
||||
|
||||
drmSize depthSize;
|
||||
/* drm_handle_t depthHandle; */
|
||||
unsigned long depthOffset;
|
||||
int depthPitch;
|
||||
/* unsigned char *depth; */
|
||||
|
||||
drmSize texSize;
|
||||
/* drm_handle_t texHandle; */
|
||||
unsigned long texOffset;
|
||||
int texPitch;
|
||||
/* unsigned char *tex; */
|
||||
|
||||
drmSize dmaBufSize; /* Size of buffers (in bytes) */
|
||||
drm_handle_t dmaBufHandle; /* Handle from drmAddMap */
|
||||
unsigned long dmaBufOffset; /* Offset/Start */
|
||||
int dmaBufPitch; /* Pitch */
|
||||
unsigned char *dmaBuf; /* Map */
|
||||
int bufNumBufs; /* Number of buffers */
|
||||
drmBufMapPtr buffers; /* Buffer map */
|
||||
|
||||
} S3VDRIRec, *S3VDRIPtr;
|
||||
|
||||
/* WARNING: Do not change the SAREA structure without changing the kernel
|
||||
* as well */
|
||||
|
||||
typedef struct {
|
||||
unsigned char next, prev; /* indices to form a circular LRU */
|
||||
unsigned char in_use; /* owned by a client, or free? */
|
||||
int age; /* tracked by clients to update local LRU's */
|
||||
} S3VTexRegionRec, *S3VTexRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
unsigned int nbox;
|
||||
drm_clip_rect_t boxes[S3V_NR_SAREA_CLIPRECTS];
|
||||
|
||||
/* Maintain an LRU of contiguous regions of texture space. If
|
||||
* you think you own a region of texture memory, and it has an
|
||||
* age different to the one you set, then you are mistaken and
|
||||
* it has been stolen by another client. If global texAge
|
||||
* hasn't changed, there is no need to walk the list.
|
||||
*
|
||||
* These regions can be used as a proxy for the fine-grained
|
||||
* texture information of other clients - by maintaining them
|
||||
* in the same lru which is used to age their own textures,
|
||||
* clients have an approximate lru for the whole of global
|
||||
* texture space, and can make informed decisions as to which
|
||||
* areas to kick out. There is no need to choose whether to
|
||||
* kick out your own texture or someone else's - simply eject
|
||||
* them all in LRU order.
|
||||
*/
|
||||
S3VTexRegionRec texList[S3V_NR_TEX_REGIONS+1]; /* Last elt is sentinal */
|
||||
|
||||
int texAge; /* last time texture was uploaded */
|
||||
|
||||
int last_enqueue; /* last time a buffer was enqueued */
|
||||
int last_dispatch; /* age of the most recently dispatched buffer */
|
||||
int last_quiescent; /* */
|
||||
|
||||
int ctxOwner; /* last context to upload state */
|
||||
} S3VSAREARec, *S3VSAREAPtr;
|
||||
|
||||
typedef struct {
|
||||
/* Nothing here yet */
|
||||
int dummy;
|
||||
} S3VConfigPrivRec, *S3VConfigPrivPtr;
|
||||
|
||||
typedef struct {
|
||||
/* Nothing here yet */
|
||||
int dummy;
|
||||
} S3VDRIContextRec, *S3VDRIContextPtr;
|
||||
|
||||
|
||||
#endif
|
@@ -5,9 +5,7 @@
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "mem.h"
|
||||
#include "mtypes.h"
|
||||
#include "mmath.h"
|
||||
|
||||
#include "tnl/t_context.h"
|
||||
|
||||
@@ -29,6 +27,7 @@
|
||||
|
||||
#define HAVE_ELTS 0
|
||||
|
||||
#if 0
|
||||
static void VERT_FALLBACK( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
@@ -50,8 +49,9 @@ static void VERT_FALLBACK( GLcontext *ctx,
|
||||
_flags = flags & PRIM_MODE_MASK;
|
||||
|
||||
tnl->Driver.Render.PrimTabVerts[_flags]( ctx, start, count, flags );
|
||||
S3V_CONTEXT(ctx)->SetupNewInputs = VERT_CLIP;
|
||||
S3V_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
PrimType_Points,
|
||||
@@ -126,12 +126,10 @@ static __inline void s3vEndPrimitive( s3vContextPtr vmesa )
|
||||
(vmesa->bufSize - vmesa->bufCount) / 2
|
||||
#define GET_SUBSEQUENT_VB_MAX_VERTS() \
|
||||
S3V_DMA_BUF_SZ / 2
|
||||
#define EMIT_VERTS( ctx, j, nr ) \
|
||||
do { \
|
||||
printf("Alas, emit...\n"); \
|
||||
/* s3v_emit(ctx, j, (j)+(nr)) */ \
|
||||
/* we don't need emit on s3v */ \
|
||||
} while (0)
|
||||
/* XXX */
|
||||
#define ALLOC_VERTS(nr) NULL
|
||||
#define EMIT_VERTS(ctx, start, count, buf) NULL
|
||||
#define FLUSH() s3vEndPrimitive( vmesa )
|
||||
|
||||
#define TAG(x) s3v_##x
|
||||
|
||||
@@ -143,13 +141,13 @@ do { \
|
||||
|
||||
|
||||
static GLboolean s3v_run_render( GLcontext *ctx,
|
||||
struct gl_pipeline_stage *stage )
|
||||
struct tnl_pipeline_stage *stage )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i, length, flags = 0;
|
||||
render_func *tab;
|
||||
GLuint i;
|
||||
tnl_render_func *tab;
|
||||
|
||||
DEBUG(("s3v_run_render\n"));
|
||||
|
||||
@@ -170,19 +168,20 @@ static GLboolean s3v_run_render( GLcontext *ctx,
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
for (i = 0 ; !(flags & PRIM_LAST) ; i += length)
|
||||
for (i = 0 ; i < VB->PrimitiveCount ; i++ )
|
||||
{
|
||||
flags = VB->Primitive[i];
|
||||
length = VB->PrimitiveLength[i];
|
||||
GLuint prim = VB->Primitive[i].mode;
|
||||
GLuint start = VB->Primitive[i].start;
|
||||
GLuint length = VB->Primitive[i].count;
|
||||
|
||||
DEBUG(("s3v_run_render (loop=%i) (lenght=%i)\n", i, length));
|
||||
|
||||
if (length) {
|
||||
tnl->Driver.Render.BuildVertices( ctx, i, i+length,
|
||||
~0 /*stage->inputs*/);
|
||||
tnl->Driver.Render.PrimTabVerts[flags & PRIM_MODE_MASK]
|
||||
( ctx, i, i + length, flags );
|
||||
vmesa->SetupNewInputs = VERT_CLIP;
|
||||
tnl->Driver.Render.BuildVertices( ctx, start,
|
||||
start+length, ~0 /*stage->inputs*/); /* XXX */
|
||||
tnl->Driver.Render.PrimTabVerts[prim & PRIM_MODE_MASK]
|
||||
( ctx, start, start + length, prim );
|
||||
vmesa->SetupNewInputs = VERT_BIT_POS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,10 +192,10 @@ static GLboolean s3v_run_render( GLcontext *ctx,
|
||||
|
||||
|
||||
static void s3v_check_render( GLcontext *ctx,
|
||||
struct gl_pipeline_stage *stage )
|
||||
struct tnl_pipeline_stage *stage )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
GLuint inputs = VERT_CLIP | VERT_RGBA;
|
||||
GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
|
||||
|
||||
DEBUG(("s3v_check_render\n"));
|
||||
|
||||
@@ -204,22 +203,22 @@ static void s3v_check_render( GLcontext *ctx,
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
|
||||
DEBUG(("DD_SEPARATE_SPECULAR\n"));
|
||||
inputs |= VERT_SPEC_RGB;
|
||||
inputs |= VERT_BIT_COLOR1;
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
DEBUG(("ctx->Texture.Unit[0]._ReallyEnabled\n"));
|
||||
inputs |= VERT_TEX(0);
|
||||
inputs |= VERT_BIT_TEX(0);
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[1]._ReallyEnabled) {
|
||||
DEBUG(("ctx->Texture.Unit[1]._ReallyEnabled\n"));
|
||||
inputs |= VERT_TEX(1);
|
||||
inputs |= VERT_BIT_TEX(1);
|
||||
}
|
||||
|
||||
if (ctx->Fog.Enabled) {
|
||||
DEBUG(("ctx->Fog.Enabled\n"));
|
||||
inputs |= VERT_FOG_COORD;
|
||||
inputs |= VERT_BIT_FOG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,13 +227,15 @@ static void s3v_check_render( GLcontext *ctx,
|
||||
}
|
||||
|
||||
|
||||
static void dtr( struct gl_pipeline_stage *stage )
|
||||
static void dtr( struct tnl_pipeline_stage *stage )
|
||||
{
|
||||
(void)stage;
|
||||
/* hack to silence a compiler warning */
|
||||
(void) &s3v_validate_render;
|
||||
}
|
||||
|
||||
|
||||
const struct gl_pipeline_stage _s3v_render_stage =
|
||||
const struct tnl_pipeline_stage _s3v_render_stage =
|
||||
{
|
||||
"s3v render",
|
||||
(_DD_NEW_SEPARATE_SPECULAR |
|
||||
|
@@ -6,8 +6,6 @@
|
||||
#include "s3v_vb.h"
|
||||
#include "s3v_dri.h"
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv )
|
||||
{
|
||||
s3vScreenPtr s3vScreen;
|
||||
@@ -25,7 +23,7 @@ s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv )
|
||||
|
||||
s3vScreen->regionCount = 4; /* Magic number. Can we fix this? */
|
||||
|
||||
s3vScreen->regions = Xmalloc(s3vScreen->regionCount *
|
||||
s3vScreen->regions = _mesa_malloc(s3vScreen->regionCount *
|
||||
sizeof(s3vRegion));
|
||||
DEBUG(("sPriv->fd = %i\nvDRIPriv->dmaBufHandle = %x\n",
|
||||
sPriv->fd, vDRIPriv->dmaBufHandle));
|
||||
|
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
typedef struct _s3vRegion {
|
||||
drmHandle handle;
|
||||
drm_handle_t handle;
|
||||
drmSize size;
|
||||
drmAddress map;
|
||||
} s3vRegion, *s3vRegionPtr;
|
||||
|
@@ -226,18 +226,19 @@ do { \
|
||||
|
||||
#endif
|
||||
|
||||
static void s3vSetReadBuffer( GLcontext *ctx,
|
||||
GLframebuffer *colorBuffer,
|
||||
GLenum mode )
|
||||
static void s3vSetBuffer( GLcontext *ctx, GLframebuffer *colorBuffer,
|
||||
GLuint bufferBit )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
|
||||
switch ( mode ) {
|
||||
case GL_FRONT_LEFT:
|
||||
vmesa->readOffset = 0;
|
||||
switch ( bufferBit ) {
|
||||
case DD_FRONT_LEFT_BIT:
|
||||
vmesa->drawOffset = vmesa->readOffset = 0;
|
||||
break;
|
||||
case GL_BACK_LEFT:
|
||||
vmesa->readOffset = vmesa->driScreen->fbHeight * vmesa->driScreen->fbWidth * vmesa->s3vScreen->cpp;
|
||||
case DD_BACK_LEFT_BIT:
|
||||
vmesa->drawOffset = vmesa->readOffset = vmesa->driScreen->fbHeight *
|
||||
vmesa->driScreen->fbWidth *
|
||||
vmesa->s3vScreen->cpp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -248,7 +249,7 @@ void s3vInitSpanFuncs( GLcontext *ctx )
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
|
||||
|
||||
swdd->SetReadBuffer = s3vSetReadBuffer;
|
||||
swdd->SetBuffer = s3vSetBuffer;
|
||||
|
||||
switch ( vmesa->s3vScreen->cpp ) {
|
||||
case 2:
|
||||
|
@@ -51,7 +51,7 @@ static void s3vUpdateAlphaMode( GLcontext *ctx )
|
||||
|
||||
}
|
||||
|
||||
static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLchan ref )
|
||||
static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
|
||||
@@ -492,7 +492,7 @@ static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
static void s3vDDClearColor( GLcontext *ctx, const GLchan color[4])
|
||||
static void s3vDDClearColor( GLcontext *ctx, const GLfloat color[4])
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
|
||||
@@ -842,14 +842,17 @@ void s3vInitStateFuncs( GLcontext *ctx )
|
||||
ctx->Driver.Clear = s3vDDClear;
|
||||
ctx->Driver.ClearIndex = NULL;
|
||||
ctx->Driver.ClearColor = s3vDDClearColor;
|
||||
ctx->Driver.SetDrawBuffer = s3vDDSetDrawBuffer;
|
||||
ctx->Driver.DrawBuffer = s3vDDSetDrawBuffer;
|
||||
ctx->Driver.ReadBuffer = NULL; /* XXX */
|
||||
|
||||
ctx->Driver.IndexMask = NULL;
|
||||
ctx->Driver.ColorMask = NULL; /* s3vDDColorMask; */ /* FIXME */
|
||||
|
||||
ctx->Driver.AlphaFunc = s3vDDAlphaFunc; /* FIXME */
|
||||
#if 0
|
||||
ctx->Driver.BlendEquation = NULL; /* s3vDDBlendEquation; */
|
||||
ctx->Driver.BlendFunc = s3vDDBlendFunc; /* FIXME */
|
||||
#endif
|
||||
ctx->Driver.BlendFuncSeparate = NULL; /* s3vDDBlendFuncSeparate; */
|
||||
ctx->Driver.ClearDepth = s3vDDClearDepth;
|
||||
ctx->Driver.CullFace = s3vDDCullFace;
|
||||
|
@@ -7,15 +7,14 @@
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "mem.h"
|
||||
#include "simple_list.h"
|
||||
#include "enums.h"
|
||||
#include "texstore.h"
|
||||
#include "texformat.h"
|
||||
#include "teximage.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "mm.h"
|
||||
#include "mmath.h"
|
||||
#include "s3v_context.h"
|
||||
#include "s3v_tex.h"
|
||||
|
||||
@@ -37,8 +36,8 @@ static void s3vSetTexWrapping(s3vContextPtr vmesa,
|
||||
s3vTextureObjectPtr t,
|
||||
GLenum wraps, GLenum wrapt)
|
||||
{
|
||||
CARD32 t0 = t->TextureCMD;
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint t0 = t->TextureCMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
DEBUG_TEX(("*** s3vSetTexWrapping: #%i ***\n", ++times));
|
||||
@@ -64,8 +63,8 @@ static void s3vSetTexFilter(s3vContextPtr vmesa,
|
||||
s3vTextureObjectPtr t,
|
||||
GLenum minf, GLenum magf)
|
||||
{
|
||||
CARD32 t0 = t->TextureCMD;
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint t0 = t->TextureCMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
DEBUG_TEX(("*** s3vSetTexFilter: #%i ***\n", ++times));
|
||||
@@ -183,7 +182,7 @@ static void s3vTexParameter( GLcontext *ctx, GLenum target,
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
s3vSetTexBorderColor( vmesa, t, tObj->BorderColor );
|
||||
s3vSetTexBorderColor( vmesa, t, tObj->_BorderChan );
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_BASE_LEVEL:
|
||||
@@ -402,7 +401,7 @@ static void s3vBindTexture( GLcontext *ctx, GLenum target,
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT( ctx );
|
||||
s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
DEBUG_TEX(("*** s3vBindTexture: #%i ***\n", ++times));
|
||||
@@ -440,11 +439,6 @@ static void s3vBindTexture( GLcontext *ctx, GLenum target,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!ctx->Texture._ReallyEnabled) {
|
||||
DEBUG_TEX(("!ctx->Texture._ReallyEnabled\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
cmd = vmesa->CMD & ~MIP_MASK;
|
||||
vmesa->dirty |= S3V_UPLOAD_TEX0;
|
||||
vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel];
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
#define TEX_DEBUG_ON 0
|
||||
|
||||
extern void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t );
|
||||
|
||||
#if TEX_DEBUG_ON
|
||||
#define DEBUG_TEX(str) printf str
|
||||
#else
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "enums.h"
|
||||
|
||||
#include "mm.h"
|
||||
#include "mem.h"
|
||||
#include "s3v_context.h"
|
||||
#include "s3v_lock.h"
|
||||
#include "s3v_tex.h"
|
||||
@@ -103,7 +102,7 @@ static void s3vUploadTexLevel( s3vContextPtr vmesa, s3vTextureObjectPtr t,
|
||||
int l2d;
|
||||
/* int offset = 0; */
|
||||
int words;
|
||||
CARD32* dest;
|
||||
GLuint* dest;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
#endif
|
||||
@@ -121,9 +120,9 @@ static void s3vUploadTexLevel( s3vContextPtr vmesa, s3vTextureObjectPtr t,
|
||||
DEBUG_TEX(("t->image[%i].offset = 0x%x\n",
|
||||
level, t->image[level].offset));
|
||||
|
||||
t->TextureBaseAddr[level] = (CARD32)(t->BufAddr + t->image[level].offset
|
||||
+ _TEXALIGN) & (CARD32)(~_TEXALIGN);
|
||||
dest = (CARD32*)(sPriv->pFB + t->TextureBaseAddr[level]);
|
||||
t->TextureBaseAddr[level] = (GLuint)(t->BufAddr + t->image[level].offset
|
||||
+ _TEXALIGN) & (GLuint)(~_TEXALIGN);
|
||||
dest = (GLuint*)(sPriv->pFB + t->TextureBaseAddr[level]);
|
||||
|
||||
DEBUG_TEX(("sPriv->pFB = 0x%x\n", sPriv->pFB));
|
||||
DEBUG_TEX(("dest = 0x%x\n", dest));
|
||||
|
@@ -21,7 +21,7 @@ static void s3vSetTexImages( s3vContextPtr vmesa,
|
||||
{
|
||||
GLuint height, width, pitch, i, /*textureFormat,*/ log_pitch;
|
||||
s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
|
||||
const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
|
||||
const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
|
||||
GLint firstLevel, lastLevel, numLevels;
|
||||
GLint log2Width, log2Height;
|
||||
#if TEX_DEBUG_ON
|
||||
@@ -55,15 +55,15 @@ static void s3vSetTexImages( s3vContextPtr vmesa,
|
||||
|
||||
numLevels = lastLevel - firstLevel + 1;
|
||||
|
||||
log2Width = tObj->Image[firstLevel]->WidthLog2;
|
||||
log2Height = tObj->Image[firstLevel]->HeightLog2;
|
||||
log2Width = tObj->Image[0][firstLevel]->WidthLog2;
|
||||
log2Height = tObj->Image[0][firstLevel]->HeightLog2;
|
||||
|
||||
|
||||
/* Figure out the amount of memory required to hold all the mipmap
|
||||
* levels. Choose the smallest pitch to accomodate the largest
|
||||
* mipmap:
|
||||
*/
|
||||
width = tObj->Image[firstLevel]->Width * t->texelBytes;
|
||||
width = tObj->Image[0][firstLevel]->Width * t->texelBytes;
|
||||
for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
|
||||
log_pitch++;
|
||||
|
||||
@@ -71,12 +71,12 @@ static void s3vSetTexImages( s3vContextPtr vmesa,
|
||||
* lines required:
|
||||
*/
|
||||
for ( height = i = 0 ; i < numLevels ; i++ ) {
|
||||
t->image[i].image = tObj->Image[firstLevel + i];
|
||||
t->image[i].image = tObj->Image[0][firstLevel + i];
|
||||
t->image[i].offset = height * pitch;
|
||||
t->image[i].internalFormat = baseImage->Format;
|
||||
height += t->image[i].image->Height;
|
||||
t->TextureBaseAddr[i] = (t->BufAddr + t->image[i].offset +
|
||||
_TEXALIGN) & (CARD32)(~_TEXALIGN);
|
||||
_TEXALIGN) & (GLuint)(~_TEXALIGN);
|
||||
}
|
||||
|
||||
t->Pitch = pitch;
|
||||
@@ -96,13 +96,13 @@ static void s3vUpdateTexEnv( GLcontext *ctx, GLuint unit )
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
const struct gl_texture_object *tObj = texUnit->_Current;
|
||||
const GLuint format = tObj->Image[tObj->BaseLevel]->Format;
|
||||
const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format;
|
||||
/*
|
||||
s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
|
||||
GLuint tc;
|
||||
*/
|
||||
GLuint alpha = 0;
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
DEBUG_TEX(("*** s3vUpdateTexEnv: %i ***\n", ++times));
|
||||
@@ -205,14 +205,14 @@ static void s3vUpdateTexUnit( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
DEBUG_TEX(("*** s3vUpdateTexUnit: %i ***\n", ++times));
|
||||
DEBUG_TEX(("and vmesa->CMD was 0x%x\n", vmesa->CMD));
|
||||
#endif
|
||||
|
||||
if (texUnit->_ReallyEnabled == TEXTURE0_2D)
|
||||
if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT)
|
||||
{
|
||||
struct gl_texture_object *tObj = texUnit->_Current;
|
||||
s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
|
||||
@@ -246,8 +246,9 @@ static void s3vUpdateTexUnit( GLcontext *ctx, GLuint unit )
|
||||
/* Update texture environment if texture object image format or
|
||||
* texture environment state has changed.
|
||||
*/
|
||||
if (tObj->Image[tObj->BaseLevel]->Format != vmesa->TexEnvImageFmt[unit]) {
|
||||
vmesa->TexEnvImageFmt[unit] = tObj->Image[tObj->BaseLevel]->Format;
|
||||
if (tObj->Image[0][tObj->BaseLevel]->Format !=
|
||||
vmesa->TexEnvImageFmt[unit]) {
|
||||
vmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
|
||||
s3vUpdateTexEnv( ctx, unit );
|
||||
}
|
||||
#if 1
|
||||
@@ -283,16 +284,12 @@ static void s3vUpdateTexUnit( GLcontext *ctx, GLuint unit )
|
||||
void s3vUpdateTextureState( GLcontext *ctx )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
(void) vmesa;
|
||||
#if TEX_DEBUG_ON
|
||||
static unsigned int times=0;
|
||||
DEBUG_TEX(("*** s3vUpdateTextureState: #%i ***\n", ++times));
|
||||
#endif
|
||||
|
||||
if (!ctx->Texture._ReallyEnabled) {
|
||||
DEBUG_TEX(("!ctx->Texture._ReallyEnabled\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
#if _TEXFALLBACK
|
||||
FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_FALSE );
|
||||
#endif
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#define HAVE_BACK_COLORS 0
|
||||
#define HAVE_HW_FLATSHADE 1
|
||||
#define VERTEX s3vVertex
|
||||
#define TAB rast_tab
|
||||
#define TAB rast_tab
|
||||
|
||||
#define VERT_SET_RGBA( v, c ) \
|
||||
do { \
|
||||
@@ -55,10 +55,10 @@ do { \
|
||||
|
||||
|
||||
static struct {
|
||||
points_func points;
|
||||
line_func line;
|
||||
triangle_func triangle;
|
||||
quad_func quad;
|
||||
tnl_points_func points;
|
||||
tnl_line_func line;
|
||||
tnl_triangle_func triangle;
|
||||
tnl_quad_func quad;
|
||||
} rast_tab[S3V_MAX_TRIFUNC];
|
||||
|
||||
#define S3V_RAST_CULL_BIT 0x01
|
||||
@@ -236,7 +236,7 @@ void s3vChooseRasterState(GLcontext *ctx)
|
||||
if ( flags & DD_FLATSHADE )
|
||||
ind |= S3V_RAST_FLAT_BIT;
|
||||
|
||||
if ( ctx->Texture._ReallyEnabled ) {
|
||||
if ( ctx->Texture.Unit[0]._ReallyEnabled ) {
|
||||
ind |= S3V_RAST_TEX_BIT;
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
/* __DRIdrawablePrivate *dPriv = vmesa->driDrawable; */
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
|
||||
unsigned int _hw_prim = hwprim;
|
||||
|
||||
@@ -650,7 +650,7 @@ static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim )
|
||||
{
|
||||
s3vContextPtr vmesa = S3V_CONTEXT(ctx);
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
CARD32 cmd = vmesa->CMD;
|
||||
GLuint cmd = vmesa->CMD;
|
||||
|
||||
unsigned int _hw_prim = hw_prim[prim];
|
||||
|
||||
|
@@ -17,18 +17,26 @@
|
||||
int start02, end01; \
|
||||
int ystart, y01y12; \
|
||||
int i, tmp, tmp2, tmp3; \
|
||||
GLfloat ydiff, fy[3]
|
||||
GLfloat ydiff, fy[3]; \
|
||||
(void) v; (void) vvv; (void) x; (void) y; (void) z; (void) idx; \
|
||||
(void) dx01; (void) dy01; (void) delt02; (void) deltzy; \
|
||||
(void) zstart; (void) start02; (void) ystart; (void) y01y12; \
|
||||
(void) i; (void) tmp; (void) tmp2; (void) tmp3; (void) ydiff; (void) fy
|
||||
|
||||
#define LINE_FLAT_VARS \
|
||||
int arstart, gbstart; \
|
||||
int deltarx, deltgbx, deltary, deltgby; \
|
||||
GLubyte *(col)[3]
|
||||
GLubyte *(col)[3]; \
|
||||
(void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
|
||||
(void) deltary; (void) deltgby; (void) col
|
||||
|
||||
#define LINE_GOURAUD_VARS \
|
||||
int arstart, gbstart; \
|
||||
int deltary, deltgby; \
|
||||
int ctmp, ctmp2, ctmp3, ctmp4; \
|
||||
GLubyte *(col)[3]
|
||||
GLubyte *(col)[3]; \
|
||||
(void) arstart; (void) gbstart; (void) deltary; (void) deltgby; \
|
||||
(void) ctmp; (void) ctmp2; (void) ctmp3; (void) ctmp4; (void) col
|
||||
|
||||
#define SORT_LINE_VERT() \
|
||||
do { \
|
||||
@@ -199,18 +207,29 @@ do { \
|
||||
int start02, end01, end12; \
|
||||
int ystart, y01y12; \
|
||||
int i, tmp, lr; \
|
||||
GLfloat ydiff, fy[3]
|
||||
GLfloat ydiff, fy[3]; \
|
||||
(void) v; (void) x; (void) y; (void) z; (void) idx; (void) dx01; \
|
||||
(void) dy01; (void) dx02; (void) dy02; (void) dx12; (void) dy12; \
|
||||
(void) delt01; (void) delt02; (void) delt12; (void) deltzx; \
|
||||
(void) deltzy; (void) zstart; (void) start02; (void) end01; \
|
||||
(void) end12; (void) ystart; (void) y01y12; (void) i; (void) tmp; \
|
||||
(void) lr; (void) ydiff; (void) fy
|
||||
|
||||
#define GOURAUD_VARS \
|
||||
int arstart, gbstart; \
|
||||
int deltarx, deltgbx, deltary, deltgby; \
|
||||
int ctmp, ctmp2, ctmp3, ctmp4; \
|
||||
GLubyte *(col)[3]
|
||||
GLubyte *(col)[3]; \
|
||||
(void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
|
||||
(void) deltary; (void) deltgby; (void) ctmp; (void) ctmp2; \
|
||||
(void) ctmp3; (void) ctmp4; (void) col
|
||||
|
||||
#define FLAT_VARS \
|
||||
int arstart, gbstart; \
|
||||
int deltarx, deltgbx, deltary, deltgby; \
|
||||
GLubyte *(col)[3]
|
||||
GLubyte *(col)[3]; \
|
||||
(void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
|
||||
(void) deltary; (void) deltgby; (void) col
|
||||
|
||||
#define TEX_VARS \
|
||||
int u0, u1, u2; \
|
||||
@@ -226,7 +245,15 @@ do { \
|
||||
int rbaseu, rbasev; \
|
||||
int dstart, ustart, wstart, vstart; \
|
||||
static int stmp = 0; \
|
||||
s3vTextureObjectPtr t
|
||||
s3vTextureObjectPtr t; \
|
||||
(void) u0; (void) u1; (void) u2; (void) ru0; (void) ru1; (void) ru2; \
|
||||
(void) v0; (void) v1; (void) v2; (void) rv0; (void) rv1; (void) rv2; \
|
||||
(void) w0; (void) w1; (void) w2; (void) rw0; (void) rw1; (void) rw2; \
|
||||
(void) baseu; (void) basev; (void) d0; (void) d1; (void) d2; \
|
||||
(void) deltdx; (void) deltvx; (void) deltux; (void) deltdy; \
|
||||
(void) deltuy; (void) deltwx; (void) deltwy; (void) rbaseu; \
|
||||
(void) rbasev; (void) dstart; (void) ustart; (void) wstart; \
|
||||
(void) vstart; (void) stmp; (void) t
|
||||
|
||||
#define SORT_VERT() \
|
||||
do { \
|
||||
@@ -376,15 +403,15 @@ do { \
|
||||
u0 = (v[idx[0]].texcoord[0][0] \
|
||||
* (GLfloat)(t->image[0].image->Width) * 256.0); \
|
||||
u1 = (v[idx[1]].texcoord[0][0] \
|
||||
* (GLfloat)(t->globj->Image[0]->Width) * 256.0); \
|
||||
* (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
|
||||
u2 = (v[idx[2]].texcoord[0][0] \
|
||||
* (GLfloat)(t->globj->Image[0]->Width) * 256.0); \
|
||||
* (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
|
||||
v0 = (v[idx[0]].texcoord[0][1] \
|
||||
* (GLfloat)(t->globj->Image[0]->Height) * 256.0); \
|
||||
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
|
||||
v1 = (v[idx[1]].texcoord[0][1] \
|
||||
* (GLfloat)(t->globj->Image[0]->Height) * 256.0); \
|
||||
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
|
||||
v2 = (v[idx[2]].texcoord[0][1] \
|
||||
* (GLfloat)(t->globj->Image[0]->Height) * 256.0); \
|
||||
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
|
||||
\
|
||||
w0 = (v[idx[0]].win[3]); \
|
||||
w1 = (v[idx[1]].win[3]); \
|
||||
@@ -492,8 +519,8 @@ do { \
|
||||
rv1 = (((v1 - basev) * rw1)); \
|
||||
rv2 = (((v2 - basev) * rw2)); \
|
||||
\
|
||||
while (baseu < 0) { baseu += (t->globj->Image[0]->Width << 8); } \
|
||||
while (basev < 0) { basev += (t->globj->Image[0]->Height << 8); } \
|
||||
while (baseu < 0) { baseu += (t->globj->Image[0][0]->Width << 8); } \
|
||||
while (basev < 0) { basev += (t->globj->Image[0][0]->Height << 8); } \
|
||||
\
|
||||
if (!(baseu & 0xFF)) \
|
||||
{ baseu = (baseu >> 8); } \
|
||||
@@ -505,8 +532,8 @@ do { \
|
||||
else \
|
||||
{ basev = (basev >> 8) - 1; } \
|
||||
\
|
||||
rbaseu = (baseu) << (16 - t->globj->Image[0]->WidthLog2); \
|
||||
rbasev = (basev) << (16 - t->globj->Image[0]->WidthLog2); \
|
||||
rbaseu = (baseu) << (16 - t->globj->Image[0][0]->WidthLog2); \
|
||||
rbasev = (basev) << (16 - t->globj->Image[0][0]->WidthLog2); \
|
||||
deltuy = (((ru2 - ru0) / dy02)); \
|
||||
deltvy = (((rv2 - rv0) / dy02)); \
|
||||
rw0 *= (1024.0 * 512.0); \
|
||||
@@ -591,6 +618,7 @@ static void TAG(s3v_line)( s3vContextPtr vmesa,
|
||||
#endif
|
||||
#if (IND & S3V_RAST_CULL_BIT)
|
||||
GLfloat cull;
|
||||
(void) cull;
|
||||
#endif
|
||||
|
||||
DEBUG(("*** s3v_line: "));
|
||||
|
@@ -4,10 +4,8 @@
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "mem.h"
|
||||
#include "macros.h"
|
||||
#include "colormac.h"
|
||||
#include "mmath.h"
|
||||
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/t_context.h"
|
||||
@@ -26,8 +24,8 @@
|
||||
|
||||
static struct {
|
||||
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
|
||||
interp_func interp;
|
||||
copy_pv_func copy_pv;
|
||||
tnl_interp_func interp;
|
||||
tnl_copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)( GLcontext *ctx );
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
@@ -61,6 +59,7 @@ static struct {
|
||||
#define GET_VIEWPORT_MAT() 0 /* vmesa->hw_viewport */
|
||||
#define GET_TEXSOURCE(n) n
|
||||
#define GET_VERTEX_FORMAT() 0
|
||||
#define GET_VERTEX_SIZE() S3V_CONTEXT(ctx)->vertex_size * sizeof(GLuint)
|
||||
#define GET_VERTEX_STORE() S3V_CONTEXT(ctx)->verts
|
||||
#define GET_VERTEX_STRIDE_SHIFT() S3V_CONTEXT(ctx)->vertex_stride_shift
|
||||
#define INVALIDATE_STORED_VERTICES()
|
||||
@@ -71,8 +70,8 @@ static struct {
|
||||
#define HAVE_HW_DIVIDE 1
|
||||
#define HAVE_RGBA_COLOR 0 /* we're BGRA */
|
||||
#define HAVE_TINY_VERTICES 1
|
||||
#define HAVE_NOTEX_VERTICES 1
|
||||
#define HAVE_TEX0_VERTICES 1
|
||||
#define HAVE_NOTEX_VERTICES 0
|
||||
#define HAVE_TEX0_VERTICES 0
|
||||
#define HAVE_TEX1_VERTICES 0
|
||||
#define HAVE_TEX2_VERTICES 0
|
||||
#define HAVE_TEX3_VERTICES 0
|
||||
@@ -216,7 +215,6 @@ void s3vBuildVertices( GLcontext *ctx,
|
||||
GLubyte *v = ((GLubyte *)vmesa->verts +
|
||||
(start<<vmesa->vertex_stride_shift));
|
||||
GLuint stride = 1<<vmesa->vertex_stride_shift;
|
||||
GLuint ind = 0;
|
||||
|
||||
DEBUG(("*** s3vBuildVertices ***\n"));
|
||||
DEBUG(("vmesa->SetupNewInputs = 0x%x\n", vmesa->SetupNewInputs));
|
||||
@@ -284,7 +282,7 @@ void s3vChooseVertexState( GLcontext *ctx )
|
||||
*/
|
||||
|
||||
|
||||
if (ctx->Texture._ReallyEnabled) {
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
_tnl_need_projected_coords( ctx, GL_FALSE );
|
||||
ind |= S3V_TEX0_BIT;
|
||||
} else {
|
||||
@@ -330,12 +328,12 @@ void s3vFreeVB( GLcontext *ctx )
|
||||
}
|
||||
|
||||
if (vmesa->UbyteSecondaryColor.Ptr) {
|
||||
ALIGN_FREE(vmesa->UbyteSecondaryColor.Ptr);
|
||||
ALIGN_FREE((void *)vmesa->UbyteSecondaryColor.Ptr);
|
||||
vmesa->UbyteSecondaryColor.Ptr = 0;
|
||||
}
|
||||
|
||||
if (vmesa->UbyteColor.Ptr) {
|
||||
ALIGN_FREE(vmesa->UbyteColor.Ptr);
|
||||
ALIGN_FREE((void *)vmesa->UbyteColor.Ptr);
|
||||
vmesa->UbyteColor.Ptr = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include "s3v_context.h"
|
||||
#include "s3v_vb.h"
|
||||
#include "context.h"
|
||||
#include "mmath.h"
|
||||
#include "matrix.h"
|
||||
#include "s3v_dri.h"
|
||||
|
||||
@@ -46,15 +45,14 @@ s3vDestroyContext(__DRIcontextPrivate *driContextPriv)
|
||||
vmesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context(vmesa->glCtx);
|
||||
|
||||
Xfree(vmesa);
|
||||
_mesa_free(vmesa);
|
||||
driContextPriv->driverPrivate = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
s3vCreateBuffer( Display *dpy,
|
||||
__DRIscreenPrivate *driScrnPriv,
|
||||
s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap )
|
||||
@@ -82,7 +80,7 @@ s3vDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
|
||||
}
|
||||
|
||||
static void
|
||||
s3vSwapBuffers(Display *dpy, void *drawablePrivate)
|
||||
s3vSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
|
||||
__DRIscreenPrivate *sPriv;
|
||||
@@ -99,14 +97,14 @@ s3vSwapBuffers(Display *dpy, void *drawablePrivate)
|
||||
|
||||
/* DMAFLUSH(); */
|
||||
|
||||
_mesa_swapbuffers( ctx );
|
||||
_mesa_notifySwapBuffers( ctx );
|
||||
|
||||
vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
/* driScrnPriv = vmesa->driScreen; */
|
||||
|
||||
/* if (vmesa->EnabledFlags & S3V_BACK_BUFFER) */
|
||||
|
||||
/* _mesa_swapbuffers( ctx ); */
|
||||
/* _mesa_notifySwapBuffers( ctx ); */
|
||||
#if 1
|
||||
{
|
||||
int x0, y0, x1, y1;
|
||||
@@ -174,6 +172,7 @@ s3vMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
||||
|
||||
s3vContextPtr vmesa;
|
||||
__DRIdrawablePrivate *dPriv = driDrawPriv;
|
||||
vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
|
||||
DEBUG(("s3vMakeCurrent\n"));
|
||||
|
||||
@@ -275,18 +274,6 @@ s3vUnbindContext( __DRIcontextPrivate *driContextPriv )
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
s3vOpenFullScreen(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
s3vCloseFullScreen(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static struct __DriverAPIRec s3vAPI = {
|
||||
s3vInitDriver,
|
||||
@@ -298,12 +285,10 @@ static struct __DriverAPIRec s3vAPI = {
|
||||
s3vSwapBuffers,
|
||||
s3vMakeCurrent,
|
||||
s3vUnbindContext,
|
||||
s3vOpenFullScreen,
|
||||
s3vCloseFullScreen
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* This is the bootstrap function for the driver.
|
||||
* The __driCreateScreen name is the symbol that libGL.so fetches.
|
||||
@@ -319,6 +304,7 @@ void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
|
||||
DEBUG(("__driCreateScreen: psp = %p\n", psp));
|
||||
return (void *) psp;
|
||||
}
|
||||
#endif
|
||||
|
||||
void __driRegisterExtensions(void)
|
||||
{
|
||||
|
@@ -141,6 +141,7 @@ struct savage_context_t {
|
||||
/* Manage our own state */
|
||||
GLuint new_state;
|
||||
GLuint new_gl_state;
|
||||
GLboolean ptexHack;
|
||||
|
||||
GLuint BCIBase;
|
||||
GLuint MMIO_BASE;
|
||||
@@ -179,6 +180,7 @@ struct savage_context_t {
|
||||
GLenum render_primitive;
|
||||
|
||||
GLuint DrawPrimitiveCmd;
|
||||
GLuint HwVertexSize;
|
||||
|
||||
/* Fallback rasterization functions
|
||||
*/
|
||||
|
@@ -312,8 +312,8 @@ static drmBuf vertex_buffer = {
|
||||
};
|
||||
|
||||
void savageFakeVertices (savageContextPtr imesa, drmBufPtr buffer) {
|
||||
GLuint vertexStride = imesa->vertex_size; /* stride in dwords */
|
||||
GLuint vertexSize = imesa->vertex_size; /* the real vertex size in dwords */
|
||||
GLuint vertexStride = imesa->HwVertexSize; /* stride in dwords */
|
||||
GLuint vertexSize = imesa->HwVertexSize; /* the real vertex size in dwords */
|
||||
GLuint nVertices = buffer->used / (vertexStride*4);
|
||||
u_int32_t *data = (u_int32_t*)buffer->address;
|
||||
u_int32_t vertexFormat = imesa->DrawPrimitiveCmd & SAVAGE_HW_SKIPFLAGS;
|
||||
|
@@ -839,9 +839,9 @@ static void savageUpdateTex0State_s4( GLcontext *ctx )
|
||||
}
|
||||
|
||||
tObj = ctx->Texture.Unit[0]._Current;
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled != TEXTURE_2D_BIT ||
|
||||
tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
/* 1D or 3D texturing enabled, or texture border - fallback */
|
||||
if ((ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
|
||||
|| tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
/* 3D texturing enabled, or texture border - fallback */
|
||||
FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -1109,9 +1109,9 @@ static void savageUpdateTex1State_s4( GLcontext *ctx )
|
||||
|
||||
tObj = ctx->Texture.Unit[1]._Current;
|
||||
|
||||
if (ctx->Texture.Unit[1]._ReallyEnabled != TEXTURE_2D_BIT ||
|
||||
tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
/* 1D or 3D texturing enabled, or texture border - fallback */
|
||||
if ((ctx->Texture.Unit[1]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
|
||||
|| tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
/* 3D texturing enabled, or texture border - fallback */
|
||||
FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -1302,9 +1302,9 @@ static void savageUpdateTexState_s3d( GLcontext *ctx )
|
||||
}
|
||||
|
||||
tObj = ctx->Texture.Unit[0]._Current;
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled != TEXTURE_2D_BIT ||
|
||||
tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
/* 1D or 3D texturing enabled, or texture border - fallback */
|
||||
if ((ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
|
||||
|| tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
/* 3D texturing enabled, or texture border - fallback */
|
||||
FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -1495,6 +1495,60 @@ static void savageTexEnv( GLcontext *ctx, GLenum target,
|
||||
}
|
||||
}
|
||||
|
||||
static void savageTexImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLint width, GLint border,
|
||||
GLenum format, GLenum type, const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
savageTextureObjectPtr t = (savageTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
savageSwapOutTexObj( SAVAGE_CONTEXT(ctx), t );
|
||||
} else {
|
||||
t = savageAllocTexObj(texObj);
|
||||
if (!t) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
|
||||
return;
|
||||
}
|
||||
}
|
||||
_mesa_store_teximage1d( ctx, target, level, internalFormat,
|
||||
width, border, format, type,
|
||||
pixels, packing, texObj, texImage );
|
||||
t->dirty_images |= (1 << level);
|
||||
SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
|
||||
}
|
||||
|
||||
static void savageTexSubImage1D( GLcontext *ctx,
|
||||
GLenum target,
|
||||
GLint level,
|
||||
GLint xoffset,
|
||||
GLsizei width,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
savageTextureObjectPtr t = (savageTextureObjectPtr) texObj->DriverData;
|
||||
assert( t ); /* this _should_ be true */
|
||||
if (t) {
|
||||
savageSwapOutTexObj( SAVAGE_CONTEXT(ctx), t );
|
||||
} else {
|
||||
t = savageAllocTexObj(texObj);
|
||||
if (!t) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
|
||||
return;
|
||||
}
|
||||
}
|
||||
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
|
||||
format, type, pixels, packing, texObj,
|
||||
texImage);
|
||||
t->dirty_images |= (1 << level);
|
||||
SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
|
||||
}
|
||||
|
||||
static void savageTexImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLint width, GLint height, GLint border,
|
||||
@@ -1538,7 +1592,7 @@ static void savageTexSubImage2D( GLcontext *ctx,
|
||||
} else {
|
||||
t = savageAllocTexObj(texObj);
|
||||
if (!t) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1556,7 +1610,7 @@ static void savageTexParameter( GLcontext *ctx, GLenum target,
|
||||
savageTextureObjectPtr t = (savageTextureObjectPtr) tObj->DriverData;
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
|
||||
if (!t || target != GL_TEXTURE_2D)
|
||||
if (!t || (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D))
|
||||
return;
|
||||
|
||||
switch (pname) {
|
||||
@@ -1586,7 +1640,8 @@ static void savageBindTexture( GLcontext *ctx, GLenum target,
|
||||
{
|
||||
savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
|
||||
|
||||
assert( (target != GL_TEXTURE_2D) || (tObj->DriverData != NULL) );
|
||||
assert( (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) ||
|
||||
(tObj->DriverData != NULL) );
|
||||
|
||||
imesa->new_state |= SAVAGE_NEW_TEXTURE;
|
||||
}
|
||||
@@ -1638,6 +1693,8 @@ void savageDDInitTextureFuncs( struct dd_function_table *functions )
|
||||
{
|
||||
functions->TexEnv = savageTexEnv;
|
||||
functions->ChooseTextureFormat = savageChooseTextureFormat;
|
||||
functions->TexImage1D = savageTexImage1D;
|
||||
functions->TexSubImage1D = savageTexSubImage1D;
|
||||
functions->TexImage2D = savageTexImage2D;
|
||||
functions->TexSubImage2D = savageTexSubImage2D;
|
||||
functions->BindTexture = savageBindTexture;
|
||||
|
@@ -77,14 +77,14 @@ static GLenum reduced_prim[GL_POLYGON+1] = {
|
||||
***********************************************************************/
|
||||
|
||||
#if defined (USE_X86_ASM)
|
||||
#define EMIT_VERT( j, vb, vertex_size, start, v ) \
|
||||
do { int __tmp; \
|
||||
vb += start; \
|
||||
__asm__ __volatile__( "rep ; movsl" \
|
||||
: "=%c" (j), "=D" (vb), "=S" (__tmp) \
|
||||
: "0" (vertex_size-start), \
|
||||
"D" ((long)vb), \
|
||||
"S" ((long)&v->ui[start])); \
|
||||
#define EMIT_VERT( j, vb, vertex_size, start, v ) \
|
||||
do { int __tmp; \
|
||||
vb += start; \
|
||||
__asm__ __volatile__( "rep ; movsl" \
|
||||
: "=%c" (j), "=D" (vb), "=S" (__tmp) \
|
||||
: "0" (vertex_size-start), \
|
||||
"D" ((long)vb), \
|
||||
"S" ((long)&(v)->ui[start])); \
|
||||
} while (0)
|
||||
#else
|
||||
#define EMIT_VERT( j, vb, vertex_size, start, v ) \
|
||||
@@ -99,7 +99,7 @@ static void __inline__ savage_draw_triangle (savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1,
|
||||
savageVertexPtr v2) {
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 3*4*vertsize);
|
||||
GLuint j;
|
||||
|
||||
@@ -113,7 +113,7 @@ static void __inline__ savage_draw_quad (savageContextPtr imesa,
|
||||
savageVertexPtr v1,
|
||||
savageVertexPtr v2,
|
||||
savageVertexPtr v3) {
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
|
||||
GLuint j;
|
||||
|
||||
@@ -127,7 +127,7 @@ static void __inline__ savage_draw_quad (savageContextPtr imesa,
|
||||
|
||||
static __inline__ void savage_draw_point (savageContextPtr imesa,
|
||||
savageVertexPtr tmp) {
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
|
||||
const GLfloat x = tmp->v.x;
|
||||
const GLfloat y = tmp->v.y;
|
||||
@@ -162,7 +162,7 @@ static __inline__ void savage_draw_point (savageContextPtr imesa,
|
||||
static __inline__ void savage_draw_line (savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1 ) {
|
||||
GLuint vertsize = imesa->vertex_size;
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
|
||||
GLfloat width = imesa->glCtx->Line._Width;
|
||||
GLfloat dx, dy, ix, iy;
|
||||
@@ -200,6 +200,117 @@ static __inline__ void savage_draw_line (savageContextPtr imesa,
|
||||
*(float *)&vb[1] = v1->v.y + iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, v1);
|
||||
}
|
||||
|
||||
/* Fallback drawing functions for the ptex hack. Code duplication
|
||||
* (especially lines and points) isn't beautiful, but I didn't feel
|
||||
* like inventing yet another template. :-/
|
||||
*/
|
||||
#define PTEX_VERTEX( j, tmp, vertex_size, start, v) \
|
||||
do { \
|
||||
GLfloat rhw = 1.0 / v->f[vertex_size]; \
|
||||
for ( j = start ; j < vertex_size ; j++ ) \
|
||||
tmp.f[j] = v->f[j]; \
|
||||
tmp.f[3] *= v->f[vertex_size]; \
|
||||
tmp.f[vertex_size-2] *= rhw; \
|
||||
tmp.f[vertex_size-1] *= rhw; \
|
||||
} while (0)
|
||||
|
||||
static void __inline__ savage_ptex_tri (savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1,
|
||||
savageVertexPtr v2) {
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 3*4*vertsize);
|
||||
savageVertex tmp;
|
||||
GLuint j;
|
||||
|
||||
PTEX_VERTEX (j, tmp, vertsize, 0, v0); EMIT_VERT (j, vb, vertsize, 0, &tmp);
|
||||
PTEX_VERTEX (j, tmp, vertsize, 0, v1); EMIT_VERT (j, vb, vertsize, 0, &tmp);
|
||||
PTEX_VERTEX (j, tmp, vertsize, 0, v2); EMIT_VERT (j, vb, vertsize, 0, &tmp);
|
||||
}
|
||||
|
||||
static __inline__ void savage_ptex_line (savageContextPtr imesa,
|
||||
savageVertexPtr v0,
|
||||
savageVertexPtr v1 ) {
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
|
||||
GLfloat width = imesa->glCtx->Line._Width;
|
||||
GLfloat dx, dy, ix, iy;
|
||||
savageVertex tmp0, tmp1;
|
||||
GLuint j;
|
||||
|
||||
PTEX_VERTEX (j, tmp0, vertsize, 2, v0);
|
||||
PTEX_VERTEX (j, tmp1, vertsize, 2, v1);
|
||||
|
||||
dx = v0->v.x - v1->v.x;
|
||||
dy = v0->v.y - v1->v.y;
|
||||
|
||||
ix = width * .5; iy = 0;
|
||||
if (dx * dx > dy * dy) {
|
||||
iy = ix; ix = 0;
|
||||
}
|
||||
|
||||
*(float *)&vb[0] = v0->v.x - ix;
|
||||
*(float *)&vb[1] = v0->v.y - iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp0);
|
||||
|
||||
*(float *)&vb[0] = v1->v.x + ix;
|
||||
*(float *)&vb[1] = v1->v.y + iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp1);
|
||||
|
||||
*(float *)&vb[0] = v0->v.x + ix;
|
||||
*(float *)&vb[1] = v0->v.y + iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp0);
|
||||
|
||||
*(float *)&vb[0] = v0->v.x - ix;
|
||||
*(float *)&vb[1] = v0->v.y - iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp0);
|
||||
|
||||
*(float *)&vb[0] = v1->v.x - ix;
|
||||
*(float *)&vb[1] = v1->v.y - iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp1);
|
||||
|
||||
*(float *)&vb[0] = v1->v.x + ix;
|
||||
*(float *)&vb[1] = v1->v.y + iy;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp1);
|
||||
}
|
||||
|
||||
static __inline__ void savage_ptex_point (savageContextPtr imesa,
|
||||
savageVertexPtr v0) {
|
||||
GLuint vertsize = imesa->HwVertexSize;
|
||||
u_int32_t *vb = savageAllocDmaLow (imesa, 6*4*vertsize);
|
||||
const GLfloat x = v0->v.x;
|
||||
const GLfloat y = v0->v.y;
|
||||
const GLfloat sz = imesa->glCtx->Point._Size * .5;
|
||||
savageVertex tmp;
|
||||
GLuint j;
|
||||
|
||||
PTEX_VERTEX (j, tmp, vertsize, 2, v0);
|
||||
|
||||
*(float *)&vb[0] = x - sz;
|
||||
*(float *)&vb[1] = y - sz;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp);
|
||||
|
||||
*(float *)&vb[0] = x + sz;
|
||||
*(float *)&vb[1] = y - sz;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp);
|
||||
|
||||
*(float *)&vb[0] = x + sz;
|
||||
*(float *)&vb[1] = y + sz;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp);
|
||||
|
||||
*(float *)&vb[0] = x + sz;
|
||||
*(float *)&vb[1] = y + sz;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp);
|
||||
|
||||
*(float *)&vb[0] = x - sz;
|
||||
*(float *)&vb[1] = y + sz;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp);
|
||||
|
||||
*(float *)&vb[0] = x - sz;
|
||||
*(float *)&vb[1] = y - sz;
|
||||
EMIT_VERT (j, vb, vertsize, 2, &tmp);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Macros for t_dd_tritmp.h to draw basic primitives *
|
||||
@@ -591,6 +702,18 @@ static void savageChooseRenderState(GLcontext *ctx)
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint index = 0;
|
||||
|
||||
/* Hook in fallback functions for the ptex hack. Do this first, so
|
||||
* that a real fallback will overwrite them with the respective
|
||||
* savage_fallback_... function.
|
||||
*/
|
||||
if (imesa->ptexHack) {
|
||||
/* Do textures make sense with points? */
|
||||
imesa->draw_point = savage_ptex_point;
|
||||
imesa->draw_line = savage_ptex_line;
|
||||
imesa->draw_tri = savage_ptex_tri;
|
||||
index |= SAVAGE_FALLBACK_BIT;
|
||||
}
|
||||
|
||||
if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
|
||||
imesa->draw_point = savage_draw_point;
|
||||
imesa->draw_line = savage_draw_line;
|
||||
@@ -604,7 +727,7 @@ static void savageChooseRenderState(GLcontext *ctx)
|
||||
|
||||
/* Hook in fallbacks for specific primitives.
|
||||
*/
|
||||
if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
|
||||
if (flags & ANY_FALLBACK_FLAGS) {
|
||||
if (flags & POINT_FALLBACK) imesa->draw_point = savage_fallback_point;
|
||||
if (flags & LINE_FALLBACK) imesa->draw_line = savage_fallback_line;
|
||||
if (flags & TRI_FALLBACK) imesa->draw_tri = savage_fallback_tri;
|
||||
@@ -706,6 +829,28 @@ static void savageRenderPrimitive( GLcontext *ctx, GLenum prim )
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if projective texture coordinates are used and if we can fake
|
||||
* them. Fallback to swrast we can't. Returns GL_TRUE if projective
|
||||
* texture coordinates must be faked, GL_FALSE otherwise.
|
||||
*/
|
||||
static GLboolean savageCheckPTexHack( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint index = tnl->render_inputs;
|
||||
|
||||
if (index & _TNL_BIT_TEX(0) && VB->TexCoordPtr[0]->size == 4) {
|
||||
if ((index & _TNL_BITS_TEX_ANY) == _TNL_BIT_TEX(0))
|
||||
return GL_TRUE; /* apply ptex hack */
|
||||
else
|
||||
FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
|
||||
}
|
||||
if ((index & _TNL_BIT_TEX(1)) && VB->TexCoordPtr[1]->size == 4)
|
||||
FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
|
||||
|
||||
return GL_FALSE; /* don't apply ptex hack */
|
||||
}
|
||||
|
||||
|
||||
#define EMIT_ATTR( ATTR, STYLE, INDEX, SKIP ) \
|
||||
do { \
|
||||
@@ -724,17 +869,19 @@ do { \
|
||||
imesa->vertex_attr_count++; \
|
||||
} while (0)
|
||||
|
||||
#define SAVAGE_EMIT_XYZ 0x0001
|
||||
#define SAVAGE_EMIT_W 0x0002
|
||||
#define SAVAGE_EMIT_C0 0x0004
|
||||
#define SAVAGE_EMIT_C1 0x0008
|
||||
#define SAVAGE_EMIT_FOG 0x0010
|
||||
#define SAVAGE_EMIT_S0 0x0020
|
||||
#define SAVAGE_EMIT_T0 0x0040
|
||||
#define SAVAGE_EMIT_ST0 0x0060
|
||||
#define SAVAGE_EMIT_S1 0x0080
|
||||
#define SAVAGE_EMIT_T1 0x0100
|
||||
#define SAVAGE_EMIT_ST1 0x0180
|
||||
#define SAVAGE_EMIT_XYZ 0x0001
|
||||
#define SAVAGE_EMIT_W 0x0002
|
||||
#define SAVAGE_EMIT_C0 0x0004
|
||||
#define SAVAGE_EMIT_C1 0x0008
|
||||
#define SAVAGE_EMIT_FOG 0x0010
|
||||
#define SAVAGE_EMIT_S0 0x0020
|
||||
#define SAVAGE_EMIT_T0 0x0040
|
||||
#define SAVAGE_EMIT_Q0 0x0080
|
||||
#define SAVAGE_EMIT_ST0 0x0060
|
||||
#define SAVAGE_EMIT_STQ0 0x00e0
|
||||
#define SAVAGE_EMIT_S1 0x0100
|
||||
#define SAVAGE_EMIT_T1 0x0200
|
||||
#define SAVAGE_EMIT_ST1 0x0300
|
||||
|
||||
|
||||
static void savageRenderStart( GLcontext *ctx )
|
||||
@@ -745,10 +892,26 @@ static void savageRenderStart( GLcontext *ctx )
|
||||
GLuint index = tnl->render_inputs;
|
||||
GLuint setupIndex = SAVAGE_EMIT_XYZ;
|
||||
GLuint drawCmd = SAVAGE_HW_SKIPFLAGS;
|
||||
GLboolean ptexHack;
|
||||
if (imesa->savageScreen->chipset < S3_SAVAGE4)
|
||||
drawCmd &= ~SAVAGE_HW_NO_UV1;
|
||||
drawCmd &= ~SAVAGE_HW_NO_Z; /* all mesa vertices have a z coordinate */
|
||||
|
||||
/* Check if we need to apply the ptex hack. Choose a new render
|
||||
* state if necessary. (Note: this can't be done in
|
||||
* savageRunPipeline, since the number of vertex coordinates can
|
||||
* change in the pipeline. texmat or texgen or both?) */
|
||||
ptexHack = savageCheckPTexHack( ctx );
|
||||
if (ptexHack != imesa->ptexHack) {
|
||||
imesa->ptexHack = ptexHack;
|
||||
savageChooseRenderState (ctx);
|
||||
}
|
||||
/* Handle fallback cases identified in savageCheckPTexHack. */
|
||||
if (SAVAGE_CONTEXT(ctx)->Fallback) {
|
||||
tnl->Driver.Render.Start(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Important:
|
||||
*/
|
||||
VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
|
||||
@@ -779,21 +942,22 @@ static void savageRenderStart( GLcontext *ctx )
|
||||
}
|
||||
|
||||
if (index & _TNL_BIT_TEX(0)) {
|
||||
if (VB->TexCoordPtr[0]->size > 2) {
|
||||
/* projective textures are not supported by the hardware */
|
||||
FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
|
||||
}
|
||||
if (VB->TexCoordPtr[0]->size == 2)
|
||||
if (ptexHack)
|
||||
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_HW_NO_UV0);
|
||||
else if (VB->TexCoordPtr[0]->size == 4)
|
||||
assert (0); /* should be caught by savageCheckPTexHack */
|
||||
else if (VB->TexCoordPtr[0]->size >= 2)
|
||||
/* The chromium menu emits some 3D tex coords even though no
|
||||
* 3D texture is enabled. Ignore the 3rd coordinate. */
|
||||
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_HW_NO_UV0 );
|
||||
else
|
||||
EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_HW_NO_U0 );
|
||||
}
|
||||
if (index & _TNL_BIT_TEX(1)) {
|
||||
if (VB->TexCoordPtr[1]->size > 2) {
|
||||
/* projective textures are not supported by the hardware */
|
||||
FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
|
||||
}
|
||||
if (VB->TexCoordPtr[1]->size == 2)
|
||||
if (VB->TexCoordPtr[1]->size == 4)
|
||||
/* Projective textures are not supported by the hardware */
|
||||
assert (0); /* should be caught by savageCheckPTexHack */
|
||||
else if (VB->TexCoordPtr[1]->size >= 2)
|
||||
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, SAVAGE_EMIT_ST1, SAVAGE_HW_NO_UV1 );
|
||||
else
|
||||
EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_1F, SAVAGE_EMIT_S1, SAVAGE_HW_NO_U1 );
|
||||
@@ -811,14 +975,23 @@ static void savageRenderStart( GLcontext *ctx )
|
||||
imesa->SetupIndex = setupIndex;
|
||||
|
||||
imesa->DrawPrimitiveCmd = drawCmd;
|
||||
imesa->HwVertexSize = imesa->vertex_size;
|
||||
|
||||
if (setupIndex & SAVAGE_EMIT_Q0) {
|
||||
/* The vertex setup code emits homogenous texture
|
||||
* coordinates. They are converted to normal 2D coords by
|
||||
* savage_ptex_tri/line/point. Now we have two different
|
||||
* vertex sizes. Functions that emit vertices to the hardware
|
||||
* need to use HwVertexSize, anything that manipulates the
|
||||
* vertices generated by t_vertex uses vertex_size. */
|
||||
imesa->HwVertexSize--;
|
||||
assert (imesa->ptexHack);
|
||||
} else
|
||||
assert (!imesa->ptexHack);
|
||||
}
|
||||
|
||||
if (!SAVAGE_CONTEXT(ctx)->Fallback) {
|
||||
/* Update hardware state and get the lock */
|
||||
savageDDRenderStart( ctx );
|
||||
} else {
|
||||
tnl->Driver.Render.Start(ctx);
|
||||
}
|
||||
/* Update hardware state and get the lock */
|
||||
savageDDRenderStart( ctx );
|
||||
}
|
||||
|
||||
static void savageRenderFinish( GLcontext *ctx )
|
||||
@@ -959,7 +1132,9 @@ static GLboolean run_texnorm_stage( GLcontext *ctx,
|
||||
return GL_TRUE;
|
||||
|
||||
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
|
||||
if (!(stage->inputs & stage->changed_inputs & VERT_BIT_TEX(i)))
|
||||
if (!(stage->inputs & stage->changed_inputs & VERT_BIT_TEX(i)) ||
|
||||
VB->TexCoordPtr[i]->size == 4)
|
||||
/* Never try to normalize homogenous tex coords! */
|
||||
continue;
|
||||
|
||||
GLuint reallyEnabled = ctx->Texture.Unit[i]._ReallyEnabled;
|
||||
@@ -973,37 +1148,17 @@ static GLboolean run_texnorm_stage( GLcontext *ctx,
|
||||
GLint j;
|
||||
|
||||
if (normalizeS && normalizeT) {
|
||||
/* determine extreme values in S and T */
|
||||
GLfloat minS = in[0], maxS = in[0], minT = in[1], maxT = in[1];
|
||||
GLfloat correctionS, correctionT;
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
for (j = 1; j < VB->Count; ++j) {
|
||||
if (in[0] < minS) minS = in[0];
|
||||
else if (in[0] > maxS) maxS = in[0];
|
||||
if (in[1] < minT) minT = in[1];
|
||||
else if (in[1] > maxT) maxT = in[1];
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
}
|
||||
correctionS = -floor((minS + maxS) * 0.5 + 0.5);
|
||||
correctionT = -floor((minT + maxT) * 0.5 + 0.5);
|
||||
in = (GLfloat *)VB->TexCoordPtr[i]->data;
|
||||
/* take first texcoords as rough estimate of mean value */
|
||||
GLfloat correctionS = -floor(in[0]+0.5);
|
||||
GLfloat correctionT = -floor(in[1]+0.5);
|
||||
for (j = 0; j < VB->Count; ++j) {
|
||||
out[j][0] = in[0] + correctionS;
|
||||
out[j][1] = in[1] + correctionT;
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
}
|
||||
} else if (normalizeS) {
|
||||
/* determine extreme values in S */
|
||||
GLfloat minS = in[0], maxS = in[0];
|
||||
GLfloat correctionS;
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
for (j = 1; j < VB->Count; ++j) {
|
||||
if (in[0] < minS) minS = in[0];
|
||||
else if (in[0] > maxS) maxS = in[0];
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
}
|
||||
correctionS = -floor((minS + maxS) * 0.5 + 0.5);
|
||||
in = (GLfloat *)VB->TexCoordPtr[i]->data;
|
||||
/* take first texcoords as rough estimate of mean value */
|
||||
GLfloat correctionS = -floor(in[0]+0.5);
|
||||
if (reallyEnabled & TEXTURE_2D_BIT) {
|
||||
for (j = 0; j < VB->Count; ++j) {
|
||||
out[j][0] = in[0] + correctionS;
|
||||
@@ -1017,17 +1172,8 @@ static GLboolean run_texnorm_stage( GLcontext *ctx,
|
||||
}
|
||||
}
|
||||
} else if (normalizeT) {
|
||||
/* determine extreme values in T */
|
||||
GLfloat minT = in[1], maxT = in[1];
|
||||
GLfloat correctionT;
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
for (j = 1; j < VB->Count; ++j) {
|
||||
if (in[1] < minT) minT = in[1];
|
||||
else if (in[1] > maxT) maxT = in[1];
|
||||
in = (GLfloat *)((GLubyte *)in + instride);
|
||||
}
|
||||
correctionT = -floor((minT + maxT) * 0.5 + 0.5);
|
||||
in = (GLfloat *)VB->TexCoordPtr[i]->data;
|
||||
/* take first texcoords as rough estimate of mean value */
|
||||
GLfloat correctionT = -floor(in[1]+0.5);
|
||||
for (j = 0; j < VB->Count; ++j) {
|
||||
out[j][0] = in[0];
|
||||
out[j][1] = in[1] + correctionT;
|
||||
|
@@ -334,8 +334,7 @@ static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits,
|
||||
m->depthBits = deep
|
||||
? (depth ? 24 : 0)
|
||||
: (depth ? 0 : depth_bits);
|
||||
m->visualType = i ? GLX_TRUE_COLOR
|
||||
: GLX_DIRECT_COLOR;
|
||||
m->visualType = vis[i];
|
||||
m->renderType = GLX_RGBA_BIT;
|
||||
m->drawableType = GLX_WINDOW_BIT;
|
||||
m->rgbMode = GL_TRUE;
|
||||
|
36
src/mesa/drivers/dri/trident/Makefile
Normal file
36
src/mesa/drivers/dri/trident/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
# src/mesa/drivers/dri/trident/Makefile
|
||||
|
||||
TOP = ../../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
LIBNAME = trident_dri.so
|
||||
|
||||
# Not yet
|
||||
# MINIGLX_SOURCES = server/trident_dri.c
|
||||
|
||||
COMMON_SOURCES = \
|
||||
../../common/driverfuncs.c \
|
||||
../common/mm.c \
|
||||
../common/utils.c \
|
||||
../common/texmem.c \
|
||||
../common/vblank.c \
|
||||
../common/xmlconfig.c \
|
||||
../common/dri_util.c \
|
||||
../common/glcontextmodes.c
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
trident_context.c \
|
||||
trident_state.c \
|
||||
trident_vb.c \
|
||||
trident_dd.c \
|
||||
trident_tris.c
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
$(DRIVER_SOURCES)
|
||||
|
||||
ASM_SOURCES =
|
||||
|
||||
include ../Makefile.template
|
||||
|
||||
symlinks:
|
@@ -37,17 +37,18 @@
|
||||
|
||||
#include "context.h"
|
||||
#include "simple_list.h"
|
||||
#include "mem.h"
|
||||
#include "matrix.h"
|
||||
#include "extensions.h"
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "X86/common_x86_asm.h"
|
||||
#endif
|
||||
#include "simple_list.h"
|
||||
#include "mem.h"
|
||||
#include "mm.h"
|
||||
|
||||
static const struct gl_pipeline_stage *trident_pipeline[] = {
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
#include "dri_util.h"
|
||||
|
||||
static const struct tnl_pipeline_stage *trident_pipeline[] = {
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
@@ -58,7 +59,7 @@ static const struct gl_pipeline_stage *trident_pipeline[] = {
|
||||
};
|
||||
|
||||
|
||||
GLboolean tridentCreateContext( Display *dpy, const __GLcontextModes *glVisual,
|
||||
GLboolean tridentCreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
@@ -66,6 +67,7 @@ GLboolean tridentCreateContext( Display *dpy, const __GLcontextModes *glVisual,
|
||||
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
|
||||
tridentContextPtr tmesa;
|
||||
tridentScreenPtr tridentscrn;
|
||||
struct dd_function_table functions;
|
||||
#if 0
|
||||
drm_trident_sarea_t *saPriv=(drm_trident_sarea_t *)(((char*)sPriv->pSAREA)+
|
||||
sizeof(XF86DRISAREARec));
|
||||
@@ -80,20 +82,22 @@ GLboolean tridentCreateContext( Display *dpy, const __GLcontextModes *glVisual,
|
||||
else
|
||||
shareCtx = NULL;
|
||||
|
||||
tmesa->glCtx = _mesa_create_context(glVisual, shareCtx, tmesa, GL_TRUE);
|
||||
_mesa_init_driver_functions(&functions);
|
||||
|
||||
tmesa->glCtx =
|
||||
_mesa_create_context(glVisual, shareCtx, &functions, (void *)tmesa);
|
||||
|
||||
if (!tmesa->glCtx) {
|
||||
FREE(tmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
tmesa->display = dpy;
|
||||
|
||||
tmesa->driContext = driContextPriv;
|
||||
tmesa->driScreen = sPriv;
|
||||
tmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
|
||||
|
||||
tmesa->hHWContext = driContextPriv->hHWContext;
|
||||
tmesa->driHwLock = &sPriv->pSAREA->lock;
|
||||
tmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
|
||||
tmesa->driFd = sPriv->fd;
|
||||
#if 0
|
||||
tmesa->sarea = saPriv;
|
||||
@@ -159,11 +163,11 @@ GLboolean tridentCreateContext( Display *dpy, const __GLcontextModes *glVisual,
|
||||
tridentDDInitTriFuncs( ctx );
|
||||
tridentDDInitState( tmesa );
|
||||
|
||||
driContextPriv->driverPrivate = (void *)tmesa;
|
||||
driContextPriv->driverPrivate = (void *)tmesa;
|
||||
|
||||
UNLOCK_HARDWARE(tmesa);
|
||||
|
||||
return GL_TRUE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -181,15 +185,14 @@ tridentDestroyContext(__DRIcontextPrivate *driContextPriv)
|
||||
tmesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context(tmesa->glCtx);
|
||||
|
||||
Xfree(tmesa);
|
||||
_mesa_free(tmesa);
|
||||
driContextPriv->driverPrivate = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
tridentCreateBuffer( Display *dpy,
|
||||
__DRIscreenPrivate *driScrnPriv,
|
||||
tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap )
|
||||
@@ -217,10 +220,9 @@ tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
|
||||
}
|
||||
|
||||
static void
|
||||
tridentSwapBuffers(Display *dpy, void *drawablePrivate)
|
||||
tridentSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
|
||||
(void) dpy;
|
||||
|
||||
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
tridentContextPtr tmesa;
|
||||
@@ -228,7 +230,7 @@ tridentSwapBuffers(Display *dpy, void *drawablePrivate)
|
||||
tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
ctx = tmesa->glCtx;
|
||||
if (ctx->Visual.doubleBufferMode) {
|
||||
_mesa_swapbuffers( ctx ); /* flush pending rendering comands */
|
||||
_mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
|
||||
tridentCopyBuffer( dPriv );
|
||||
}
|
||||
}
|
||||
@@ -284,24 +286,11 @@ tridentUnbindContext( __DRIcontextPrivate *driContextPriv )
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
tridentOpenFullScreen(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
tridentCloseFullScreen(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
tridentScreenPtr tridentCreateScreen( __DRIscreenPrivate *sPriv )
|
||||
{
|
||||
TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
|
||||
tridentScreenPtr tridentScreen;
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
/* Check the DRI version */
|
||||
@@ -360,7 +349,7 @@ printf("offset 0x%x 0x%x\n",tridentScreen->backOffset,tridentScreen->depthOffset
|
||||
FREE(tridentScreen);
|
||||
return GL_FALSE;
|
||||
}
|
||||
printf("MAPPED at 0x%x\n",tridentScreen->mmio.map);
|
||||
printf("MAPPED at %p\n", tridentScreen->mmio.map);
|
||||
|
||||
return tridentScreen;
|
||||
}
|
||||
@@ -396,23 +385,49 @@ static struct __DriverAPIRec tridentAPI = {
|
||||
tridentSwapBuffers,
|
||||
tridentMakeCurrent,
|
||||
tridentUnbindContext,
|
||||
tridentOpenFullScreen,
|
||||
tridentCloseFullScreen
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the bootstrap function for the driver.
|
||||
* The __driCreateScreen name is the symbol that libGL.so fetches.
|
||||
* Return: pointer to a __DRIscreenPrivate.
|
||||
*/
|
||||
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
|
||||
int numConfigs, __GLXvisualConfig *config)
|
||||
#ifndef USE_NEW_INTERFACE
|
||||
#error trident_dri.so is new-interface only.
|
||||
#else
|
||||
|
||||
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
|
||||
|
||||
PUBLIC void *__driCreateNewScreen( __DRInativeDisplay *dpy, int scrn,
|
||||
__DRIscreen *psc,
|
||||
const __GLcontextModes * modes,
|
||||
const __DRIversion * ddx_version,
|
||||
const __DRIversion * dri_version,
|
||||
const __DRIversion * drm_version,
|
||||
const __DRIframebuffer * frame_buffer,
|
||||
drmAddress pSAREA, int fd,
|
||||
int internal_api_version,
|
||||
__GLcontextModes ** driver_modes )
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &tridentAPI);
|
||||
return (void *) psp;
|
||||
__DRIscreenPrivate *psp;
|
||||
/* XXX version checks */
|
||||
|
||||
psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
|
||||
ddx_version, dri_version, drm_version,
|
||||
frame_buffer, pSAREA, fd,
|
||||
internal_api_version, &tridentAPI);
|
||||
|
||||
if ( psp != NULL ) {
|
||||
create_context_modes = (PFNGLXCREATECONTEXTMODES)
|
||||
glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
|
||||
#if 0
|
||||
if ( create_context_modes != NULL ) {
|
||||
TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
|
||||
*driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
|
||||
GL_TRUE );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return (void *) psp;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void __driRegisterExtensions(void)
|
||||
{
|
||||
/* No extensions */
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#ifndef _TRIDENT_CONTEXT_H_
|
||||
#define _TRIDENT_CONTEXT_H_
|
||||
|
||||
#include "compiler.h"
|
||||
#include "dri_util.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
@@ -54,6 +53,23 @@
|
||||
#include "tnl_dd/t_dd_vertex.h"
|
||||
#undef TAG
|
||||
|
||||
/* these require that base be dword-aligned */
|
||||
static inline void MMIO_OUT32(unsigned char *base, unsigned int offset,
|
||||
unsigned int val)
|
||||
{
|
||||
unsigned int *addr = (unsigned int *)(base + offset);
|
||||
*addr = val;
|
||||
}
|
||||
|
||||
static inline unsigned int MMIO_IN32(unsigned char *base, unsigned int offset)
|
||||
{
|
||||
unsigned int *addr = (unsigned int *)(base + offset);
|
||||
return *addr;
|
||||
}
|
||||
|
||||
#define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val)
|
||||
#define MMIO_IN8(base, offset) *((base) + (offset))
|
||||
|
||||
struct trident_context;
|
||||
typedef struct trident_context tridentContextRec;
|
||||
typedef struct trident_context *tridentContextPtr;
|
||||
@@ -74,7 +90,7 @@ typedef void (*trident_point_func)( tridentContextPtr,
|
||||
const tridentVertex * );
|
||||
|
||||
typedef struct {
|
||||
drmHandle handle; /* Handle to the DRM region */
|
||||
drm_handle_t handle; /* Handle to the DRM region */
|
||||
drmSize size; /* Size of the DRM region */
|
||||
unsigned char *map; /* Mapping of the DRM region */
|
||||
} tridentRegionRec, *tridentRegionPtr;
|
||||
@@ -123,11 +139,9 @@ struct trident_context {
|
||||
|
||||
/* Mirrors of some DRI state
|
||||
*/
|
||||
Display *display; /* X server display */
|
||||
|
||||
int lastStamp; /* mirror driDrawable->lastStamp */
|
||||
|
||||
drmContext hHWContext;
|
||||
drm_context_t hHWContext;
|
||||
drmLock *driHwLock;
|
||||
int driFd;
|
||||
|
||||
@@ -141,10 +155,10 @@ struct trident_context {
|
||||
GLint readOffset, readPitch;
|
||||
|
||||
GLuint numClipRects; /* Cliprects for the draw buffer */
|
||||
XF86DRIClipRectPtr pClipRects;
|
||||
drm_clip_rect_t *pClipRects;
|
||||
|
||||
GLint scissor;
|
||||
XF86DRIClipRectRec ScissorRect; /* Current software scissor */
|
||||
drm_clip_rect_t ScissorRect; /* Current software scissor */
|
||||
|
||||
GLuint Fallback;
|
||||
GLuint RenderIndex;
|
||||
@@ -199,10 +213,19 @@ void tridentInitHW( tridentContextPtr tmesa );
|
||||
void tridentDDInitStateFuncs( GLcontext *ctx );
|
||||
void tridentDDInitTextureFuncs( GLcontext *ctx );
|
||||
void tridentDDInitTriFuncs( GLcontext *ctx );
|
||||
|
||||
extern void tridentBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs );
|
||||
extern void tridentInitVB( GLcontext *ctx );
|
||||
extern void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv );
|
||||
extern void tridentFallback( tridentContextPtr tmesa, GLuint bit,
|
||||
GLboolean mode );
|
||||
extern void tridentCheckTexSizes( GLcontext *ctx );
|
||||
extern void tridentChooseVertexState( GLcontext *ctx );
|
||||
extern void tridentDDUpdateHWState( GLcontext *ctx );
|
||||
extern void tridentUploadHwStateLocked( tridentContextPtr tmesa );
|
||||
|
||||
#define TRIDENT_CONTEXT(ctx) ((tridentContextPtr)(ctx->DriverCtx))
|
||||
|
||||
|
@@ -33,8 +33,7 @@
|
||||
#include "swrast/swrast.h"
|
||||
#include "context.h"
|
||||
|
||||
#define TRIDENT_DATE "20020318"
|
||||
|
||||
#define TRIDENT_DATE "20041223"
|
||||
|
||||
/* Return the width and height of the current color buffer.
|
||||
*/
|
||||
|
28
src/mesa/drivers/dri/trident/trident_dri.h
Normal file
28
src/mesa/drivers/dri/trident/trident_dri.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _TRIDENT_DRI_
|
||||
#define _TRIDENT_DRI_
|
||||
|
||||
#include "xf86drm.h"
|
||||
|
||||
typedef struct {
|
||||
drm_handle_t regs;
|
||||
drmSize regsSize;
|
||||
drmAddress regsMap;
|
||||
int deviceID;
|
||||
int width;
|
||||
int height;
|
||||
int mem;
|
||||
int frontOffset;
|
||||
int frontPitch;
|
||||
int backOffset;
|
||||
int backPitch;
|
||||
int depthOffset;
|
||||
int depthPitch;
|
||||
int cpp;
|
||||
#if 0
|
||||
int textureOffset;
|
||||
int textureSize;
|
||||
#endif
|
||||
unsigned int sarea_priv_offset;
|
||||
} TRIDENTDRIRec, *TRIDENTDRIPtr;
|
||||
|
||||
#endif
|
11
src/mesa/drivers/dri/trident/trident_lock.h
Normal file
11
src/mesa/drivers/dri/trident/trident_lock.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* XXX tridentGetLock doesn't exist... */
|
||||
|
||||
#define LOCK_HARDWARE(tmesa) \
|
||||
do { \
|
||||
char __ret = 0; \
|
||||
DRM_CAS(tmesa->driHwLock, tmesa->hHWContext, \
|
||||
DRM_LOCK_HELD | tmesa->hHWContext, __ret); \
|
||||
} while (0)
|
||||
|
||||
#define UNLOCK_HARDWARE(tmesa) \
|
||||
DRM_UNLOCK(tmesa->driFd, tmesa->driHwLock, tmesa->hHWContext)
|
@@ -26,7 +26,10 @@
|
||||
*/
|
||||
#include "trident_context.h"
|
||||
#include "trident_lock.h"
|
||||
#include "array_cache/acache.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
|
||||
#define TRIDENTPACKCOLOR332(r, g, b) \
|
||||
(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
|
||||
@@ -90,9 +93,9 @@ void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv )
|
||||
{
|
||||
unsigned char *MMIO;
|
||||
tridentContextPtr tmesa;
|
||||
GLint nbox, i, ret;
|
||||
GLint nbox, i;
|
||||
int busy;
|
||||
XF86DRIClipRectPtr pbox;
|
||||
drm_clip_rect_t *pbox;
|
||||
|
||||
assert(dPriv);
|
||||
assert(dPriv->driContextPriv);
|
||||
@@ -110,7 +113,7 @@ void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv )
|
||||
for ( i = 0 ; i < nbox ; i++ ) {
|
||||
#if 0
|
||||
GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox );
|
||||
XF86DRIClipRectPtr b = tmesa->sarea->boxes;
|
||||
drm_clip_rect_t *b = tmesa->sarea->boxes;
|
||||
GLint n = 0;
|
||||
|
||||
for ( ; i < nr ; i++ ) {
|
||||
@@ -151,11 +154,9 @@ static void tridentDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
{
|
||||
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
|
||||
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
|
||||
__DRIdrawablePrivate *dPriv = tmesa->driDrawable;
|
||||
int busy;
|
||||
GLuint flags = 0;
|
||||
GLint i;
|
||||
GLint ret;
|
||||
|
||||
#define DRM_TRIDENT_FRONT 0x01
|
||||
#define DRM_TRIDENT_BACK 0x02
|
||||
@@ -195,8 +196,8 @@ static void tridentDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
for ( i = 0 ; i < tmesa->numClipRects ; i++ ) {
|
||||
#if 0
|
||||
int nr = MIN2( i + TRIDENT_NR_SAREA_CLIPRECTS, tmesa->numClipRects );
|
||||
XF86DRIClipRectPtr box = tmesa->pClipRects;
|
||||
XF86DRIClipRectPtr b = tmesa->sarea->boxes;
|
||||
drm_clip_rect_t *box = tmesa->pClipRects;
|
||||
drm_clip_rect_t *b = tmesa->sarea->boxes;
|
||||
GLint n = 0;
|
||||
|
||||
if ( !all ) {
|
||||
@@ -363,12 +364,12 @@ void tridentSetCliprects( tridentContextPtr tmesa, GLenum mode )
|
||||
switch ( mode ) {
|
||||
case GL_FRONT_LEFT:
|
||||
if (dPriv->numClipRects == 0) {
|
||||
static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
|
||||
static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
|
||||
tmesa->numClipRects = 1;
|
||||
tmesa->pClipRects = &zeroareacliprect;
|
||||
} else {
|
||||
tmesa->numClipRects = dPriv->numClipRects;
|
||||
tmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pClipRects;
|
||||
tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
|
||||
}
|
||||
tmesa->drawX = dPriv->x;
|
||||
tmesa->drawY = dPriv->y;
|
||||
@@ -376,19 +377,19 @@ void tridentSetCliprects( tridentContextPtr tmesa, GLenum mode )
|
||||
case GL_BACK_LEFT:
|
||||
if ( dPriv->numBackClipRects == 0 ) {
|
||||
if (dPriv->numClipRects == 0) {
|
||||
static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
|
||||
static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
|
||||
tmesa->numClipRects = 1;
|
||||
tmesa->pClipRects = &zeroareacliprect;
|
||||
} else {
|
||||
tmesa->numClipRects = dPriv->numClipRects;
|
||||
tmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pClipRects;
|
||||
tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
|
||||
tmesa->drawX = dPriv->x;
|
||||
tmesa->drawY = dPriv->y;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tmesa->numClipRects = dPriv->numBackClipRects;
|
||||
tmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pBackClipRects;
|
||||
tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pBackClipRects;
|
||||
tmesa->drawX = dPriv->backX;
|
||||
tmesa->drawY = dPriv->backY;
|
||||
}
|
||||
@@ -402,6 +403,7 @@ void tridentSetCliprects( tridentContextPtr tmesa, GLenum mode )
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static GLboolean tridentDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
|
||||
{
|
||||
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
|
||||
@@ -450,7 +452,7 @@ static void tridentDDClearColor( GLcontext *ctx,
|
||||
color[0], color[1],
|
||||
color[2], color[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void tridentDDUpdateState( GLcontext *ctx, GLuint new_state )
|
||||
{
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
|
||||
static int first = 1;
|
||||
|
||||
@@ -277,7 +278,7 @@ void Init3D( tridentContextPtr tmesa )
|
||||
|
||||
int DrawTriangle( tridentContextPtr tmesa)
|
||||
{
|
||||
volatile unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
|
||||
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
|
||||
dmaBufRec clr;
|
||||
|
||||
printf("DRAW TRI\n");
|
||||
@@ -416,6 +417,7 @@ static INLINE void trident_draw_point(tridentContextPtr tmesa,
|
||||
const tridentVertex *v0 )
|
||||
{
|
||||
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
|
||||
(void) MMIO;
|
||||
}
|
||||
|
||||
static INLINE void trident_draw_line( tridentContextPtr tmesa,
|
||||
@@ -423,6 +425,7 @@ static INLINE void trident_draw_line( tridentContextPtr tmesa,
|
||||
const tridentVertex *v1 )
|
||||
{
|
||||
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
|
||||
(void) MMIO;
|
||||
}
|
||||
|
||||
static INLINE void trident_draw_triangle( tridentContextPtr tmesa,
|
||||
@@ -547,6 +550,7 @@ if (vertsize == 4) {
|
||||
* primitives are being drawn, and only for the unaccelerated
|
||||
* primitives.
|
||||
*/
|
||||
#if 0
|
||||
static void
|
||||
trident_fallback_quad( tridentContextPtr tmesa,
|
||||
const tridentVertex *v0,
|
||||
@@ -562,6 +566,11 @@ trident_fallback_quad( tridentContextPtr tmesa,
|
||||
trident_translate_vertex( ctx, v3, &v[3] );
|
||||
_swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* XXX hack to get the prototype defined in time... */
|
||||
void trident_translate_vertex(GLcontext *ctx, const tridentVertex *src,
|
||||
SWvertex *dst);
|
||||
|
||||
static void
|
||||
trident_fallback_tri( tridentContextPtr tmesa,
|
||||
@@ -649,10 +658,10 @@ do { \
|
||||
|
||||
|
||||
static struct {
|
||||
points_func points;
|
||||
line_func line;
|
||||
triangle_func triangle;
|
||||
quad_func quad;
|
||||
tnl_points_func points;
|
||||
tnl_line_func line;
|
||||
tnl_triangle_func triangle;
|
||||
tnl_quad_func quad;
|
||||
} rast_tab[TRIDENT_MAX_TRIFUNC];
|
||||
|
||||
|
||||
@@ -733,7 +742,9 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
#endif
|
||||
|
||||
static void tridentResetLineStipple( GLcontext *ctx );
|
||||
#if 0
|
||||
static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim );
|
||||
#endif
|
||||
static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim );
|
||||
|
||||
#define RASTERIZE(x) /*if (tmesa->hw_primitive != hw_prim[x]) \
|
||||
@@ -985,13 +996,14 @@ static void tridentChooseRenderState(GLcontext *ctx)
|
||||
* which renders strips as strips, the equivalent calculations are
|
||||
* performed in tridentrender.c.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim )
|
||||
{
|
||||
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
|
||||
if (tmesa->hw_primitive != hwprim)
|
||||
tmesa->hw_primitive = hwprim;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim )
|
||||
{
|
||||
@@ -1043,6 +1055,7 @@ static void tridentRenderFinish( GLcontext *ctx )
|
||||
static void tridentResetLineStipple( GLcontext *ctx )
|
||||
{
|
||||
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
|
||||
(void) tmesa;
|
||||
|
||||
/* Reset the hardware stipple counter.
|
||||
*/
|
||||
|
@@ -26,10 +26,8 @@
|
||||
*/
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "mem.h"
|
||||
#include "macros.h"
|
||||
#include "colormac.h"
|
||||
#include "mmath.h"
|
||||
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "swrast/swrast.h"
|
||||
@@ -49,8 +47,8 @@
|
||||
|
||||
static struct {
|
||||
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
|
||||
interp_func interp;
|
||||
copy_pv_func copy_pv;
|
||||
tnl_interp_func interp;
|
||||
tnl_copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)( GLcontext *ctx );
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
@@ -77,10 +75,12 @@ static struct {
|
||||
#define DO_PTEX (IND & TRIDENT_PTEX_BIT)
|
||||
|
||||
#define VERTEX tridentVertex
|
||||
#define VERTEX_COLOR trident_color_t
|
||||
#define LOCALVARS tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
|
||||
#define GET_VIEWPORT_MAT() tmesa->hw_viewport
|
||||
#define GET_TEXSOURCE(n) tmesa->tmu_source[n]
|
||||
#define GET_VERTEX_FORMAT() tmesa->vertex_format
|
||||
#define GET_VERTEX_SIZE() tmesa->vertex_size
|
||||
#define GET_VERTEX_STORE() tmesa->verts
|
||||
#define GET_VERTEX_STRIDE_SHIFT() tmesa->vertex_stride_shift
|
||||
#define GET_UBYTE_COLOR_STORE() &tmesa->UbyteColor
|
||||
@@ -310,24 +310,24 @@ void tridentBuildVertices( GLcontext *ctx,
|
||||
if (!newinputs)
|
||||
return;
|
||||
|
||||
if (newinputs & VERT_CLIP) {
|
||||
if (newinputs & VERT_BIT_POS) {
|
||||
setup_tab[tmesa->SetupIndex].emit( ctx, start, count, v, stride );
|
||||
} else {
|
||||
GLuint ind = 0;
|
||||
|
||||
if (newinputs & VERT_RGBA)
|
||||
if (newinputs & VERT_BIT_COLOR0)
|
||||
ind |= TRIDENT_RGBA_BIT;
|
||||
|
||||
if (newinputs & VERT_SPEC_RGB)
|
||||
if (newinputs & VERT_BIT_COLOR1)
|
||||
ind |= TRIDENT_SPEC_BIT;
|
||||
|
||||
if (newinputs & VERT_TEX0)
|
||||
if (newinputs & VERT_BIT_TEX0)
|
||||
ind |= TRIDENT_TEX0_BIT;
|
||||
|
||||
if (newinputs & VERT_TEX1)
|
||||
if (newinputs & VERT_BIT_TEX1)
|
||||
ind |= TRIDENT_TEX1_BIT;
|
||||
|
||||
if (newinputs & VERT_FOG_COORD)
|
||||
if (newinputs & VERT_BIT_FOG)
|
||||
ind |= TRIDENT_FOG_BIT;
|
||||
|
||||
if (tmesa->SetupIndex & TRIDENT_PTEX_BIT)
|
||||
@@ -373,10 +373,9 @@ void tridentChooseVertexState( GLcontext *ctx )
|
||||
if (ctx->Fog.Enabled)
|
||||
ind |= TRIDENT_FOG_BIT;
|
||||
|
||||
if (ctx->Texture._ReallyEnabled) {
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
ind |= TRIDENT_TEX0_BIT;
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled &&
|
||||
ctx->Texture.Unit[1]._ReallyEnabled) {
|
||||
if (ctx->Texture.Unit[1]._ReallyEnabled) {
|
||||
ind |= TRIDENT_TEX1_BIT;
|
||||
}
|
||||
}
|
||||
@@ -424,12 +423,12 @@ void tridentFreeVB( GLcontext *ctx )
|
||||
}
|
||||
|
||||
if (tmesa->UbyteSecondaryColor.Ptr) {
|
||||
ALIGN_FREE(tmesa->UbyteSecondaryColor.Ptr);
|
||||
ALIGN_FREE((void *)tmesa->UbyteSecondaryColor.Ptr);
|
||||
tmesa->UbyteSecondaryColor.Ptr = 0;
|
||||
}
|
||||
|
||||
if (tmesa->UbyteColor.Ptr) {
|
||||
ALIGN_FREE(tmesa->UbyteColor.Ptr);
|
||||
ALIGN_FREE((void *)tmesa->UbyteColor.Ptr);
|
||||
tmesa->UbyteColor.Ptr = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -40,14 +40,6 @@
|
||||
#define VIA_LOG_MIN_TEX_REGION_SIZE 16
|
||||
#endif
|
||||
|
||||
#define VIA_UPLOAD_TEX0IMAGE 0x1
|
||||
#define VIA_UPLOAD_TEX1IMAGE 0x2
|
||||
#define VIA_UPLOAD_CTX 0x4
|
||||
#define VIA_UPLOAD_BUFFERS 0x8
|
||||
#define VIA_UPLOAD_TEX0 0x10
|
||||
#define VIA_UPLOAD_TEX1 0x20
|
||||
#define VIA_UPLOAD_CLIPRECTS 0x40
|
||||
/*#define VIA_UPLOAD_ALL 0xff*/
|
||||
|
||||
/* VIA specific ioctls */
|
||||
#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t)
|
||||
|
@@ -68,45 +68,7 @@
|
||||
#ifdef DEBUG
|
||||
GLuint VIA_DEBUG = 0;
|
||||
#endif
|
||||
GLuint DRAW_FRONT = 0;
|
||||
#define DMA_SIZE 2
|
||||
GLuint VIA_PERFORMANCE = 0;
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
GLuint busy = 0;
|
||||
GLuint idle = 0;
|
||||
hash_element hash_table[HASH_TABLE_SIZE][HASH_TABLE_DEPTH];
|
||||
#endif
|
||||
/*=* John Sheng [2003.5.31] agp tex *=*/
|
||||
|
||||
static GLboolean
|
||||
AllocateBuffer(viaContextPtr vmesa)
|
||||
{
|
||||
vmesa->front_base = vmesa->driScreen->pFB;
|
||||
if (vmesa->drawType == GLX_PBUFFER_BIT) {
|
||||
if (vmesa->front.map)
|
||||
via_free_front_buffer(vmesa);
|
||||
if (!via_alloc_front_buffer(vmesa))
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (vmesa->hasBack) {
|
||||
if (vmesa->back.map)
|
||||
via_free_back_buffer(vmesa);
|
||||
if (!via_alloc_back_buffer(vmesa))
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (vmesa->hasDepth || vmesa->hasStencil) {
|
||||
if (vmesa->depth.map)
|
||||
via_free_depth_buffer(vmesa);
|
||||
if (!via_alloc_depth_buffer(vmesa)) {
|
||||
via_free_depth_buffer(vmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return various strings for \c glGetString.
|
||||
@@ -175,80 +137,92 @@ buffer_align( unsigned width )
|
||||
static GLboolean
|
||||
calculate_buffer_parameters( viaContextPtr vmesa )
|
||||
{
|
||||
const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
|
||||
const unsigned extra = (vmesa->drawType == GLX_PBUFFER_BIT) ? 0 : 32;
|
||||
unsigned w;
|
||||
unsigned h;
|
||||
const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
|
||||
const unsigned extra = 32;
|
||||
unsigned w;
|
||||
unsigned h;
|
||||
|
||||
if (vmesa->drawType == GLX_PBUFFER_BIT) {
|
||||
w = vmesa->driDrawable->w;
|
||||
h = vmesa->driDrawable->h;
|
||||
}
|
||||
else {
|
||||
w = vmesa->viaScreen->width;
|
||||
h = vmesa->viaScreen->height;
|
||||
/* Allocate front-buffer */
|
||||
if (vmesa->drawType == GLX_PBUFFER_BIT) {
|
||||
w = vmesa->driDrawable->w;
|
||||
h = vmesa->driDrawable->h;
|
||||
|
||||
vmesa->front.offset = 0;
|
||||
vmesa->front.map = (char *) vmesa->driScreen->pFB;
|
||||
}
|
||||
vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
|
||||
vmesa->front.pitch = buffer_align( w ) << shift;
|
||||
vmesa->front.size = vmesa->front.pitch * h;
|
||||
|
||||
vmesa->front.pitch = buffer_align( w ) << shift;
|
||||
vmesa->front.size = vmesa->front.pitch * h;
|
||||
if (vmesa->front.map)
|
||||
via_free_draw_buffer(vmesa, &vmesa->front);
|
||||
if (!via_alloc_draw_buffer(vmesa, &vmesa->front))
|
||||
return GL_FALSE;
|
||||
|
||||
}
|
||||
else {
|
||||
w = vmesa->viaScreen->width;
|
||||
h = vmesa->viaScreen->height;
|
||||
|
||||
vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
|
||||
vmesa->front.pitch = buffer_align( w ) << shift;
|
||||
vmesa->front.size = vmesa->front.pitch * h;
|
||||
vmesa->front.offset = 0;
|
||||
vmesa->front.map = (char *) vmesa->driScreen->pFB;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate back-buffer */
|
||||
/* Allocate back-buffer */
|
||||
if (vmesa->hasBack) {
|
||||
vmesa->back.bpp = vmesa->viaScreen->bitsPerPixel;
|
||||
vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift) + extra;
|
||||
vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h;
|
||||
if (vmesa->back.map)
|
||||
via_free_draw_buffer(vmesa, &vmesa->back);
|
||||
if (!via_alloc_draw_buffer(vmesa, &vmesa->back))
|
||||
return GL_FALSE;
|
||||
}
|
||||
else {
|
||||
/* KW: mem leak if vmesa->hasBack ever changes:
|
||||
*/
|
||||
(void) memset( &vmesa->back, 0, sizeof( vmesa->back ) );
|
||||
}
|
||||
|
||||
vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift)
|
||||
+ extra;
|
||||
vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s backbuffer: w = %d h = %d bpp = %d sizs = %d\n",
|
||||
__FUNCTION__,
|
||||
vmesa->back.pitch,
|
||||
vmesa->driDrawable->h,
|
||||
8 << shift,
|
||||
vmesa->back.size);
|
||||
/* Allocate depth-buffer */
|
||||
if ( vmesa->hasStencil || vmesa->hasDepth ) {
|
||||
vmesa->depth.bpp = vmesa->depthBits;
|
||||
if (vmesa->depth.bpp == 24)
|
||||
vmesa->depth.bpp = 32;
|
||||
|
||||
/* Allocate depth-buffer */
|
||||
if ( vmesa->hasStencil || vmesa->hasDepth ) {
|
||||
const unsigned dShift = (vmesa->hasStencil)
|
||||
? 2 : (vmesa->depthBits / 16);
|
||||
vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) * (vmesa->depth.bpp/8)) + extra;
|
||||
vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h;
|
||||
|
||||
vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) << dShift)
|
||||
+ extra;
|
||||
vmesa->depth.bpp = 8 << dShift;
|
||||
vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h;
|
||||
}
|
||||
else {
|
||||
(void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) );
|
||||
}
|
||||
if (vmesa->depth.map)
|
||||
via_free_draw_buffer(vmesa, &vmesa->depth);
|
||||
if (!via_alloc_draw_buffer(vmesa, &vmesa->depth)) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* KW: mem leak if vmesa->hasStencil/hasDepth ever changes:
|
||||
*/
|
||||
(void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) );
|
||||
}
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s depthbuffer: w = %d h = %d bpp = %d sizs = %d\n",
|
||||
__FUNCTION__,
|
||||
vmesa->depth.pitch,
|
||||
vmesa->driDrawable->h,
|
||||
vmesa->depth.bpp,
|
||||
vmesa->depth.size);
|
||||
|
||||
/*=* John Sheng [2003.5.31] flip *=*/
|
||||
if( vmesa->viaScreen->width == vmesa->driDrawable->w &&
|
||||
vmesa->viaScreen->height == vmesa->driDrawable->h ) {
|
||||
#define ALLOW_EXPERIMENTAL_PAGEFLIP 1
|
||||
/*=* John Sheng [2003.5.31] flip *=*/
|
||||
if( vmesa->viaScreen->width == vmesa->driDrawable->w &&
|
||||
vmesa->viaScreen->height == vmesa->driDrawable->h ) {
|
||||
#define ALLOW_EXPERIMENTAL_PAGEFLIP 0
|
||||
#if ALLOW_EXPERIMENTAL_PAGEFLIP
|
||||
vmesa->doPageFlip = GL_TRUE;
|
||||
vmesa->doPageFlip = GL_TRUE;
|
||||
#else
|
||||
vmesa->doPageFlip = GL_FALSE;
|
||||
vmesa->doPageFlip = GL_FALSE;
|
||||
#endif
|
||||
vmesa->currentPage = 0;
|
||||
vmesa->back.pitch = vmesa->front.pitch;
|
||||
}
|
||||
/* vmesa->currentPage = 0; */
|
||||
assert(vmesa->back.pitch == vmesa->front.pitch);
|
||||
}
|
||||
else
|
||||
vmesa->doPageFlip = GL_FALSE;
|
||||
|
||||
if (!AllocateBuffer(vmesa)) {
|
||||
FREE(vmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,20 +231,8 @@ void viaReAllocateBuffers(GLframebuffer *drawbuffer)
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
|
||||
ctx->DrawBuffer->Width = drawbuffer->Width;
|
||||
ctx->DrawBuffer->Height = drawbuffer->Height;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
ctx->DrawBuffer->Accum = 0;
|
||||
|
||||
vmesa->driDrawable->w = ctx->DrawBuffer->Width;
|
||||
vmesa->driDrawable->h = ctx->DrawBuffer->Height;
|
||||
|
||||
LOCK_HARDWARE(vmesa);
|
||||
_swrast_alloc_buffers( drawbuffer );
|
||||
calculate_buffer_parameters( vmesa );
|
||||
UNLOCK_HARDWARE(vmesa);
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
|
||||
@@ -310,10 +272,7 @@ static const struct tnl_pipeline_stage *via_pipeline[] = {
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
/* REMOVE: point attenuation stage */
|
||||
#if 1
|
||||
&_via_fastrender_stage, /* ADD: unclipped rastersetup-to-dma */
|
||||
&_via_render_stage, /* ADD: modification from _tnl_render_stage */
|
||||
#endif
|
||||
&_tnl_render_stage,
|
||||
0,
|
||||
};
|
||||
@@ -322,52 +281,28 @@ static const struct tnl_pipeline_stage *via_pipeline[] = {
|
||||
static GLboolean
|
||||
AllocateDmaBuffer(const GLvisual *visual, viaContextPtr vmesa)
|
||||
{
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
if (vmesa->dma)
|
||||
via_free_dma_buffer(vmesa);
|
||||
|
||||
if (!via_alloc_dma_buffer(vmesa)) {
|
||||
if (vmesa->front.map)
|
||||
via_free_front_buffer(vmesa);
|
||||
if (vmesa->back.map)
|
||||
via_free_back_buffer(vmesa);
|
||||
if (vmesa->depth.map)
|
||||
via_free_depth_buffer(vmesa);
|
||||
|
||||
if (!via_alloc_dma_buffer(vmesa))
|
||||
return GL_FALSE;
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
|
||||
vmesa->dmaLow = 0;
|
||||
vmesa->dmaCliprectAddr = 0;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
InitVertexBuffer(viaContextPtr vmesa)
|
||||
{
|
||||
GLuint *addr;
|
||||
|
||||
addr = (GLuint *)vmesa->dma;
|
||||
*addr = 0xF210F110;
|
||||
*addr = (HC_ParaType_NotTex << 16);
|
||||
*addr = 0xcccccccc;
|
||||
*addr = 0xdddddddd;
|
||||
|
||||
vmesa->dmaLow = DMA_OFFSET;
|
||||
vmesa->dmaHigh = VIA_DMA_BUFSIZ;
|
||||
vmesa->dmaAddr = (unsigned char *)vmesa->dma;
|
||||
vmesa->dmaLastPrim = vmesa->dmaLow;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeBuffer(viaContextPtr vmesa)
|
||||
{
|
||||
if (vmesa->front.map)
|
||||
via_free_front_buffer(vmesa);
|
||||
via_free_draw_buffer(vmesa, &vmesa->front);
|
||||
|
||||
if (vmesa->back.map)
|
||||
via_free_back_buffer(vmesa);
|
||||
via_free_draw_buffer(vmesa, &vmesa->back);
|
||||
|
||||
if (vmesa->depth.map)
|
||||
via_free_depth_buffer(vmesa);
|
||||
via_free_draw_buffer(vmesa, &vmesa->depth);
|
||||
|
||||
if (vmesa->dma)
|
||||
via_free_dma_buffer(vmesa);
|
||||
@@ -406,31 +341,55 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
sPriv->myNum, "via");
|
||||
|
||||
/* pick back buffer */
|
||||
if (mesaVis->doubleBufferMode) {
|
||||
vmesa->hasBack = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
vmesa->hasBack = GL_FALSE;
|
||||
}
|
||||
/* pick z buffer */
|
||||
if (mesaVis->haveDepthBuffer) {
|
||||
vmesa->hasDepth = GL_TRUE;
|
||||
vmesa->depthBits = mesaVis->depthBits;
|
||||
}
|
||||
else {
|
||||
vmesa->hasDepth = GL_FALSE;
|
||||
vmesa->depthBits = 0;
|
||||
}
|
||||
/* pick stencil buffer */
|
||||
if (mesaVis->haveStencilBuffer) {
|
||||
vmesa->hasStencil = GL_TRUE;
|
||||
vmesa->stencilBits = mesaVis->stencilBits;
|
||||
}
|
||||
else {
|
||||
vmesa->hasStencil = GL_FALSE;
|
||||
vmesa->stencilBits = 0;
|
||||
vmesa->hasBack = mesaVis->doubleBufferMode;
|
||||
|
||||
switch(mesaVis->depthBits) {
|
||||
case 0:
|
||||
vmesa->hasDepth = GL_FALSE;
|
||||
vmesa->depthBits = 0;
|
||||
vmesa->depth_max = 1.0;
|
||||
break;
|
||||
case 16:
|
||||
vmesa->hasDepth = GL_TRUE;
|
||||
vmesa->depthBits = mesaVis->depthBits;
|
||||
vmesa->have_hw_stencil = GL_FALSE;
|
||||
vmesa->depth_max = (GLfloat)0xffff;
|
||||
vmesa->depth_clear_mask = 0xf << 28;
|
||||
vmesa->ClearDepth = 0xffff;
|
||||
vmesa->polygon_offset_scale = 1.0 / vmesa->depth_max;
|
||||
break;
|
||||
case 24:
|
||||
vmesa->hasDepth = GL_TRUE;
|
||||
vmesa->depthBits = mesaVis->depthBits;
|
||||
vmesa->depth_max = (GLfloat) 0xffffff;
|
||||
vmesa->depth_clear_mask = 0xe << 28;
|
||||
vmesa->ClearDepth = 0xffffff00;
|
||||
|
||||
assert(mesaVis->haveStencilBuffer);
|
||||
assert(mesaVis->stencilBits == 8);
|
||||
|
||||
vmesa->have_hw_stencil = GL_TRUE;
|
||||
vmesa->stencilBits = mesaVis->stencilBits;
|
||||
vmesa->stencil_clear_mask = 0x1 << 28;
|
||||
vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
|
||||
break;
|
||||
case 32:
|
||||
vmesa->hasDepth = GL_TRUE;
|
||||
vmesa->depthBits = mesaVis->depthBits;
|
||||
assert(!mesaVis->haveStencilBuffer);
|
||||
vmesa->have_hw_stencil = GL_FALSE;
|
||||
vmesa->depth_max = (GLfloat)0xffffffff;
|
||||
vmesa->depth_clear_mask = 0;
|
||||
vmesa->ClearDepth = 0xffffffff;
|
||||
vmesa->depth_clear_mask = 0xf << 28;
|
||||
vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
_mesa_init_driver_functions(&functions);
|
||||
viaInitTextureFuncs(&functions);
|
||||
|
||||
@@ -452,33 +411,21 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
|
||||
ctx = vmesa->glCtx;
|
||||
|
||||
/* check */
|
||||
/*=* John Sheng [2003.7.2] for visual config number can't excess 8 *=*/
|
||||
/*if (viaScreen->textureSize < 2 * 1024 * 1024) {
|
||||
ctx->Const.MaxTextureLevels = 9;
|
||||
}
|
||||
else if (viaScreen->textureSize < 8 * 1024 * 1024) {
|
||||
ctx->Const.MaxTextureLevels = 10;
|
||||
}
|
||||
else {
|
||||
ctx->Const.MaxTextureLevels = 11;
|
||||
}*/
|
||||
ctx->Const.MaxTextureLevels = 11;
|
||||
|
||||
ctx->Const.MaxTextureLevels = 10;
|
||||
ctx->Const.MaxTextureUnits = 2;
|
||||
ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
|
||||
ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
|
||||
|
||||
ctx->Const.MinLineWidth = 1.0;
|
||||
ctx->Const.MinLineWidthAA = 1.0;
|
||||
ctx->Const.MaxLineWidth = 3.0;
|
||||
ctx->Const.MaxLineWidthAA = 3.0;
|
||||
ctx->Const.MaxLineWidth = 1.0;
|
||||
ctx->Const.MaxLineWidthAA = 1.0;
|
||||
ctx->Const.LineWidthGranularity = 1.0;
|
||||
|
||||
ctx->Const.MinPointSize = 1.0;
|
||||
ctx->Const.MinPointSizeAA = 1.0;
|
||||
ctx->Const.MaxPointSize = 3.0;
|
||||
ctx->Const.MaxPointSizeAA = 3.0;
|
||||
ctx->Const.MaxPointSize = 1.0;
|
||||
ctx->Const.MaxPointSizeAA = 1.0;
|
||||
ctx->Const.PointSizeGranularity = 1.0;
|
||||
|
||||
ctx->Driver.GetBufferSize = viaBufferSize;
|
||||
@@ -520,11 +467,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
vmesa->glBuffer = NULL;
|
||||
|
||||
vmesa->texHeap = mmInit(0, viaScreen->textureSize);
|
||||
vmesa->stippleInHw = 1;
|
||||
vmesa->renderIndex = ~0;
|
||||
vmesa->dirty = VIA_UPLOAD_ALL;
|
||||
vmesa->uploadCliprects = GL_TRUE;
|
||||
vmesa->needUploadAllState = 1;
|
||||
|
||||
make_empty_list(&vmesa->TexObjList);
|
||||
make_empty_list(&vmesa->SwappedOut);
|
||||
@@ -534,7 +477,16 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
|
||||
_math_matrix_ctr(&vmesa->ViewportMatrix);
|
||||
|
||||
driInitExtensions( ctx, card_extensions, GL_TRUE );
|
||||
/* Do this early, before VIA_FLUSH_DMA can be called:
|
||||
*/
|
||||
if (!AllocateDmaBuffer(mesaVis, vmesa)) {
|
||||
fprintf(stderr ,"AllocateDmaBuffer fail\n");
|
||||
FreeBuffer(vmesa);
|
||||
FREE(vmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
driInitExtensions( ctx, card_extensions, GL_TRUE );
|
||||
viaInitStateFuncs(ctx);
|
||||
viaInitTextures(ctx);
|
||||
viaInitTriFuncs(ctx);
|
||||
@@ -550,27 +502,10 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
VIA_DEBUG = 0;
|
||||
#endif
|
||||
|
||||
if (getenv("DRAW_FRONT"))
|
||||
DRAW_FRONT = 1;
|
||||
else
|
||||
DRAW_FRONT = 0;
|
||||
if (getenv("VIA_NO_RAST"))
|
||||
FALLBACK(vmesa, VIA_FALLBACK_USER_DISABLE, 1);
|
||||
|
||||
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (getenv("VIA_PERFORMANCE"))
|
||||
VIA_PERFORMANCE = 1;
|
||||
else
|
||||
VIA_PERFORMANCE = 0;
|
||||
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < HASH_TABLE_SIZE; i++) {
|
||||
for (j = 0; j < HASH_TABLE_DEPTH; j ++) {
|
||||
hash_table[i][j].count = 0;
|
||||
sprintf(hash_table[i][j].func, "%s", "NULL");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* I don't understand why this isn't working:
|
||||
*/
|
||||
@@ -587,17 +522,9 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
if ( vmesa->get_ust == NULL ) {
|
||||
vmesa->get_ust = get_ust_nop;
|
||||
}
|
||||
(*vmesa->get_ust)( & vmesa->swap_ust );
|
||||
vmesa->get_ust( &vmesa->swap_ust );
|
||||
|
||||
|
||||
if (!AllocateDmaBuffer(mesaVis, vmesa)) {
|
||||
fprintf(stderr ,"AllocateDmaBuffer fail\n");
|
||||
FREE(vmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
InitVertexBuffer(vmesa);
|
||||
|
||||
vmesa->regMMIOBase = (GLuint *)((GLuint)viaScreen->reg);
|
||||
vmesa->pnGEMode = (GLuint *)((GLuint)viaScreen->reg + 0x4);
|
||||
vmesa->regEngineStatus = (GLuint *)((GLuint)viaScreen->reg + 0x400);
|
||||
@@ -609,43 +536,6 @@ viaCreateContext(const __GLcontextModes *mesaVis,
|
||||
}
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
{
|
||||
#ifndef USE_XINERAMA
|
||||
vmesa->saam = 0;
|
||||
#else
|
||||
GLboolean saam = XineramaIsActive(vmesa->display);
|
||||
int count = 0, fbSize;
|
||||
|
||||
if (saam && vmesa->viaScreen->drixinerama) {
|
||||
vmesa->xsi = XineramaQueryScreens(vmesa->display, &count);
|
||||
/* Test RightOf or Down */
|
||||
if (vmesa->xsi[0].x_org == 0 && vmesa->xsi[0].y_org == 0) {
|
||||
if (vmesa->xsi[1].x_org == vmesa->xsi[1].width) {
|
||||
vmesa->saam = RightOf;
|
||||
}
|
||||
else {
|
||||
vmesa->saam = Down;
|
||||
}
|
||||
}
|
||||
/* Test LeftOf or Up */
|
||||
else if (vmesa->xsi[0].x_org == vmesa->xsi[0].width) {
|
||||
vmesa->saam = LeftOf;
|
||||
}
|
||||
else if (vmesa->xsi[0].y_org == vmesa->xsi[0].height) {
|
||||
vmesa->saam = Up;
|
||||
}
|
||||
else
|
||||
vmesa->saam = 0;
|
||||
|
||||
|
||||
fbSize = vmesa->viaScreen->fbSize;
|
||||
}
|
||||
else
|
||||
vmesa->saam = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
vmesa->pSaamRects = (drm_clip_rect_t *) malloc(sizeof(drm_clip_rect_t));
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -655,11 +545,10 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
|
||||
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
assert(vmesa); /* should never be null */
|
||||
/* viaFlushPrimsLocked(vmesa); */
|
||||
WAIT_IDLE
|
||||
|
||||
if (vmesa) {
|
||||
/*=* John Sheng [2003.5.31] agp tex *=*/
|
||||
WAIT_IDLE(vmesa);
|
||||
if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", vmesa->agpFullCount);
|
||||
|
||||
_swsetup_DestroyContext(vmesa->glCtx);
|
||||
@@ -674,231 +563,62 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
|
||||
FREE(vmesa);
|
||||
}
|
||||
|
||||
P_M_R;
|
||||
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) fprintf(stderr, "idle = %d\n", idle);
|
||||
if (VIA_PERFORMANCE) fprintf(stderr, "busy = %d\n", busy);
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void viaXMesaSetFrontClipRects(viaContextPtr vmesa)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
|
||||
vmesa->numClipRects = dPriv->numClipRects;
|
||||
vmesa->pClipRects = dPriv->pClipRects;
|
||||
vmesa->drawX = dPriv->x;
|
||||
vmesa->drawY = dPriv->y;
|
||||
vmesa->drawW = dPriv->w;
|
||||
vmesa->drawH = dPriv->h;
|
||||
|
||||
viaEmitDrawingRectangle(vmesa);
|
||||
vmesa->uploadCliprects = GL_TRUE;
|
||||
}
|
||||
|
||||
void viaXMesaSetBackClipRects(viaContextPtr vmesa)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
/*=* John Sheng [2003.6.9] fix glxgears dirty screen */
|
||||
/*if (vmesa->saam) {*/
|
||||
vmesa->numClipRects = dPriv->numClipRects;
|
||||
vmesa->pClipRects = dPriv->pClipRects;
|
||||
vmesa->drawX = dPriv->x;
|
||||
vmesa->drawY = dPriv->y;
|
||||
vmesa->drawW = dPriv->w;
|
||||
vmesa->drawH = dPriv->h;
|
||||
/*}
|
||||
else {
|
||||
if (dPriv->numBackClipRects == 0) {
|
||||
vmesa->numClipRects = dPriv->numClipRects;
|
||||
vmesa->pClipRects = dPriv->pClipRects;
|
||||
vmesa->drawX = dPriv->x;
|
||||
vmesa->drawY = dPriv->y;
|
||||
vmesa->drawW = dPriv->w;
|
||||
vmesa->drawH = dPriv->h;
|
||||
}
|
||||
else {
|
||||
vmesa->numClipRects = dPriv->numBackClipRects;
|
||||
vmesa->pClipRects = dPriv->pBackClipRects;
|
||||
vmesa->drawX = dPriv->backX;
|
||||
vmesa->drawY = dPriv->backY;
|
||||
vmesa->drawW = dPriv->w;
|
||||
vmesa->drawH = dPriv->h;
|
||||
}
|
||||
}*/
|
||||
viaEmitDrawingRectangle(vmesa);
|
||||
vmesa->uploadCliprects = GL_TRUE;
|
||||
}
|
||||
|
||||
void viaXMesaWindowMoved(viaContextPtr vmesa)
|
||||
{
|
||||
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
|
||||
#ifdef USE_XINERAMA
|
||||
GLuint side = 0;
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
#endif
|
||||
|
||||
switch (vmesa->glCtx->Color._DrawDestMask[0]) {
|
||||
case __GL_FRONT_BUFFER_MASK:
|
||||
viaXMesaSetFrontClipRects(vmesa);
|
||||
break;
|
||||
case __GL_BACK_BUFFER_MASK:
|
||||
viaXMesaSetBackClipRects(vmesa);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
|
||||
|
||||
#ifndef USE_XINERAMA
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam &= ~S1;
|
||||
vmesa->saam |= S0;
|
||||
#else
|
||||
side = vmesa->saam & P_MASK;
|
||||
|
||||
switch (side) {
|
||||
case RightOf:
|
||||
/* full in screen 1 */
|
||||
if (vmesa->drawX >= vmesa->xsi[0].width) {
|
||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize;
|
||||
vmesa->drawX = vmesa->drawX - vmesa->xsi[1].width;
|
||||
vmesa->numClipRects = dPriv->numBackClipRects;
|
||||
vmesa->pClipRects = dPriv->pBackClipRects;
|
||||
vmesa->drawX = dPriv->backX;
|
||||
vmesa->drawY = dPriv->backY;
|
||||
vmesa->saam &= ~S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
/* full in screen 0 */
|
||||
else if ((vmesa->drawX + vmesa->drawW) <= vmesa->xsi[0].width) {
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam &= ~S1;
|
||||
vmesa->saam |= S0;
|
||||
}
|
||||
/* between screen 0 && screen 1 */
|
||||
else {
|
||||
vmesa->numSaamRects = dPriv->numBackClipRects;
|
||||
vmesa->pSaamRects = dPriv->pBackClipRects;
|
||||
vmesa->drawXSaam = dPriv->backX;
|
||||
vmesa->drawYSaam = dPriv->backY;
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam |= S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
break;
|
||||
case LeftOf:
|
||||
/* full in screen 1 */
|
||||
if (vmesa->drawX + vmesa->drawW <= 0) {
|
||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize;
|
||||
vmesa->drawX = vmesa->drawX + vmesa->xsi[1].width;
|
||||
vmesa->numClipRects = dPriv->numBackClipRects;
|
||||
vmesa->pClipRects = dPriv->pBackClipRects;
|
||||
vmesa->drawX = dPriv->backX;
|
||||
vmesa->drawY = dPriv->backY;
|
||||
vmesa->saam &= ~S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
/* full in screen 0 */
|
||||
else if (vmesa->drawX >= 0) {
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam &= ~S1;
|
||||
vmesa->saam |= S0;
|
||||
}
|
||||
/* between screen 0 && screen 1 */
|
||||
else {
|
||||
vmesa->numSaamRects = dPriv->numBackClipRects;
|
||||
vmesa->pSaamRects = dPriv->pBackClipRects;
|
||||
vmesa->drawXSaam = dPriv->backX;
|
||||
vmesa->drawYSaam = dPriv->backY;
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam |= S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
break;
|
||||
case Down :
|
||||
/* full in screen 1 */
|
||||
if (vmesa->drawY >= vmesa->xsi[0].height) {
|
||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize;
|
||||
vmesa->drawY = vmesa->drawY - vmesa->xsi[1].height;
|
||||
vmesa->numClipRects = dPriv->numBackClipRects;
|
||||
vmesa->pClipRects = dPriv->pBackClipRects;
|
||||
vmesa->drawX = dPriv->backX;
|
||||
vmesa->drawY = dPriv->backY;
|
||||
vmesa->saam &= ~S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
/* full in screen 0 */
|
||||
else if ((vmesa->drawY + vmesa->drawH) <= vmesa->xsi[0].height) {
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam &= ~S1;
|
||||
vmesa->saam |= S0;
|
||||
}
|
||||
/* between screen 0 && screen 1 */
|
||||
else {
|
||||
vmesa->numSaamRects = dPriv->numBackClipRects;
|
||||
vmesa->pSaamRects = dPriv->pBackClipRects;
|
||||
vmesa->drawXSaam = dPriv->backX;
|
||||
vmesa->drawYSaam = dPriv->backY;
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam |= S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
break;
|
||||
case Up :
|
||||
/* full in screen 1 */
|
||||
if ((vmesa->drawY + vmesa->drawH) <= 0) {
|
||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize;
|
||||
vmesa->drawY = vmesa->drawY + vmesa->xsi[1].height;
|
||||
vmesa->numClipRects = dPriv->numBackClipRects;
|
||||
vmesa->pClipRects = dPriv->pBackClipRects;
|
||||
vmesa->drawX = dPriv->backX;
|
||||
vmesa->drawY = dPriv->backY;
|
||||
vmesa->saam &= ~S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
/* full in screen 0 */
|
||||
else if (vmesa->drawY >= 0) {
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam &= ~S1;
|
||||
vmesa->saam |= S0;
|
||||
}
|
||||
/* between screen 0 && screen 1 */
|
||||
else {
|
||||
vmesa->numSaamRects = dPriv->numBackClipRects;
|
||||
vmesa->pSaamRects = dPriv->pBackClipRects;
|
||||
vmesa->drawXSaam = dPriv->backX;
|
||||
vmesa->drawYSaam = dPriv->backY;
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
vmesa->saam |= S0;
|
||||
vmesa->saam |= S1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
vmesa->viaScreen->fbOffset = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
GLuint pitch, offset;
|
||||
pitch = vmesa->front.pitch;
|
||||
offset = vmesa->viaScreen->fbOffset + (vmesa->drawY * pitch + vmesa->drawX * bytePerPixel);
|
||||
vmesa->drawXoff = (GLuint)((offset & 0x1f) / bytePerPixel);
|
||||
if (vmesa->saam) {
|
||||
if (vmesa->pSaamRects) {
|
||||
offset = vmesa->viaScreen->fbOffset + (vmesa->pSaamRects[0].y1 * pitch +
|
||||
vmesa->pSaamRects[0].x1 * bytePerPixel);
|
||||
vmesa->drawXoffSaam = (GLuint)((offset & 0x1f) / bytePerPixel);
|
||||
}
|
||||
else
|
||||
vmesa->drawXoffSaam = 0;
|
||||
}
|
||||
else
|
||||
vmesa->drawXoffSaam = 0;
|
||||
}
|
||||
|
||||
viaCalcViewport(vmesa->glCtx);
|
||||
if (!dPriv)
|
||||
return;
|
||||
|
||||
switch (vmesa->glCtx->Color._DrawDestMask[0]) {
|
||||
case DD_FRONT_LEFT_BIT:
|
||||
if (dPriv->numBackClipRects == 0) {
|
||||
vmesa->numClipRects = dPriv->numClipRects;
|
||||
vmesa->pClipRects = dPriv->pClipRects;
|
||||
}
|
||||
else {
|
||||
vmesa->numClipRects = dPriv->numBackClipRects;
|
||||
vmesa->pClipRects = dPriv->pBackClipRects;
|
||||
}
|
||||
break;
|
||||
case DD_BACK_LEFT_BIT:
|
||||
vmesa->numClipRects = dPriv->numClipRects;
|
||||
vmesa->pClipRects = dPriv->pClipRects;
|
||||
break;
|
||||
default:
|
||||
vmesa->numClipRects = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vmesa->drawW != dPriv->w ||
|
||||
vmesa->drawH != dPriv->h)
|
||||
calculate_buffer_parameters( vmesa );
|
||||
|
||||
vmesa->drawXoff = (GLuint)(((dPriv->x * bytePerPixel) & 0x1f) / bytePerPixel);
|
||||
vmesa->drawX = dPriv->x - vmesa->drawXoff;
|
||||
vmesa->drawY = dPriv->y;
|
||||
vmesa->drawW = dPriv->w;
|
||||
vmesa->drawH = dPriv->h;
|
||||
|
||||
vmesa->front.orig = (vmesa->front.offset +
|
||||
vmesa->drawY * vmesa->front.pitch +
|
||||
vmesa->drawX * bytePerPixel);
|
||||
|
||||
vmesa->front.origMap = (vmesa->front.map +
|
||||
vmesa->drawY * vmesa->front.pitch +
|
||||
vmesa->drawX * bytePerPixel);
|
||||
|
||||
vmesa->back.orig = vmesa->back.offset;
|
||||
vmesa->depth.orig = vmesa->depth.offset;
|
||||
vmesa->back.origMap = vmesa->back.map;
|
||||
vmesa->depth.origMap = vmesa->depth.map;
|
||||
|
||||
viaCalcViewport(vmesa->glCtx);
|
||||
}
|
||||
|
||||
GLboolean
|
||||
@@ -924,6 +644,7 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
||||
|
||||
if (driContextPriv) {
|
||||
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate;
|
||||
GLcontext *ctx = vmesa->glCtx;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w);
|
||||
|
||||
@@ -933,13 +654,24 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
||||
if ( ! calculate_buffer_parameters( vmesa ) ) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
|
||||
}
|
||||
|
||||
_mesa_make_current2(vmesa->glCtx,
|
||||
(GLframebuffer *)driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *)driReadPriv->driverPrivate);
|
||||
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext);
|
||||
viaXMesaWindowMoved(vmesa);
|
||||
|
||||
/* These are probably needed only the first time a context is
|
||||
* made current:
|
||||
*/
|
||||
viaXMesaWindowMoved(vmesa);
|
||||
ctx->Driver.Scissor(ctx,
|
||||
ctx->Scissor.X,
|
||||
ctx->Scissor.Y,
|
||||
ctx->Scissor.Width,
|
||||
ctx->Scissor.Height);
|
||||
|
||||
}
|
||||
else {
|
||||
_mesa_make_current(0,0);
|
||||
@@ -953,86 +685,29 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
__DRIscreenPrivate *sPriv = vmesa->driScreen;
|
||||
drm_via_sarea_t *sarea = vmesa->sarea;
|
||||
int me = vmesa->hHWContext;
|
||||
__DRIdrawablePrivate *pdp;
|
||||
__DRIscreenPrivate *psp;
|
||||
pdp = dPriv;
|
||||
psp = sPriv;
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
fprintf(stderr, "is: %x non-contend: %x want: %x\n",
|
||||
*(GLuint *)vmesa->driHwLock, vmesa->hHWContext,
|
||||
(DRM_LOCK_HELD|vmesa->hHWContext));
|
||||
}
|
||||
|
||||
drmGetLock(vmesa->driFd, vmesa->hHWContext, flags);
|
||||
|
||||
DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
|
||||
|
||||
if (sarea->ctxOwner != me) {
|
||||
vmesa->uploadCliprects = GL_TRUE;
|
||||
sarea->ctxOwner = me;
|
||||
vmesa->needUploadAllState = 1;
|
||||
if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
|
||||
vmesa->sarea->ctxOwner = vmesa->hHWContext;
|
||||
vmesa->newEmitState = ~0;
|
||||
}
|
||||
|
||||
viaXMesaWindowMoved(vmesa);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void viaLock(viaContextPtr vmesa, GLuint flags)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable;
|
||||
__DRIscreenPrivate *sPriv = vmesa->driScreen;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
|
||||
/*=* John Sheng [2003.6.16] for xf43 */
|
||||
if(dPriv->pStamp == NULL)
|
||||
dPriv->pStamp = &dPriv->lastStamp;
|
||||
|
||||
if (*(dPriv->pStamp) != dPriv->lastStamp || vmesa->saam) {
|
||||
GLuint scrn;
|
||||
scrn = vmesa->saam & S_MASK;
|
||||
|
||||
DRM_SPINLOCK(&sPriv->pSAREA->drawable_lock, sPriv->drawLockID);
|
||||
|
||||
if (scrn == S1)
|
||||
__driUtilUpdateDrawableInfo(dPriv);
|
||||
else
|
||||
DRI_VALIDATE_DRAWABLE_INFO_ONCE(dPriv);
|
||||
|
||||
viaXMesaWindowMoved(vmesa);
|
||||
DRM_SPINUNLOCK(&sPriv->pSAREA->drawable_lock, sPriv->drawLockID);
|
||||
if (vmesa->lastStamp != dPriv->lastStamp) {
|
||||
viaXMesaWindowMoved(vmesa);
|
||||
vmesa->lastStamp = dPriv->lastStamp;
|
||||
}
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void viaUnLock(viaContextPtr vmesa, GLuint flags)
|
||||
{
|
||||
drm_via_sarea_t *sarea = vmesa->sarea;
|
||||
int me = vmesa->hHWContext;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
if (VIA_DEBUG) fprintf(stderr, "sarea->ctxOwner = %d\n", sarea->ctxOwner);
|
||||
if (VIA_DEBUG) fprintf(stderr, "me = %d\n", me);
|
||||
if (sarea->ctxOwner == me) {
|
||||
sarea->ctxOwner = 0;
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void
|
||||
viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *)drawablePrivate;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
if (dPriv && dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
viaContextPtr vmesa;
|
||||
GLcontext *ctx;
|
||||
|
||||
@@ -1048,7 +723,7 @@ viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
|
||||
}
|
||||
}
|
||||
else
|
||||
VIA_FIREVERTICES(vmesa);
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
}
|
||||
else {
|
||||
_mesa_problem(NULL, "viaSwapBuffers: drawable has no context!\n");
|
||||
|
@@ -40,9 +40,6 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
|
||||
#include "via_tex.h"
|
||||
#include "via_common.h"
|
||||
#include "xf86drmVIA.h"
|
||||
#ifdef USE_XINERAMA
|
||||
#include "../../../../../include/extensions/Xinerama.h"
|
||||
#endif
|
||||
#define VIA_FALLBACK_TEXTURE 0x1
|
||||
#define VIA_FALLBACK_DRAW_BUFFER 0x2
|
||||
#define VIA_FALLBACK_READ_BUFFER 0x4
|
||||
@@ -53,24 +50,13 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
|
||||
#define VIA_FALLBACK_STENCIL 0x100
|
||||
#define VIA_FALLBACK_BLEND_EQ 0x200
|
||||
#define VIA_FALLBACK_BLEND_FUNC 0x400
|
||||
#define VIA_FALLBACK_USER_DISABLE 0x800
|
||||
|
||||
#define VIA_DMA_BUFSIZ 5000
|
||||
#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 256)
|
||||
|
||||
#define VIA_NO_CLIPRECTS 0x1
|
||||
|
||||
#define VIA_UPLOAD_NONE 0x0000
|
||||
#define VIA_UPLOAD_ALPHATEST 0x0001
|
||||
#define VIA_UPLOAD_BLEND 0x0002
|
||||
#define VIA_UPLOAD_FOG 0x0004
|
||||
#define VIA_UPLOAD_MASK_ROP 0x0008
|
||||
#define VIA_UPLOAD_LINESTIPPLE 0x0010
|
||||
#define VIA_UPLOAD_POLYGONSTIPPLE 0x0020
|
||||
#define VIA_UPLOAD_DEPTH 0x0040
|
||||
#define VIA_UPLOAD_TEXTURE 0x0080
|
||||
#define VIA_UPLOAD_STENCIL 0x0100
|
||||
#define VIA_UPLOAD_CLIPPING 0x0200
|
||||
#define VIA_UPLOAD_DESTBUFFER 0x0400
|
||||
#define VIA_UPLOAD_DEPTHBUFFER 0x0800
|
||||
#define VIA_UPLOAD_ENABLE 0x0800
|
||||
#define VIA_UPLOAD_ALL 0x1000
|
||||
|
||||
#define VIA_DMA_BUFSIZ 500000
|
||||
|
||||
/* Use the templated vertex formats:
|
||||
*/
|
||||
@@ -78,14 +64,6 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
|
||||
#include "tnl_dd/t_dd_vertex.h"
|
||||
#undef TAG
|
||||
|
||||
#define RightOf 1
|
||||
#define LeftOf 2
|
||||
#define Down 4
|
||||
#define Up 8
|
||||
#define S0 16
|
||||
#define S1 32
|
||||
#define P_MASK 0x0f;
|
||||
#define S_MASK 0x30;
|
||||
typedef void (*via_tri_func)(viaContextPtr, viaVertex *, viaVertex *,
|
||||
viaVertex *);
|
||||
typedef void (*via_line_func)(viaContextPtr, viaVertex *, viaVertex *);
|
||||
@@ -99,6 +77,10 @@ typedef struct {
|
||||
GLuint pitch;
|
||||
GLuint bpp;
|
||||
char *map;
|
||||
GLuint orig; /* The drawing origin,
|
||||
* at (drawX,drawY) in screen space.
|
||||
*/
|
||||
char *origMap;
|
||||
} viaBuffer, *viaBufferPtr;
|
||||
|
||||
|
||||
@@ -106,7 +88,6 @@ struct via_context_t {
|
||||
GLint refcount;
|
||||
GLcontext *glCtx;
|
||||
GLcontext *shareCtx;
|
||||
unsigned char* front_base;
|
||||
viaBuffer front;
|
||||
viaBuffer back;
|
||||
viaBuffer depth;
|
||||
@@ -116,7 +97,15 @@ struct via_context_t {
|
||||
GLboolean hasAccum;
|
||||
GLuint depthBits;
|
||||
GLuint stencilBits;
|
||||
GLuint *dma;
|
||||
|
||||
GLboolean have_hw_stencil;
|
||||
GLuint ClearDepth;
|
||||
GLuint depth_clear_mask;
|
||||
GLuint stencil_clear_mask;
|
||||
GLfloat depth_max;
|
||||
GLfloat polygon_offset_scale;
|
||||
|
||||
GLubyte *dma;
|
||||
viaRegion tex;
|
||||
|
||||
GLuint isAGP;
|
||||
@@ -132,36 +121,25 @@ struct via_context_t {
|
||||
*/
|
||||
GLuint Fallback;
|
||||
|
||||
/* Temporaries for translating away float colors:
|
||||
*/
|
||||
struct gl_client_array UbyteColor;
|
||||
struct gl_client_array UbyteSecondaryColor;
|
||||
|
||||
/* State for via_vb.c and via_tris.c.
|
||||
*/
|
||||
GLuint newState; /* _NEW_* flags */
|
||||
GLuint newEmitState; /* _NEW_* flags */
|
||||
GLuint setupNewInputs;
|
||||
GLuint setupIndex;
|
||||
GLuint renderIndex;
|
||||
GLmatrix ViewportMatrix;
|
||||
GLenum renderPrimitive;
|
||||
GLenum reducedPrimitive;
|
||||
GLuint hwPrimitive;
|
||||
GLenum hwPrimitive;
|
||||
unsigned char *verts;
|
||||
|
||||
/* drmBufPtr dma_buffer;
|
||||
*/
|
||||
unsigned char* dmaAddr;
|
||||
GLuint dmaLow;
|
||||
GLuint dmaHigh;
|
||||
GLuint dmaCliprectAddr;
|
||||
GLuint dmaLastPrim;
|
||||
GLboolean useAgp;
|
||||
|
||||
GLboolean uploadCliprects;
|
||||
|
||||
GLuint needUploadAllState;
|
||||
GLuint primitiveRendered;
|
||||
|
||||
|
||||
/* Fallback rasterization functions
|
||||
*/
|
||||
@@ -230,12 +208,13 @@ struct via_context_t {
|
||||
*/
|
||||
GLuint dirty;
|
||||
int vertexSize;
|
||||
int vertexStrideShift;
|
||||
int vertexFormat;
|
||||
GLint lastStamp;
|
||||
GLboolean stippleInHw;
|
||||
|
||||
GLenum TexEnvImageFmt[2];
|
||||
GLuint ClearColor;
|
||||
GLuint ClearMask;
|
||||
|
||||
/* DRI stuff
|
||||
*/
|
||||
GLuint needClip;
|
||||
@@ -243,25 +222,15 @@ struct via_context_t {
|
||||
GLboolean doPageFlip;
|
||||
/*=* John Sheng [2003.5.31] flip *=*/
|
||||
GLuint currentPage;
|
||||
char *drawMap; /* draw buffer address in virtual mem */
|
||||
char *readMap;
|
||||
|
||||
viaBuffer *drawBuffer;
|
||||
viaBuffer *readBuffer;
|
||||
int drawX; /* origin of drawable in draw buffer */
|
||||
int drawY;
|
||||
|
||||
int drawW;
|
||||
int drawH;
|
||||
GLuint saam;
|
||||
#ifdef USE_XINERAMA
|
||||
XineramaScreenInfo *xsi;
|
||||
#endif
|
||||
int drawXoffSaam;
|
||||
drm_clip_rect_t *pSaamRects;
|
||||
int drawXSaam;
|
||||
int drawYSaam;
|
||||
GLuint numSaamRects;
|
||||
|
||||
int drawPitch;
|
||||
int readPitch;
|
||||
int drawXoff;
|
||||
GLuint numClipRects; /* cliprects for that buffer */
|
||||
drm_clip_rect_t *pClipRects;
|
||||
@@ -311,72 +280,8 @@ struct via_context_t {
|
||||
PFNGLXGETUSTPROC get_ust;
|
||||
|
||||
};
|
||||
/*#define DMA_OFFSET 16*/
|
||||
#define DMA_OFFSET 32
|
||||
/*#define PERFORMANCE_MEASURE*/
|
||||
|
||||
extern GLuint VIA_PERFORMANCE;
|
||||
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
#define HASH_TABLE_SIZE 1000
|
||||
#define HASH_TABLE_DEPTH 10
|
||||
typedef struct {
|
||||
char func[50];
|
||||
GLuint count;
|
||||
} hash_element;
|
||||
extern hash_element hash_table[HASH_TABLE_SIZE][HASH_TABLE_DEPTH];
|
||||
#define P_M \
|
||||
do { \
|
||||
GLuint h_index,h_depth; \
|
||||
h_index = (GLuint)(((GLuint) __FUNCTION__)%HASH_TABLE_SIZE); \
|
||||
for (h_depth = 0; h_depth < HASH_TABLE_DEPTH; h_depth++) { \
|
||||
if (!strcmp(hash_table[h_index][h_depth].func, "NULL")) { \
|
||||
sprintf(hash_table[h_index][h_depth].func, "%s", __FUNCTION__); \
|
||||
hash_table[h_index][h_depth].count++; \
|
||||
break; \
|
||||
} \
|
||||
else if (!strcmp(hash_table[h_index][h_depth].func, __FUNCTION__)) { \
|
||||
hash_table[h_index][h_depth].count++; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define P_M_X \
|
||||
do { \
|
||||
GLuint h_index,h_depth; \
|
||||
char str[80]; \
|
||||
strcpy(str, __FUNCTION__); \
|
||||
h_index = (GLuint)(((GLuint) __FUNCTION__)%HASH_TABLE_SIZE); \
|
||||
for (h_depth = 0; h_depth < HASH_TABLE_DEPTH; h_depth++) { \
|
||||
if (!strcmp(hash_table[h_index][h_depth].func, "NULL")) { \
|
||||
sprintf(hash_table[h_index][h_depth].func, "%s_X", __FUNCTION__); \
|
||||
hash_table[h_index][h_depth].count++; \
|
||||
break; \
|
||||
} \
|
||||
else if (!strcmp(hash_table[h_index][h_depth].func, strcat(str, "_X"))) { \
|
||||
hash_table[h_index][h_depth].count++; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define P_M_R \
|
||||
do { \
|
||||
GLuint h_size, h_depth; \
|
||||
for (h_size = 0; h_size < HASH_TABLE_SIZE; h_size++) { \
|
||||
for (h_depth = 0; h_depth < HASH_TABLE_DEPTH; h_depth++) { \
|
||||
if (hash_table[h_size][h_depth].count) { \
|
||||
fprintf(stderr, "func:%s count:%d\n", hash_table[h_size][h_depth].func, hash_table[h_size][h_depth].count); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#else /* PERFORMANCE_MEASURE */
|
||||
#define P_M {}
|
||||
#define P_M_X {}
|
||||
#define P_M_R {}
|
||||
#endif
|
||||
|
||||
#define VIA_CONTEXT(ctx) ((viaContextPtr)(ctx->DriverCtx))
|
||||
|
||||
@@ -386,65 +291,27 @@ extern hash_element hash_table[HASH_TABLE_SIZE][HASH_TABLE_DEPTH];
|
||||
|
||||
/* Lock the hardware and validate our state.
|
||||
*/
|
||||
/*
|
||||
#define LOCK_HARDWARE(vmesa) \
|
||||
do { \
|
||||
char __ret = 0; \
|
||||
DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \
|
||||
(DRM_LOCK_HELD|vmesa->hHWContext), __ret); \
|
||||
if (__ret) \
|
||||
viaGetLock(vmesa, 0); \
|
||||
} while (0)
|
||||
*/
|
||||
/*=* John Sheng [2003.6.20] fix pci *=*/
|
||||
/*=* John Sheng [2003.7.25] fix viewperf black shadow *=*/
|
||||
#define LOCK_HARDWARE(vmesa) \
|
||||
if(1) \
|
||||
do { \
|
||||
char __ret = 0; \
|
||||
DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \
|
||||
(DRM_LOCK_HELD|vmesa->hHWContext), __ret); \
|
||||
if (__ret) \
|
||||
viaGetLock(vmesa, 0); \
|
||||
} while (0); \
|
||||
else \
|
||||
viaLock(vmesa, 0)
|
||||
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
#define LOCK_HARDWARE(vmesa) \
|
||||
viaLock(vmesa, 0);
|
||||
*/
|
||||
|
||||
/* Release the kernel lock.
|
||||
*/
|
||||
/*
|
||||
#define UNLOCK_HARDWARE(vmesa) \
|
||||
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext);
|
||||
*/
|
||||
/*=* John Sheng [2003.6.20] fix pci *=*/
|
||||
/*=* John Sheng [2003.7.25] fix viewperf black shadow *=*/
|
||||
#define UNLOCK_HARDWARE(vmesa) \
|
||||
if(1) \
|
||||
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); \
|
||||
else \
|
||||
viaUnLock(vmesa, 0);
|
||||
/*
|
||||
#define UNLOCK_HARDWARE(vmesa) \
|
||||
viaUnLock(vmesa, 0);
|
||||
*/
|
||||
#define WAIT_IDLE \
|
||||
while (1) { \
|
||||
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext);
|
||||
|
||||
#define WAIT_IDLE(vmesa) \
|
||||
do { \
|
||||
if ((((GLuint)*vmesa->regEngineStatus) & 0xFFFEFFFF) == 0x00020000) \
|
||||
break; \
|
||||
}
|
||||
} while (1)
|
||||
|
||||
#define LOCK_HARDWARE_QUIESCENT(vmesa) \
|
||||
do { \
|
||||
LOCK_HARDWARE(vmesa); \
|
||||
viaRegetLockQuiescent(vmesa); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
extern GLuint VIA_DEBUG;
|
||||
@@ -453,13 +320,11 @@ extern GLuint VIA_DEBUG;
|
||||
#endif
|
||||
|
||||
|
||||
extern GLuint DRAW_FRONT;
|
||||
extern void viaGetLock(viaContextPtr vmesa, GLuint flags);
|
||||
extern void viaLock(viaContextPtr vmesa, GLuint flags);
|
||||
extern void viaUnLock(viaContextPtr vmesa, GLuint flags);
|
||||
extern void viaEmitHwStateLocked(viaContextPtr vmesa);
|
||||
extern void viaEmitScissorValues(viaContextPtr vmesa, int box_nr, int emit);
|
||||
extern void viaEmitDrawingRectangle(viaContextPtr vmesa);
|
||||
extern void viaXMesaSetBackClipRects(viaContextPtr vmesa);
|
||||
extern void viaXMesaSetFrontClipRects(viaContextPtr vmesa);
|
||||
extern void viaReAllocateBuffers(GLframebuffer *drawbuffer);
|
||||
@@ -468,8 +333,10 @@ extern void viaXMesaWindowMoved(viaContextPtr vmesa);
|
||||
extern void viaTexCombineState(viaContextPtr vmesa,
|
||||
const struct gl_tex_env_combine_state * combine, unsigned unit );
|
||||
|
||||
#define SUBPIXEL_X -.5
|
||||
#define SUBPIXEL_Y -.5
|
||||
/* Via hw already adjusted for GL pixel centers:
|
||||
*/
|
||||
#define SUBPIXEL_X 0
|
||||
#define SUBPIXEL_Y 0
|
||||
|
||||
/* TODO XXX _SOLO temp defines to make code compilable */
|
||||
#ifndef GLX_PBUFFER_BIT
|
||||
|
@@ -1,720 +0,0 @@
|
||||
/*
|
||||
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* 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, 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
|
||||
* VIA, S3 GRAPHICS, 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.
|
||||
*/
|
||||
|
||||
#if HAVE_RGBA
|
||||
#define VERT_SET_IND(v, c) (void)c
|
||||
#define VERT_COPY_IND(v0, v1)
|
||||
#define VERT_SAVE_IND(idx)
|
||||
#define VERT_RESTORE_IND(idx)
|
||||
#if HAVE_BACK_COLORS
|
||||
#define VERT_SET_RGBA(v, c)
|
||||
#endif
|
||||
#else
|
||||
#define VERT_SET_RGBA(v, c) (void)c
|
||||
#define VERT_COPY_RGBA(v0, v1)
|
||||
#define VERT_SAVE_RGBA(idx)
|
||||
#define VERT_RESTORE_RGBA(idx)
|
||||
#if HAVE_BACK_COLORS
|
||||
#define VERT_SET_IND(v, c)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_SPEC
|
||||
#define VERT_SET_SPEC(v, c) (void)c
|
||||
#define VERT_COPY_SPEC(v0, v1)
|
||||
#define VERT_SAVE_SPEC(idx)
|
||||
#define VERT_RESTORE_SPEC(idx)
|
||||
#if HAVE_BACK_COLORS
|
||||
#define VERT_COPY_SPEC1(v)
|
||||
#endif
|
||||
#else
|
||||
#if HAVE_BACK_COLORS
|
||||
#define VERT_SET_SPEC(v, c)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_BACK_COLORS
|
||||
#define VERT_COPY_SPEC1(v)
|
||||
#define VERT_COPY_IND1(v)
|
||||
#define VERT_COPY_RGBA1(v)
|
||||
#endif
|
||||
|
||||
#ifndef INSANE_VERTICES
|
||||
#define VERT_SET_Z(v, val) VERT_Z(v) = val
|
||||
#define VERT_Z_ADD(v, val) VERT_Z(v) += val
|
||||
#endif
|
||||
|
||||
#if DO_TRI
|
||||
static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2)
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
VERTEX *v[3];
|
||||
GLfloat offset;
|
||||
GLfloat z[3];
|
||||
GLenum mode = GL_FILL;
|
||||
GLuint facing;
|
||||
LOCAL_VARS(3);
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
|
||||
v[0] = (VERTEX *)GET_VERTEX(e0);
|
||||
v[1] = (VERTEX *)GET_VERTEX(e1);
|
||||
v[2] = (VERTEX *)GET_VERTEX(e2);
|
||||
|
||||
if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED) {
|
||||
GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]);
|
||||
GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]);
|
||||
GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]);
|
||||
GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]);
|
||||
GLfloat cc = ex * fy - ey * fx;
|
||||
|
||||
if (DO_TWOSIDE || DO_UNFILLED) {
|
||||
facing = AREA_IS_CCW(cc) ^ ctx->Polygon._FrontBit;
|
||||
|
||||
if (DO_UNFILLED) {
|
||||
if (facing) {
|
||||
mode = ctx->Polygon.BackMode;
|
||||
if (ctx->Polygon.CullFlag &&
|
||||
ctx->Polygon.CullFaceMode != GL_FRONT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mode = ctx->Polygon.FrontMode;
|
||||
if (ctx->Polygon.CullFlag &&
|
||||
ctx->Polygon.CullFaceMode != GL_BACK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DO_TWOSIDE && facing == 1) {
|
||||
if (HAVE_RGBA) {
|
||||
if (HAVE_BACK_COLORS) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_RGBA(0);
|
||||
VERT_SAVE_RGBA(1);
|
||||
VERT_COPY_RGBA1(v[0]);
|
||||
VERT_COPY_RGBA1(v[1]);
|
||||
}
|
||||
VERT_SAVE_RGBA(2);
|
||||
VERT_COPY_RGBA1(v[2]);
|
||||
if (HAVE_SPEC) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_SAVE_SPEC(1);
|
||||
VERT_COPY_SPEC1(v[0]);
|
||||
VERT_COPY_SPEC1(v[1]);
|
||||
}
|
||||
VERT_SAVE_SPEC(2);
|
||||
VERT_COPY_SPEC1(v[2]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
|
||||
ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLfloat));
|
||||
(void)vbcolor;
|
||||
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_RGBA(0);
|
||||
VERT_SAVE_RGBA(1);
|
||||
VERT_SET_RGBA(v[0], vbcolor[e0]);
|
||||
VERT_SET_RGBA(v[1], vbcolor[e1]);
|
||||
}
|
||||
VERT_SAVE_RGBA(2);
|
||||
VERT_SET_RGBA(v[2], vbcolor[e2]);
|
||||
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
|
||||
GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
|
||||
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_SAVE_SPEC(1);
|
||||
VERT_SET_SPEC(v[0], vbspec[e0]);
|
||||
VERT_SET_SPEC(v[1], vbspec[e1]);
|
||||
}
|
||||
VERT_SAVE_SPEC(2);
|
||||
VERT_SET_SPEC(v[2], vbspec[e2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
GLfloat *vbindex = (GLfloat*) VB->IndexPtr[1]->data;
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_IND( 0 );
|
||||
VERT_SAVE_IND( 1 );
|
||||
VERT_SET_IND(v[0], vbindex[e0]);
|
||||
VERT_SET_IND(v[1], vbindex[e1]);
|
||||
}
|
||||
VERT_SAVE_IND( 2 );
|
||||
VERT_SET_IND(v[2], vbindex[e2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DO_OFFSET) {
|
||||
offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
|
||||
z[0] = VERT_Z(v[0]);
|
||||
z[1] = VERT_Z(v[1]);
|
||||
z[2] = VERT_Z(v[2]);
|
||||
if (cc * cc > 1e-16) {
|
||||
GLfloat ic = 1.0 / cc;
|
||||
GLfloat ez = z[0] - z[2];
|
||||
GLfloat fz = z[1] - z[2];
|
||||
GLfloat a = ey * fz - ez * fy;
|
||||
GLfloat b = ez * fx - ex * fz;
|
||||
GLfloat ac = a * ic;
|
||||
GLfloat bc = b * ic;
|
||||
if (ac < 0.0f) ac = -ac;
|
||||
if (bc < 0.0f) bc = -bc;
|
||||
offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
|
||||
}
|
||||
offset *= ctx->MRD;
|
||||
}
|
||||
}
|
||||
|
||||
if (DO_FLAT) {
|
||||
if (HAVE_RGBA) {
|
||||
VERT_SAVE_RGBA(0);
|
||||
VERT_SAVE_RGBA(1);
|
||||
VERT_COPY_RGBA(v[0], v[2]);
|
||||
VERT_COPY_RGBA(v[1], v[2]);
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_SAVE_SPEC(1);
|
||||
VERT_COPY_SPEC(v[0], v[2]);
|
||||
VERT_COPY_SPEC(v[1], v[2]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VERT_SAVE_IND(0);
|
||||
VERT_SAVE_IND(1);
|
||||
VERT_COPY_IND(v[0], v[2]);
|
||||
VERT_COPY_IND(v[1], v[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == GL_POINT) {
|
||||
if (DO_OFFSET && ctx->Polygon.OffsetPoint) {
|
||||
VERT_Z_ADD(v[0], offset);
|
||||
VERT_Z_ADD(v[1], offset);
|
||||
VERT_Z_ADD(v[2], offset);
|
||||
}
|
||||
UNFILLED_TRI(ctx, GL_POINT, e0, e1, e2);
|
||||
}
|
||||
else if (mode == GL_LINE) {
|
||||
if (DO_OFFSET && ctx->Polygon.OffsetLine) {
|
||||
VERT_Z_ADD(v[0], offset);
|
||||
VERT_Z_ADD(v[1], offset);
|
||||
VERT_Z_ADD(v[2], offset);
|
||||
}
|
||||
UNFILLED_TRI(ctx, GL_LINE, e0, e1, e2);
|
||||
}
|
||||
else {
|
||||
if (DO_OFFSET && ctx->Polygon.OffsetFill) {
|
||||
VERT_Z_ADD(v[0], offset);
|
||||
VERT_Z_ADD(v[1], offset);
|
||||
VERT_Z_ADD(v[2], offset);
|
||||
}
|
||||
if (DO_UNFILLED)
|
||||
RASTERIZE(GL_TRIANGLES);
|
||||
TRI(v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
if (DO_OFFSET) {
|
||||
VERT_SET_Z(v[0], z[0]);
|
||||
VERT_SET_Z(v[1], z[1]);
|
||||
VERT_SET_Z(v[2], z[2]);
|
||||
}
|
||||
|
||||
if (DO_TWOSIDE && facing == 1) {
|
||||
if (HAVE_RGBA) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_RESTORE_RGBA(0);
|
||||
VERT_RESTORE_RGBA(1);
|
||||
}
|
||||
VERT_RESTORE_RGBA(2);
|
||||
if (HAVE_SPEC) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_RESTORE_SPEC(0);
|
||||
VERT_RESTORE_SPEC(1);
|
||||
}
|
||||
VERT_RESTORE_SPEC(2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!DO_FLAT) {
|
||||
VERT_RESTORE_IND( 0 );
|
||||
VERT_RESTORE_IND( 1 );
|
||||
}
|
||||
VERT_RESTORE_IND( 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (DO_FLAT) {
|
||||
if (HAVE_RGBA) {
|
||||
VERT_RESTORE_RGBA(0);
|
||||
VERT_RESTORE_RGBA(1);
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
|
||||
VERT_RESTORE_SPEC(0);
|
||||
VERT_RESTORE_SPEC(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VERT_RESTORE_IND(0);
|
||||
VERT_RESTORE_IND(1);
|
||||
}
|
||||
}
|
||||
SET_PRIMITIVE_RENDERED
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DO_QUAD
|
||||
#if DO_FULL_QUAD
|
||||
static void TAG(quad)(GLcontext *ctx,
|
||||
GLuint e0, GLuint e1, GLuint e2, GLuint e3)
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
|
||||
VERTEX *v[4];
|
||||
GLfloat offset;
|
||||
GLfloat z[4];
|
||||
GLenum mode = GL_FILL;
|
||||
GLuint facing;
|
||||
LOCAL_VARS(4);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
v[0] = (VERTEX *)GET_VERTEX(e0);
|
||||
v[1] = (VERTEX *)GET_VERTEX(e1);
|
||||
v[2] = (VERTEX *)GET_VERTEX(e2);
|
||||
v[3] = (VERTEX *)GET_VERTEX(e3);
|
||||
|
||||
if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED) {
|
||||
GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]);
|
||||
GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]);
|
||||
GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]);
|
||||
GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]);
|
||||
GLfloat cc = ex * fy - ey * fx;
|
||||
|
||||
if (DO_TWOSIDE || DO_UNFILLED) {
|
||||
facing = AREA_IS_CCW(cc) ^ ctx->Polygon._FrontBit;
|
||||
|
||||
if (DO_UNFILLED) {
|
||||
if (facing) {
|
||||
mode = ctx->Polygon.BackMode;
|
||||
if (ctx->Polygon.CullFlag &&
|
||||
ctx->Polygon.CullFaceMode != GL_FRONT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mode = ctx->Polygon.FrontMode;
|
||||
if (ctx->Polygon.CullFlag &&
|
||||
ctx->Polygon.CullFaceMode != GL_BACK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DO_TWOSIDE && facing == 1) {
|
||||
if (HAVE_RGBA) {
|
||||
GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
|
||||
(void)vbcolor;
|
||||
|
||||
if (HAVE_BACK_COLORS) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_RGBA(0);
|
||||
VERT_SAVE_RGBA(1);
|
||||
VERT_SAVE_RGBA(2);
|
||||
VERT_COPY_RGBA1(v[0]);
|
||||
VERT_COPY_RGBA1(v[1]);
|
||||
VERT_COPY_RGBA1(v[2]);
|
||||
}
|
||||
VERT_SAVE_RGBA(3);
|
||||
VERT_COPY_RGBA1(v[3]);
|
||||
if (HAVE_SPEC) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_SAVE_SPEC(1);
|
||||
VERT_SAVE_SPEC(2);
|
||||
VERT_COPY_SPEC1(v[0]);
|
||||
VERT_COPY_SPEC1(v[1]);
|
||||
VERT_COPY_SPEC1(v[2]);
|
||||
}
|
||||
VERT_SAVE_SPEC(3);
|
||||
VERT_COPY_SPEC1(v[3]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_RGBA(0);
|
||||
VERT_SAVE_RGBA(1);
|
||||
VERT_SAVE_RGBA(2);
|
||||
VERT_SET_RGBA(v[0], vbcolor[e0]);
|
||||
VERT_SET_RGBA(v[1], vbcolor[e1]);
|
||||
VERT_SET_RGBA(v[2], vbcolor[e2]);
|
||||
}
|
||||
VERT_SAVE_RGBA(3);
|
||||
VERT_SET_RGBA(v[3], vbcolor[e3]);
|
||||
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
|
||||
GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
|
||||
ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat));
|
||||
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_SAVE_SPEC(1);
|
||||
VERT_SAVE_SPEC(2);
|
||||
VERT_SET_SPEC(v[0], vbspec[e0]);
|
||||
VERT_SET_SPEC(v[1], vbspec[e1]);
|
||||
VERT_SET_SPEC(v[2], vbspec[e2]);
|
||||
}
|
||||
VERT_SAVE_SPEC(3);
|
||||
VERT_SET_SPEC(v[3], vbspec[e3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
GLfloat *vbindex = (GLfloat*) VB->IndexPtr[1]->data;
|
||||
if (!DO_FLAT) {
|
||||
VERT_SAVE_IND( 0 );
|
||||
VERT_SAVE_IND( 1 );
|
||||
VERT_SAVE_IND( 2 );
|
||||
VERT_SET_IND(v[0], vbindex[e0]);
|
||||
VERT_SET_IND(v[1], vbindex[e1]);
|
||||
VERT_SET_IND(v[2], vbindex[e2]);
|
||||
}
|
||||
VERT_SAVE_IND( 3 );
|
||||
VERT_SET_IND(v[3], vbindex[e3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (DO_OFFSET) {
|
||||
offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
|
||||
z[0] = VERT_Z(v[0]);
|
||||
z[1] = VERT_Z(v[1]);
|
||||
z[2] = VERT_Z(v[2]);
|
||||
z[3] = VERT_Z(v[3]);
|
||||
if (cc * cc > 1e-16) {
|
||||
GLfloat ez = z[2] - z[0];
|
||||
GLfloat fz = z[3] - z[1];
|
||||
GLfloat a = ey * fz - ez * fy;
|
||||
GLfloat b = ez * fx - ex * fz;
|
||||
GLfloat ic = 1.0 / cc;
|
||||
GLfloat ac = a * ic;
|
||||
GLfloat bc = b * ic;
|
||||
if ( ac < 0.0f ) ac = -ac;
|
||||
if ( bc < 0.0f ) bc = -bc;
|
||||
offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
|
||||
}
|
||||
offset *= ctx->MRD;
|
||||
}
|
||||
}
|
||||
|
||||
if (DO_FLAT) {
|
||||
if (HAVE_RGBA) {
|
||||
VERT_SAVE_RGBA(0);
|
||||
VERT_SAVE_RGBA(1);
|
||||
VERT_SAVE_RGBA(2);
|
||||
VERT_COPY_RGBA(v[0], v[3]);
|
||||
VERT_COPY_RGBA(v[1], v[3]);
|
||||
VERT_COPY_RGBA(v[2], v[3]);
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_SAVE_SPEC(1);
|
||||
VERT_SAVE_SPEC(2);
|
||||
VERT_COPY_SPEC(v[0], v[3]);
|
||||
VERT_COPY_SPEC(v[1], v[3]);
|
||||
VERT_COPY_SPEC(v[2], v[3]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VERT_SAVE_IND(0);
|
||||
VERT_SAVE_IND(1);
|
||||
VERT_SAVE_IND(2);
|
||||
VERT_COPY_IND(v[0], v[3]);
|
||||
VERT_COPY_IND(v[1], v[3]);
|
||||
VERT_COPY_IND(v[2], v[3]);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == GL_POINT) {
|
||||
if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) {
|
||||
VERT_Z_ADD(v[0], offset);
|
||||
VERT_Z_ADD(v[1], offset);
|
||||
VERT_Z_ADD(v[2], offset);
|
||||
VERT_Z_ADD(v[3], offset);
|
||||
}
|
||||
UNFILLED_QUAD(ctx, GL_POINT, e0, e1, e2, e3);
|
||||
}
|
||||
else if (mode == GL_LINE) {
|
||||
if (DO_OFFSET && ctx->Polygon.OffsetLine) {
|
||||
VERT_Z_ADD(v[0], offset);
|
||||
VERT_Z_ADD(v[1], offset);
|
||||
VERT_Z_ADD(v[2], offset);
|
||||
VERT_Z_ADD(v[3], offset);
|
||||
}
|
||||
UNFILLED_QUAD(ctx, GL_LINE, e0, e1, e2, e3);
|
||||
}
|
||||
else {
|
||||
if (DO_OFFSET && ctx->Polygon.OffsetFill) {
|
||||
VERT_Z_ADD(v[0], offset);
|
||||
VERT_Z_ADD(v[1], offset);
|
||||
VERT_Z_ADD(v[2], offset);
|
||||
VERT_Z_ADD(v[3], offset);
|
||||
}
|
||||
RASTERIZE(GL_TRIANGLES);
|
||||
QUAD((v[0]), (v[1]), (v[2]), (v[3]));
|
||||
}
|
||||
|
||||
if (DO_OFFSET) {
|
||||
VERT_SET_Z(v[0], z[0]);
|
||||
VERT_SET_Z(v[1], z[1]);
|
||||
VERT_SET_Z(v[2], z[2]);
|
||||
VERT_SET_Z(v[3], z[3]);
|
||||
}
|
||||
|
||||
if (DO_TWOSIDE && facing == 1) {
|
||||
if (HAVE_RGBA) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_RESTORE_RGBA(0);
|
||||
VERT_RESTORE_RGBA(1);
|
||||
VERT_RESTORE_RGBA(2);
|
||||
}
|
||||
VERT_RESTORE_RGBA(3);
|
||||
if (HAVE_SPEC) {
|
||||
if (!DO_FLAT) {
|
||||
VERT_RESTORE_SPEC(0);
|
||||
VERT_RESTORE_SPEC(1);
|
||||
VERT_RESTORE_SPEC(2);
|
||||
}
|
||||
VERT_RESTORE_SPEC(3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!DO_FLAT) {
|
||||
VERT_RESTORE_IND( 0 );
|
||||
VERT_RESTORE_IND( 1 );
|
||||
VERT_RESTORE_IND( 2 );
|
||||
}
|
||||
VERT_RESTORE_IND( 3 );
|
||||
}
|
||||
}
|
||||
|
||||
if (DO_FLAT) {
|
||||
if (HAVE_RGBA) {
|
||||
VERT_RESTORE_RGBA(0);
|
||||
VERT_RESTORE_RGBA(1);
|
||||
VERT_RESTORE_RGBA(2);
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
|
||||
VERT_RESTORE_SPEC(0);
|
||||
VERT_RESTORE_SPEC(1);
|
||||
VERT_RESTORE_SPEC(2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VERT_RESTORE_IND(0);
|
||||
VERT_RESTORE_IND(1);
|
||||
VERT_RESTORE_IND(2);
|
||||
}
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
#else
|
||||
static void TAG(quad)(GLcontext *ctx, GLuint e0,
|
||||
GLuint e1, GLuint e2, GLuint e3)
|
||||
{
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
if (DO_UNFILLED) {
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLubyte ef1 = VB->EdgeFlag[e1];
|
||||
GLubyte ef3 = VB->EdgeFlag[e3];
|
||||
VB->EdgeFlag[e1] = 0;
|
||||
TAG(triangle)(ctx, e0, e1, e3);
|
||||
VB->EdgeFlag[e1] = ef1;
|
||||
VB->EdgeFlag[e3] = 0;
|
||||
TAG(triangle)(ctx, e1, e2, e3);
|
||||
VB->EdgeFlag[e3] = ef3;
|
||||
}
|
||||
else {
|
||||
TAG(triangle)(ctx, e0, e1, e3);
|
||||
TAG(triangle)(ctx, e1, e2, e3);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DO_LINE
|
||||
static void TAG(line)(GLcontext *ctx, GLuint e0, GLuint e1)
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
VERTEX *v[2];
|
||||
LOCAL_VARS(2);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
v[0] = (VERTEX *)GET_VERTEX(e0);
|
||||
v[1] = (VERTEX *)GET_VERTEX(e1);
|
||||
|
||||
if (DO_FLAT) {
|
||||
if (HAVE_RGBA) {
|
||||
VERT_SAVE_RGBA( 0 );
|
||||
VERT_COPY_RGBA( v[0], v[1] );
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
|
||||
VERT_SAVE_SPEC(0);
|
||||
VERT_COPY_SPEC(v[0], v[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VERT_SAVE_IND(0);
|
||||
VERT_COPY_IND(v[0], v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
LINE(v[0], v[1]);
|
||||
|
||||
if (DO_FLAT) {
|
||||
if (HAVE_RGBA) {
|
||||
VERT_RESTORE_RGBA(0);
|
||||
|
||||
if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
|
||||
VERT_RESTORE_SPEC(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
VERT_RESTORE_IND(0);
|
||||
}
|
||||
}
|
||||
SET_PRIMITIVE_RENDERED
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DO_POINTS
|
||||
static void TAG(points)(GLcontext *ctx, GLuint first, GLuint last)
|
||||
{
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
int i;
|
||||
LOCAL_VARS(1);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
if (VB->Elts == 0) {
|
||||
for (i = first; i < last; i++) {
|
||||
if (VB->ClipMask[i] == 0) {
|
||||
VERTEX *v = (VERTEX *)GET_VERTEX(i);
|
||||
POINT(v);
|
||||
SET_PRIMITIVE_RENDERED
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = first; i < last; i++) {
|
||||
GLuint e = VB->Elts[i];
|
||||
if (VB->ClipMask[e] == 0) {
|
||||
VERTEX *v = (VERTEX *)GET_VERTEX(e);
|
||||
POINT(v);
|
||||
SET_PRIMITIVE_RENDERED
|
||||
}
|
||||
}
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void TAG(init)(void)
|
||||
{
|
||||
#if DO_QUAD
|
||||
TAB[IND].quad = TAG(quad);
|
||||
#endif
|
||||
#if DO_TRI
|
||||
TAB[IND].triangle = TAG(triangle);
|
||||
#endif
|
||||
#if DO_LINE
|
||||
TAB[IND].line = TAG(line);
|
||||
#endif
|
||||
#if DO_POINTS
|
||||
TAB[IND].points = TAG(points);
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
|
||||
#if HAVE_RGBA
|
||||
#undef VERT_SET_IND
|
||||
#undef VERT_COPY_IND
|
||||
#undef VERT_SAVE_IND
|
||||
#undef VERT_RESTORE_IND
|
||||
#if HAVE_BACK_COLORS
|
||||
#undef VERT_SET_RGBA
|
||||
#endif
|
||||
#else
|
||||
#undef VERT_SET_RGBA
|
||||
#undef VERT_COPY_RGBA
|
||||
#undef VERT_SAVE_RGBA
|
||||
#undef VERT_RESTORE_RGBA
|
||||
#if HAVE_BACK_COLORS
|
||||
#undef VERT_SET_IND
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_SPEC
|
||||
#undef VERT_SET_SPEC
|
||||
#undef VERT_COPY_SPEC
|
||||
#undef VERT_SAVE_SPEC
|
||||
#undef VERT_RESTORE_SPEC
|
||||
#if HAVE_BACK_COLORS
|
||||
#undef VERT_COPY_SPEC1
|
||||
#endif
|
||||
#else
|
||||
#if HAVE_BACK_COLORS
|
||||
#undef VERT_SET_SPEC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_BACK_COLORS
|
||||
#undef VERT_COPY_SPEC1
|
||||
#undef VERT_COPY_IND1
|
||||
#undef VERT_COPY_RGBA1
|
||||
#endif
|
||||
|
||||
#ifndef INSANE_VERTICES
|
||||
#undef VERT_SET_Z
|
||||
#undef VERT_Z_ADD
|
||||
#endif
|
@@ -1,716 +0,0 @@
|
||||
/*
|
||||
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* 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, 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
|
||||
* VIA, S3 GRAPHICS, 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.
|
||||
*/
|
||||
|
||||
|
||||
/* Unlike the other templates here, this assumes quite a bit about the
|
||||
* underlying hardware. Specifically it assumes a d3d-like vertex
|
||||
* format, with a layout more or less constrained to look like the
|
||||
* following:
|
||||
*
|
||||
* union {
|
||||
* struct {
|
||||
* float x, y, z, w;
|
||||
* struct { char r, g, b, a; } color;
|
||||
* struct { char r, g, b, fog; } spec;
|
||||
* float u0, v0;
|
||||
* float u1, v1;
|
||||
* float u2, v2;
|
||||
* float u3, v3;
|
||||
* } v;
|
||||
* struct {
|
||||
* float x, y, z, w;
|
||||
* struct { char r, g, b, a; } color;
|
||||
* struct { char r, g, b, fog; } spec;
|
||||
* float u0, v0, q0;
|
||||
* float u1, v1, q1;
|
||||
* float u2, v2, q2;
|
||||
* float u3, v3, q3;
|
||||
* } pv;
|
||||
* struct {
|
||||
* float x, y, z;
|
||||
* struct { char r, g, b, a; } color;
|
||||
* } tv;
|
||||
* float f[16];
|
||||
* unsigned int ui[16];
|
||||
* unsigned char ub4[4][16];
|
||||
* }
|
||||
*
|
||||
|
||||
* DO_XYZW: Emit xyz and maybe w coordinates.
|
||||
* DO_RGBA: Emit color.
|
||||
* DO_SPEC: Emit specular color.
|
||||
* DO_FOG: Emit fog coordinate in specular alpha.
|
||||
* DO_TEX0: Emit tex0 u,v coordinates.
|
||||
* DO_TEX1: Emit tex1 u,v coordinates.
|
||||
* DO_TEX2: Emit tex2 u,v coordinates.
|
||||
* DO_TEX3: Emit tex3 u,v coordinates.
|
||||
* DO_PTEX: Emit tex0,1,2,3 q coordinates where possible.
|
||||
*
|
||||
* HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra).
|
||||
*
|
||||
* HAVE_HW_VIEWPORT: Hardware performs viewport transform.
|
||||
* HAVE_HW_DIVIDE: Hardware performs perspective divide.
|
||||
*
|
||||
* HAVE_TINY_VERTICES: Hardware understands v.tv format.
|
||||
* HAVE_PTEX_VERTICES: Hardware understands v.pv format.
|
||||
* HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0.
|
||||
*
|
||||
* Additionally, this template assumes it is emitting *transformed*
|
||||
* vertices; the modifications to emit untransformed vertices (ie. to
|
||||
* t&l hardware) are probably too great to cooexist with the code
|
||||
* already in this file.
|
||||
*
|
||||
* NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if
|
||||
* only TEX0 is enabled, in order to maintain a vertex size which is
|
||||
* an exact number of quadwords.
|
||||
*/
|
||||
|
||||
#if (HAVE_HW_VIEWPORT)
|
||||
#define VIEWPORT_X(dst, x) dst = x
|
||||
#define VIEWPORT_Y(dst, y) dst = y
|
||||
#define VIEWPORT_Z(dst, z) dst = z
|
||||
#else
|
||||
#define VIEWPORT_X(dst, x) dst = s[0] * x + s[12]
|
||||
#define VIEWPORT_Y(dst, y) dst = s[5] * y + s[13]
|
||||
#define VIEWPORT_Z(dst, z) dst = s[10] * z + s[14]
|
||||
#endif
|
||||
|
||||
#if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES)
|
||||
#error "can't cope with this combination"
|
||||
#endif
|
||||
|
||||
#ifndef LOCALVARS
|
||||
#define LOCALVARS
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_HW_DIVIDE
|
||||
#define CHECK_HW_DIVIDE 1
|
||||
#endif
|
||||
|
||||
#if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES)
|
||||
|
||||
static void TAG(emit)(GLcontext *ctx,
|
||||
GLuint start, GLuint end,
|
||||
void *dest,
|
||||
GLuint stride)
|
||||
{
|
||||
LOCALVARS
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4];
|
||||
GLfloat (*tc2)[4], (*tc3)[4];
|
||||
GLfloat (*col)[4], (*spec)[4];
|
||||
GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride;
|
||||
GLuint tc2_stride, tc3_stride;
|
||||
GLuint tc0_size, tc1_size;
|
||||
GLuint tc2_size, tc3_size;
|
||||
GLfloat (*coord)[4];
|
||||
GLuint coord_stride;
|
||||
VERTEX *v = (VERTEX *)dest;
|
||||
const GLfloat *s = GET_VIEWPORT_MAT();
|
||||
const GLubyte *mask = VB->ClipMask;
|
||||
int i;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "TAG-emit for HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICE\n");
|
||||
|
||||
if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
|
||||
(void) s;
|
||||
coord = VB->ClipPtr->data;
|
||||
coord_stride = VB->ClipPtr->stride;
|
||||
}
|
||||
else {
|
||||
coord = VB->NdcPtr->data;
|
||||
coord_stride = VB->NdcPtr->stride;
|
||||
}
|
||||
|
||||
if (DO_TEX3) {
|
||||
const GLuint t3 = GET_TEXSOURCE(3);
|
||||
tc3 = VB->TexCoordPtr[t3]->data;
|
||||
tc3_stride = VB->TexCoordPtr[t3]->stride;
|
||||
if (DO_PTEX)
|
||||
tc3_size = VB->TexCoordPtr[t3]->size;
|
||||
}
|
||||
|
||||
if (DO_TEX2) {
|
||||
const GLuint t2 = GET_TEXSOURCE(2);
|
||||
tc2 = VB->TexCoordPtr[t2]->data;
|
||||
tc2_stride = VB->TexCoordPtr[t2]->stride;
|
||||
if (DO_PTEX)
|
||||
tc2_size = VB->TexCoordPtr[t2]->size;
|
||||
}
|
||||
|
||||
if (DO_TEX1) {
|
||||
const GLuint t1 = GET_TEXSOURCE(1);
|
||||
tc1 = VB->TexCoordPtr[t1]->data;
|
||||
tc1_stride = VB->TexCoordPtr[t1]->stride;
|
||||
if (DO_PTEX)
|
||||
tc1_size = VB->TexCoordPtr[t1]->size;
|
||||
}
|
||||
|
||||
if (DO_TEX0) {
|
||||
const GLuint t0 = GET_TEXSOURCE(0);
|
||||
/* test */
|
||||
tc0_stride = VB->TexCoordPtr[t0]->stride;
|
||||
tc0 = VB->TexCoordPtr[t0]->data;
|
||||
if (DO_PTEX)
|
||||
tc0_size = VB->TexCoordPtr[t0]->size;
|
||||
}
|
||||
|
||||
if (DO_RGBA) {
|
||||
col = VB->ColorPtr[0]->data;
|
||||
col_stride = VB->ColorPtr[0]->stride;
|
||||
}
|
||||
|
||||
if (DO_SPEC) {
|
||||
spec = VB->SecondaryColorPtr[0]->data;
|
||||
spec_stride = VB->SecondaryColorPtr[0]->stride;
|
||||
}
|
||||
|
||||
if (DO_FOG) {
|
||||
if (VB->FogCoordPtr) {
|
||||
fog = VB->FogCoordPtr->data;
|
||||
fog_stride = VB->FogCoordPtr->stride;
|
||||
}
|
||||
else {
|
||||
static GLfloat tmp[4] = { 0, 0, 0, 0 };
|
||||
fog = &tmp;
|
||||
fog_stride = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* May have nonstandard strides:
|
||||
*/
|
||||
if (start) {
|
||||
STRIDE_4F(coord, start * coord_stride);
|
||||
if (DO_TEX0)
|
||||
STRIDE_4F(tc0, start * tc0_stride);
|
||||
if (DO_TEX1)
|
||||
STRIDE_4F(tc1, start * tc1_stride);
|
||||
if (DO_TEX2)
|
||||
STRIDE_4F(tc2, start * tc2_stride);
|
||||
if (DO_TEX3)
|
||||
STRIDE_4F(tc3, start * tc3_stride);
|
||||
if (DO_RGBA)
|
||||
STRIDE_4F(col, start * col_stride);
|
||||
if (DO_SPEC)
|
||||
STRIDE_4F(spec, start * spec_stride);
|
||||
if (DO_FOG)
|
||||
STRIDE_4F(fog, start * fog_stride);
|
||||
}
|
||||
|
||||
for (i = start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) {
|
||||
if (DO_XYZW) {
|
||||
if (HAVE_HW_VIEWPORT || mask[i] == 0) {
|
||||
VIEWPORT_X(v->v.x, coord[0][0]);
|
||||
VIEWPORT_Y(v->v.y, coord[0][1]);
|
||||
VIEWPORT_Z(v->v.z, coord[0][2]);
|
||||
}
|
||||
v->v.w = coord[0][3];
|
||||
STRIDE_4F(coord, coord_stride);
|
||||
}
|
||||
if (DO_RGBA) {
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.red, col[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.green, col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.blue, col[0][2]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.alpha, col[0][3]);
|
||||
STRIDE_4F(col, col_stride);
|
||||
}
|
||||
|
||||
if (DO_SPEC) {
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.red, spec[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.green, spec[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.blue, spec[0][2]);
|
||||
STRIDE_4F(spec, spec_stride);
|
||||
}
|
||||
else {
|
||||
v->v.specular.red = 0;
|
||||
v->v.specular.green = 0;
|
||||
v->v.specular.blue = 0;
|
||||
}
|
||||
|
||||
if (DO_FOG) {
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.alpha, fog[0][0]);
|
||||
/*=* [DBG] exy : fix lighting on + fog off error *=*/
|
||||
STRIDE_4F(fog, fog_stride);
|
||||
}
|
||||
else {
|
||||
v->v.specular.alpha = 0;
|
||||
}
|
||||
|
||||
if (DO_TEX0) {
|
||||
v->v.u0 = tc0[0][0];
|
||||
v->v.v0 = tc0[0][1];
|
||||
if (DO_PTEX) {
|
||||
if (HAVE_PTEX_VERTICES) {
|
||||
if (tc0_size == 4)
|
||||
v->pv.q0 = tc0[0][3];
|
||||
else
|
||||
v->pv.q0 = 1.0;
|
||||
}
|
||||
else if (tc0_size == 4) {
|
||||
float rhw = 1.0 / tc0[0][3];
|
||||
v->v.w *= tc0[0][3];
|
||||
v->v.u0 *= rhw;
|
||||
v->v.v0 *= rhw;
|
||||
}
|
||||
}
|
||||
STRIDE_4F(tc0, tc0_stride);
|
||||
}
|
||||
if (DO_TEX1) {
|
||||
if (DO_PTEX && HAVE_PTEX_VERTICES) {
|
||||
v->pv.u1 = tc1[0][0];
|
||||
v->pv.v1 = tc1[0][1];
|
||||
if (tc1_size == 4)
|
||||
v->pv.q1 = tc1[0][3];
|
||||
else
|
||||
v->pv.q1 = 1.0;
|
||||
}
|
||||
else {
|
||||
v->v.u1 = tc1[0][0];
|
||||
v->v.v1 = tc1[0][1];
|
||||
}
|
||||
STRIDE_4F(tc1, tc1_stride);
|
||||
}
|
||||
else if (DO_PTEX) {
|
||||
*(GLuint *)&v->pv.q1 = 0;
|
||||
}
|
||||
if (DO_TEX2) {
|
||||
if (DO_PTEX) {
|
||||
v->pv.u2 = tc2[0][0];
|
||||
v->pv.v2 = tc2[0][1];
|
||||
if (tc2_size == 4)
|
||||
v->pv.q2 = tc2[0][3];
|
||||
else
|
||||
v->pv.q2 = 1.0;
|
||||
}
|
||||
else {
|
||||
v->v.u2 = tc2[0][0];
|
||||
v->v.v2 = tc2[0][1];
|
||||
}
|
||||
STRIDE_4F(tc2, tc2_stride);
|
||||
}
|
||||
if (DO_TEX3) {
|
||||
if (DO_PTEX) {
|
||||
v->pv.u3 = tc3[0][0];
|
||||
v->pv.v3 = tc3[0][1];
|
||||
if (tc3_size == 4)
|
||||
v->pv.q3 = tc3[0][3];
|
||||
else
|
||||
v->pv.q3 = 1.0;
|
||||
}
|
||||
else {
|
||||
v->v.u3 = tc3[0][0];
|
||||
v->v.v3 = tc3[0][1];
|
||||
}
|
||||
STRIDE_4F(tc3, tc3_stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if DO_XYZW
|
||||
|
||||
#if HAVE_HW_DIVIDE
|
||||
#error "cannot use tiny vertices with hw perspective divide"
|
||||
#endif
|
||||
|
||||
static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
|
||||
void *dest, GLuint stride)
|
||||
{
|
||||
LOCALVARS
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLfloat (*col)[4];
|
||||
GLuint col_stride;
|
||||
GLfloat (*coord)[4] = VB->NdcPtr->data;
|
||||
GLuint coord_stride = VB->NdcPtr->stride;
|
||||
GLfloat *v = (GLfloat *)dest;
|
||||
const GLubyte *mask = VB->ClipMask;
|
||||
const GLfloat *s = GET_VIEWPORT_MAT();
|
||||
int i;
|
||||
|
||||
(void) s;
|
||||
|
||||
/*ASSERT(stride == 4);*/
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "TAG-emit for DO_XYZW\n");
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
col = VB->ColorPtr[0]->data;
|
||||
col_stride = VB->ColorPtr[0]->stride;
|
||||
|
||||
if (start) {
|
||||
STRIDE_4F(coord, start * coord_stride);
|
||||
STRIDE_4F(col, start * col_stride);
|
||||
}
|
||||
|
||||
for (i = start; i < end; i++, v += 4) {
|
||||
if (DO_XYZW) {
|
||||
if (HAVE_HW_VIEWPORT || mask[i] == 0) {
|
||||
VIEWPORT_X(v[0], coord[0][0]);
|
||||
VIEWPORT_Y(v[1], coord[0][1]);
|
||||
VIEWPORT_Z(v[2], coord[0][2]);
|
||||
}
|
||||
STRIDE_4F(coord, coord_stride);
|
||||
}
|
||||
if (DO_RGBA) {
|
||||
VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3];
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(c->red, col[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(c->green, col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(c->blue, col[0][2]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(c->alpha, col[0][3]);
|
||||
STRIDE_4F( col, col_stride );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
|
||||
void *dest, GLuint stride)
|
||||
{
|
||||
LOCALVARS
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLubyte (*col)[4];
|
||||
GLuint col_stride;
|
||||
GLfloat *v = (GLfloat *)dest;
|
||||
int i;
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "TAG-emit for No DO_XYZW\n");
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
|
||||
IMPORT_FLOAT_COLORS( ctx );
|
||||
|
||||
col = VB->ColorPtr[0]->Ptr;
|
||||
col_stride = VB->ColorPtr[0]->StrideB;
|
||||
|
||||
if (start)
|
||||
STRIDE_4UB(col, col_stride * start);
|
||||
|
||||
/* Need to figure out where color is:
|
||||
*/
|
||||
if (GET_VERTEX_FORMAT() == TINY_VERTEX_FORMAT)
|
||||
v += 3;
|
||||
else
|
||||
v += 4;
|
||||
|
||||
for (i = start; i < end; i++, STRIDE_F(v, stride)) {
|
||||
if (HAVE_RGBA_COLOR) {
|
||||
*(GLuint *)v = *(GLuint *)col[0];
|
||||
}
|
||||
else {
|
||||
GLubyte *b = (GLubyte *)v;
|
||||
b[0] = col[0][2];
|
||||
b[1] = col[0][1];
|
||||
b[2] = col[0][0];
|
||||
b[3] = col[0][3];
|
||||
}
|
||||
STRIDE_4UB(col, col_stride);
|
||||
}
|
||||
}
|
||||
#endif /* emit */
|
||||
#endif /* emit */
|
||||
|
||||
#if (DO_XYZW) && (DO_RGBA)
|
||||
|
||||
#if (HAVE_PTEX_VERTICES)
|
||||
static GLboolean TAG(check_tex_sizes)(GLcontext *ctx)
|
||||
{
|
||||
LOCALVARS
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
/* Force 'missing' texcoords to something valid.
|
||||
*/
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
|
||||
VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
|
||||
|
||||
if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
|
||||
VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
|
||||
|
||||
if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
|
||||
VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
|
||||
|
||||
if (DO_PTEX)
|
||||
return GL_TRUE;
|
||||
|
||||
if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
|
||||
(DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
|
||||
(DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) ||
|
||||
(DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4))
|
||||
return GL_FALSE;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return GL_TRUE;
|
||||
}
|
||||
#else
|
||||
static GLboolean TAG(check_tex_sizes)(GLcontext *ctx)
|
||||
{
|
||||
LOCALVARS
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
/* Force 'missing' texcoords to something valid.
|
||||
*/
|
||||
if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
|
||||
VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
|
||||
|
||||
if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
|
||||
VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
|
||||
|
||||
if (DO_TEX1 && VB->TexCoordPtr[0] == 0) {
|
||||
VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
|
||||
}
|
||||
|
||||
if (DO_PTEX)
|
||||
return GL_TRUE;
|
||||
|
||||
if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
|
||||
(DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
|
||||
(DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
|
||||
/*PTEX_FALLBACK();*/
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
|
||||
if (DO_TEX1 || DO_TEX2 || DO_TEX3) {
|
||||
/*PTEX_FALLBACK();*/
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
#endif /* ptex */
|
||||
|
||||
|
||||
static void TAG(interp)(GLcontext *ctx,
|
||||
GLfloat t,
|
||||
GLuint edst, GLuint eout, GLuint ein,
|
||||
GLboolean force_boundary)
|
||||
{
|
||||
LOCALVARS
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLubyte *ddverts = GET_VERTEX_STORE();
|
||||
GLuint shift = GET_VERTEX_STRIDE_SHIFT();
|
||||
const GLfloat *dstclip = VB->ClipPtr->data[edst];
|
||||
GLfloat w;
|
||||
const GLfloat *s = GET_VIEWPORT_MAT();
|
||||
|
||||
VERTEX *dst = (VERTEX *)(ddverts + (edst << shift));
|
||||
VERTEX *in = (VERTEX *)(ddverts + (ein << shift));
|
||||
VERTEX *out = (VERTEX *)(ddverts + (eout << shift));
|
||||
|
||||
(void)s;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
|
||||
VIEWPORT_X(dst->v.x, dstclip[0]);
|
||||
VIEWPORT_Y(dst->v.y, dstclip[1]);
|
||||
VIEWPORT_Z(dst->v.z, dstclip[2]);
|
||||
w = dstclip[3];
|
||||
}
|
||||
else {
|
||||
w = 1.0 / dstclip[3];
|
||||
VIEWPORT_X(dst->v.x, dstclip[0] * w);
|
||||
VIEWPORT_Y(dst->v.y, dstclip[1] * w);
|
||||
VIEWPORT_Z(dst->v.z, dstclip[2] * w);
|
||||
}
|
||||
|
||||
if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) ||
|
||||
DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 ||
|
||||
DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) {
|
||||
|
||||
dst->v.w = w;
|
||||
|
||||
INTERP_UB(t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0]);
|
||||
INTERP_UB(t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1]);
|
||||
INTERP_UB(t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2]);
|
||||
INTERP_UB(t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3]);
|
||||
|
||||
if (DO_SPEC) {
|
||||
INTERP_UB(t, dst->ub4[5][0], out->ub4[5][0], in->ub4[5][0]);
|
||||
INTERP_UB(t, dst->ub4[5][1], out->ub4[5][1], in->ub4[5][1]);
|
||||
INTERP_UB(t, dst->ub4[5][2], out->ub4[5][2], in->ub4[5][2]);
|
||||
}
|
||||
if (DO_FOG) {
|
||||
INTERP_UB(t, dst->ub4[5][3], out->ub4[5][3], in->ub4[5][3]);
|
||||
}
|
||||
if (DO_TEX0) {
|
||||
if (DO_PTEX) {
|
||||
if (HAVE_PTEX_VERTICES) {
|
||||
INTERP_F(t, dst->pv.u0, out->pv.u0, in->pv.u0);
|
||||
INTERP_F(t, dst->pv.v0, out->pv.v0, in->pv.v0);
|
||||
INTERP_F(t, dst->pv.q0, out->pv.q0, in->pv.q0);
|
||||
}
|
||||
else {
|
||||
INTERP_F(t, dst->v.u0, out->v.u0, in->v.u0);
|
||||
INTERP_F(t, dst->v.v0, out->v.v0, in->v.v0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
INTERP_F(t, dst->v.u0, out->v.u0, in->v.u0);
|
||||
INTERP_F(t, dst->v.v0, out->v.v0, in->v.v0);
|
||||
}
|
||||
}
|
||||
if (DO_TEX1) {
|
||||
if (DO_PTEX) {
|
||||
if (HAVE_PTEX_VERTICES) {
|
||||
INTERP_F(t, dst->pv.u1, out->pv.u1, in->pv.u1);
|
||||
INTERP_F(t, dst->pv.v1, out->pv.v1, in->pv.v1);
|
||||
INTERP_F(t, dst->pv.q1, out->pv.q1, in->pv.q1);
|
||||
}
|
||||
else {
|
||||
INTERP_F(t, dst->v.u1, out->v.u1, in->v.u1);
|
||||
INTERP_F(t, dst->v.v1, out->v.v1, in->v.v1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
INTERP_F(t, dst->v.u1, out->v.u1, in->v.u1);
|
||||
INTERP_F(t, dst->v.v1, out->v.v1, in->v.v1);
|
||||
}
|
||||
}
|
||||
else if (DO_PTEX) {
|
||||
dst->pv.q0 = 0.0; /* must be a valid float on radeon */
|
||||
}
|
||||
if (DO_TEX2) {
|
||||
if (DO_PTEX) {
|
||||
INTERP_F(t, dst->pv.u2, out->pv.u2, in->pv.u2);
|
||||
INTERP_F(t, dst->pv.v2, out->pv.v2, in->pv.v2);
|
||||
INTERP_F(t, dst->pv.q2, out->pv.q2, in->pv.q2);
|
||||
}
|
||||
else {
|
||||
INTERP_F(t, dst->v.u2, out->v.u2, in->v.u2);
|
||||
INTERP_F(t, dst->v.v2, out->v.v2, in->v.v2);
|
||||
}
|
||||
}
|
||||
if (DO_TEX3) {
|
||||
if (DO_PTEX) {
|
||||
INTERP_F(t, dst->pv.u3, out->pv.u3, in->pv.u3);
|
||||
INTERP_F(t, dst->pv.v3, out->pv.v3, in->pv.v3);
|
||||
INTERP_F(t, dst->pv.q3, out->pv.q3, in->pv.q3);
|
||||
}
|
||||
else {
|
||||
INTERP_F(t, dst->v.u3, out->v.u3, in->v.u3);
|
||||
INTERP_F(t, dst->v.v3, out->v.v3, in->v.v3);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
|
||||
*/
|
||||
INTERP_UB(t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0]);
|
||||
INTERP_UB(t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1]);
|
||||
INTERP_UB(t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2]);
|
||||
INTERP_UB(t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3]);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
#endif /* rgba && xyzw */
|
||||
|
||||
static void TAG(init)(void)
|
||||
{
|
||||
setup_tab[IND].emit = TAG(emit);
|
||||
|
||||
#if (DO_XYZW && DO_RGBA)
|
||||
setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
|
||||
setup_tab[IND].interp = TAG(interp);
|
||||
#endif
|
||||
|
||||
if (DO_SPEC)
|
||||
setup_tab[IND].copyPv = copy_pv_rgba4_spec5;
|
||||
else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 ||
|
||||
DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES)
|
||||
setup_tab[IND].copyPv = copy_pv_rgba4;
|
||||
else
|
||||
setup_tab[IND].copyPv = copy_pv_rgba3;
|
||||
|
||||
if (DO_TEX3) {
|
||||
if (DO_PTEX && HAVE_PTEX_VERTICES) {
|
||||
ASSERT(HAVE_PTEX_VERTICES);
|
||||
setup_tab[IND].vertexFormat = PROJ_TEX3_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 18;
|
||||
setup_tab[IND].vertexStrideShift = 7;
|
||||
}
|
||||
else {
|
||||
setup_tab[IND].vertexFormat = TEX3_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 14;
|
||||
setup_tab[IND].vertexStrideShift = 6;
|
||||
}
|
||||
}
|
||||
else if (DO_TEX2) {
|
||||
if (DO_PTEX && HAVE_PTEX_VERTICES) {
|
||||
ASSERT(HAVE_PTEX_VERTICES);
|
||||
setup_tab[IND].vertexFormat = PROJ_TEX3_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 18;
|
||||
setup_tab[IND].vertexStrideShift = 7;
|
||||
}
|
||||
else {
|
||||
setup_tab[IND].vertexFormat = TEX2_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 12;
|
||||
setup_tab[IND].vertexStrideShift = 6;
|
||||
}
|
||||
}
|
||||
else if (DO_TEX1) {
|
||||
if (DO_PTEX && HAVE_PTEX_VERTICES) {
|
||||
ASSERT(HAVE_PTEX_VERTICES);
|
||||
setup_tab[IND].vertexFormat = PROJ_TEX1_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 12;
|
||||
setup_tab[IND].vertexStrideShift = 6;
|
||||
}
|
||||
else {
|
||||
setup_tab[IND].vertexFormat = TEX1_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 10;
|
||||
setup_tab[IND].vertexStrideShift = 6;
|
||||
}
|
||||
}
|
||||
else if (DO_TEX0) {
|
||||
if (DO_PTEX && HAVE_PTEX_VERTICES) {
|
||||
setup_tab[IND].vertexFormat = PROJ_TEX1_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 12;
|
||||
setup_tab[IND].vertexStrideShift = 6;
|
||||
}
|
||||
else {
|
||||
setup_tab[IND].vertexFormat = TEX0_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 8;
|
||||
setup_tab[IND].vertexStrideShift = 5;
|
||||
}
|
||||
}
|
||||
else if (!HAVE_HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) {
|
||||
setup_tab[IND].vertexFormat = TINY_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 4;
|
||||
setup_tab[IND].vertexStrideShift = 4;
|
||||
}
|
||||
else if (HAVE_NOTEX_VERTICES) {
|
||||
setup_tab[IND].vertexFormat = NOTEX_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 6;
|
||||
setup_tab[IND].vertexStrideShift = 5;
|
||||
}
|
||||
else {
|
||||
setup_tab[IND].vertexFormat = TEX0_VERTEX_FORMAT;
|
||||
setup_tab[IND].vertexSize = 8;
|
||||
setup_tab[IND].vertexStrideShift = 5;
|
||||
}
|
||||
|
||||
assert(setup_tab[IND].vertexSize * 4 <=
|
||||
1 << setup_tab[IND].vertexStrideShift);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
@@ -1,556 +0,0 @@
|
||||
/*
|
||||
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* 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, 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
|
||||
* VIA, S3 GRAPHICS, 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.
|
||||
*/
|
||||
|
||||
/* Template for render stages which build and emit vertices directly
|
||||
* to fixed-size dma buffers. Useful for rendering strips and other
|
||||
* native primitives where clipping and per-vertex tweaks such as
|
||||
* those in t_dd_tritmp.h are not required.
|
||||
*
|
||||
* Produces code for both inline triangles and indexed triangles.
|
||||
* Where various primitive types are unaccelerated by hardware, the
|
||||
* code attempts to fallback to other primitive types (quadstrips to
|
||||
* tristrips, lineloops to linestrips), or to indexed vertices.
|
||||
* Ultimately, a FALLBACK() macro is invoked if there is no way to
|
||||
* render the primitive natively.
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_TRIANGLES)
|
||||
#error "must have at least triangles to use render template"
|
||||
#endif
|
||||
|
||||
#if !HAVE_ELTS
|
||||
#define ELTS_VARS
|
||||
#define ALLOC_ELTS(nr)
|
||||
#define EMIT_ELT(offset, elt)
|
||||
#define EMIT_TWO_ELTS(offset, elt0, elt1)
|
||||
#define INCR_ELTS(nr)
|
||||
#define ELT_INIT(prim)
|
||||
#define GET_CURRENT_VB_MAX_ELTS() 0
|
||||
#define GET_SUBSEQUENT_VB_MAX_ELTS() 0
|
||||
#define ALLOC_ELTS_NEW_PRIMITIVE(nr)
|
||||
#define RELEASE_ELT_VERTS()
|
||||
#define EMIT_INDEXED_VERTS(ctx, start, count)
|
||||
#endif
|
||||
|
||||
#ifndef EMIT_TWO_ELTS
|
||||
#define EMIT_TWO_ELTS(offset, elt0, elt1) \
|
||||
do { \
|
||||
EMIT_ELT(offset, elt0); \
|
||||
EMIT_ELT(offset + 1, elt1); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef FINISH
|
||||
#define FINISH
|
||||
#endif
|
||||
|
||||
/***********************************************************************
|
||||
* Render non-indexed primitives.
|
||||
***********************************************************************/
|
||||
|
||||
static void TAG(render_points_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_POINTS) {
|
||||
LOCAL_VARS;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
GLuint j, nr;
|
||||
|
||||
INIT(GL_POINTS);
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (j = start; j < count; j += nr) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_lines_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_LINES) {
|
||||
LOCAL_VARS;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
GLuint j, nr;
|
||||
|
||||
INIT(GL_LINES);
|
||||
|
||||
/* Emit whole number of lines in total and in each buffer:
|
||||
*/
|
||||
count -= (count - start) & 1;
|
||||
currentsz -= currentsz & 1;
|
||||
dmasz -= dmasz & 1;
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (j = start; j < count; j += nr) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
static void TAG(render_line_strip_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_LINE_STRIPS) {
|
||||
LOCAL_VARS;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
GLuint j, nr;
|
||||
|
||||
INIT(GL_LINE_STRIP);
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (j = start; j + 1 < count; j += nr - 1) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
static void TAG(render_line_loop_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_LINE_STRIPS) {
|
||||
LOCAL_VARS;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
GLuint j, nr;
|
||||
|
||||
INIT(GL_LINE_STRIP);
|
||||
|
||||
if (flags & PRIM_BEGIN)
|
||||
j = start;
|
||||
else
|
||||
j = start + 1;
|
||||
|
||||
/* Ensure last vertex won't wrap buffers:
|
||||
*/
|
||||
currentsz--;
|
||||
dmasz--;
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (; j + 1 < count; j += nr - 1) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
if (start < count - 1 && (flags & PRIM_END))
|
||||
EMIT_VERTS(ctx, start, 1);
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
static void TAG(render_triangles_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
LOCAL_VARS;
|
||||
int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS() / 3) * 3;
|
||||
int currentsz = (GET_CURRENT_VB_MAX_VERTS() / 3) * 3;
|
||||
GLuint j, nr;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
|
||||
/* Emit whole number of tris in total. dmasz is already a multiple
|
||||
* of 3.
|
||||
*/
|
||||
count -= (count - start) % 3;
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (j = start; j < count; j += nr) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
FINISH;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
static void TAG(render_tri_strip_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_TRI_STRIPS) {
|
||||
LOCAL_VARS;
|
||||
GLuint j, nr;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
|
||||
INIT(GL_TRIANGLE_STRIP);
|
||||
|
||||
if (currentsz < 8) {
|
||||
NEW_BUFFER();
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
/* From here on emit even numbers of tris when wrapping over buffers:
|
||||
*/
|
||||
dmasz -= (dmasz & 1);
|
||||
currentsz -= (currentsz & 1);
|
||||
|
||||
for (j = start; j + 2 < count; j += nr - 2) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_tri_fan_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (HAVE_TRI_FANS) {
|
||||
LOCAL_VARS;
|
||||
GLuint j, nr;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
|
||||
INIT(GL_TRIANGLE_FAN);
|
||||
|
||||
if (currentsz < 8) {
|
||||
NEW_BUFFER();
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
for (j = start + 1; j + 1 < count; j += nr - 1) {
|
||||
nr = MIN2(currentsz, count - j + 1);
|
||||
EMIT_VERTS(ctx, start, 1);
|
||||
EMIT_VERTS(ctx, j, nr - 1);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
/* Could write code to emit these as indexed vertices (for the
|
||||
* g400, for instance).
|
||||
*/
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
static void TAG(render_poly_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_POLYGONS) {
|
||||
LOCAL_VARS;
|
||||
GLuint j, nr;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
|
||||
INIT(GL_POLYGON);
|
||||
|
||||
if (currentsz < 8) {
|
||||
NEW_BUFFER();
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
for (j = start + 1; j + 1 < count; j += nr - 1) {
|
||||
nr = MIN2(currentsz, count - j + 1);
|
||||
EMIT_VERTS(ctx, start, 1);
|
||||
EMIT_VERTS(ctx, j, nr - 1);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) {
|
||||
TAG(render_tri_fan_verts)(ctx, start, count, flags);
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_quad_strip_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j, nr;
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (HAVE_QUAD_STRIPS) {
|
||||
LOCAL_VARS;
|
||||
GLuint j, nr;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz;
|
||||
|
||||
INIT(GL_QUAD_STRIP);
|
||||
|
||||
currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
|
||||
if (currentsz < 8) {
|
||||
NEW_BUFFER();
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
dmasz -= (dmasz & 2);
|
||||
currentsz -= (currentsz & 2);
|
||||
|
||||
for (j = start; j + 3 < count; j += nr - 2) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else if (HAVE_TRI_STRIPS) {
|
||||
LOCAL_VARS;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
|
||||
/* Emit smooth-shaded quadstrips as tristrips:
|
||||
*/
|
||||
INIT(GL_TRIANGLE_STRIP);
|
||||
|
||||
/* Emit whole number of quads in total, and in each buffer.
|
||||
*/
|
||||
dmasz -= dmasz & 1;
|
||||
currentsz -= currentsz & 1;
|
||||
count -= (count - start) & 1;
|
||||
|
||||
if (currentsz < 8) {
|
||||
NEW_BUFFER();
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
for (j = start; j + 3 < count; j += nr - 2) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
static void TAG(render_quads_verts)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M_X;
|
||||
#endif
|
||||
if (HAVE_QUADS) {
|
||||
LOCAL_VARS;
|
||||
int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS() / 4) * 4;
|
||||
int currentsz = (GET_CURRENT_VB_MAX_VERTS() / 4) * 4;
|
||||
GLuint j, nr;
|
||||
|
||||
INIT(GL_QUADS);
|
||||
|
||||
/* Emit whole number of quads in total. dmasz is already a multiple
|
||||
* of 4.
|
||||
*/
|
||||
count -= (count - start) % 4;
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (j = start; j < count; j += nr) {
|
||||
nr = MIN2(currentsz, count - j);
|
||||
EMIT_VERTS(ctx, j, nr);
|
||||
currentsz = dmasz;
|
||||
}
|
||||
FINISH;
|
||||
}
|
||||
else if (HAVE_TRIANGLES) {
|
||||
/* Hardware doesn't have a quad primitive type -- try to
|
||||
* simulate it using triangle primitive.
|
||||
*/
|
||||
LOCAL_VARS;
|
||||
int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
|
||||
int currentsz;
|
||||
GLuint j;
|
||||
|
||||
INIT(GL_TRIANGLES);
|
||||
|
||||
currentsz = GET_CURRENT_VB_MAX_VERTS();
|
||||
|
||||
/* Emit whole number of quads in total, and in each buffer.
|
||||
*/
|
||||
dmasz -= dmasz & 3;
|
||||
count -= (count - start) & 3;
|
||||
currentsz -= currentsz & 3;
|
||||
|
||||
/* Adjust for rendering as triangles:
|
||||
*/
|
||||
currentsz = currentsz / 6 * 4;
|
||||
dmasz = dmasz / 6 * 4;
|
||||
|
||||
if (currentsz < 8)
|
||||
currentsz = dmasz;
|
||||
|
||||
for (j = start; j < count; j += 4) {
|
||||
/* Send v0, v1, v3
|
||||
*/
|
||||
EMIT_VERTS(ctx, j, 2);
|
||||
EMIT_VERTS(ctx, j + 3, 1);
|
||||
/* Send v1, v2, v3
|
||||
*/
|
||||
EMIT_VERTS(ctx, j + 1, 3);
|
||||
}
|
||||
FINISH;
|
||||
}
|
||||
else {
|
||||
/* Vertices won't fit in a single buffer, fallback.
|
||||
*/
|
||||
VERT_FALLBACK(ctx, start, count, flags);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_noop)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static tnl_render_func TAG(render_tab_verts)[GL_POLYGON + 2] =
|
||||
{
|
||||
TAG(render_points_verts),
|
||||
TAG(render_lines_verts),
|
||||
TAG(render_line_loop_verts),
|
||||
TAG(render_line_strip_verts),
|
||||
TAG(render_triangles_verts),
|
||||
TAG(render_tri_strip_verts),
|
||||
TAG(render_tri_fan_verts),
|
||||
TAG(render_quads_verts),
|
||||
TAG(render_quad_strip_verts),
|
||||
TAG(render_poly_verts),
|
||||
TAG(render_noop),
|
||||
};
|
||||
|
@@ -29,9 +29,6 @@ typedef struct {
|
||||
int priv2;
|
||||
int fbOffset;
|
||||
int fbSize;
|
||||
#ifdef USE_XINERAMA
|
||||
Bool drixinerama;
|
||||
#endif
|
||||
int backOffset;
|
||||
int depthOffset;
|
||||
int textureOffset;
|
||||
|
@@ -31,150 +31,60 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
GLboolean
|
||||
via_alloc_back_buffer(viaContextPtr vmesa)
|
||||
via_alloc_draw_buffer(viaContextPtr vmesa, viaBuffer *buf)
|
||||
{
|
||||
drm_via_mem_t fb;
|
||||
unsigned char *pFB;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
fb.context = vmesa->hHWContext;
|
||||
fb.size = vmesa->back.size;
|
||||
fb.type = VIDEO;
|
||||
if (VIA_DEBUG) fprintf(stderr, "context = %d, size =%d, type = %d\n", fb.context, fb.size, fb.type);
|
||||
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb))
|
||||
return GL_FALSE;
|
||||
|
||||
pFB = vmesa->driScreen->pFB;
|
||||
|
||||
vmesa->back.offset = fb.offset;
|
||||
vmesa->back.map = (char *)(fb.offset + (GLuint)pFB);
|
||||
vmesa->back.index = fb.index;
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "back offset = %08x\n", vmesa->back.offset);
|
||||
fprintf(stderr, "back index = %d\n", vmesa->back.index);
|
||||
}
|
||||
drm_via_mem_t mem;
|
||||
mem.context = vmesa->hHWContext;
|
||||
mem.size = buf->size;
|
||||
mem.type = VIDEO;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
via_alloc_front_buffer(viaContextPtr vmesa)
|
||||
{
|
||||
drm_via_mem_t fb;
|
||||
unsigned char *pFB;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
fb.context = vmesa->hHWContext;
|
||||
fb.size = vmesa->back.size;
|
||||
fb.type = VIDEO;
|
||||
if (VIA_DEBUG) fprintf(stderr, "context = %d, size =%d, type = %d\n", fb.context, fb.size, fb.type);
|
||||
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb))
|
||||
return GL_FALSE;
|
||||
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &mem))
|
||||
return GL_FALSE;
|
||||
|
||||
pFB = vmesa->driScreen->pFB;
|
||||
|
||||
vmesa->front.offset = fb.offset;
|
||||
vmesa->front.map = (char *)(fb.offset + (GLuint)pFB);
|
||||
vmesa->front.index = fb.index;
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "front offset = %08x\n", vmesa->front.offset);
|
||||
fprintf(stderr, "front index = %d\n", vmesa->front.index);
|
||||
}
|
||||
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return GL_TRUE;
|
||||
buf->offset = mem.offset;
|
||||
buf->map = (char *)vmesa->driScreen->pFB + mem.offset;
|
||||
buf->index = mem.index;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
via_free_back_buffer(viaContextPtr vmesa)
|
||||
via_free_draw_buffer(viaContextPtr vmesa, viaBuffer *buf)
|
||||
{
|
||||
drm_via_mem_t fb;
|
||||
drm_via_mem_t mem;
|
||||
|
||||
if (!vmesa) return;
|
||||
fb.context = vmesa->hHWContext;
|
||||
fb.index = vmesa->back.index;
|
||||
fb.type = VIDEO;
|
||||
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb);
|
||||
vmesa->back.map = NULL;
|
||||
if (!vmesa) return;
|
||||
|
||||
mem.context = vmesa->hHWContext;
|
||||
mem.index = buf->index;
|
||||
mem.type = VIDEO;
|
||||
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &mem);
|
||||
buf->map = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
via_free_front_buffer(viaContextPtr vmesa)
|
||||
{
|
||||
drm_via_mem_t fb;
|
||||
|
||||
if (!vmesa) return;
|
||||
fb.context = vmesa->hHWContext;
|
||||
fb.index = vmesa->front.index;
|
||||
fb.type = VIDEO;
|
||||
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb);
|
||||
vmesa->front.map = NULL;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
via_alloc_depth_buffer(viaContextPtr vmesa)
|
||||
{
|
||||
drm_via_mem_t fb;
|
||||
unsigned char *pFB;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
fb.context = vmesa->hHWContext;
|
||||
fb.size = vmesa->depth.size;
|
||||
fb.type = VIDEO;
|
||||
|
||||
if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb)) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
pFB = vmesa->driScreen->pFB;
|
||||
|
||||
vmesa->depth.offset = fb.offset;
|
||||
vmesa->depth.map = (char *)(fb.offset + (GLuint)pFB);
|
||||
vmesa->depth.index = fb.index;
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "depth offset = %08x\n", vmesa->depth.offset);
|
||||
fprintf(stderr, "depth index = %d\n", vmesa->depth.index);
|
||||
}
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
via_free_depth_buffer(viaContextPtr vmesa)
|
||||
{
|
||||
drm_via_mem_t fb;
|
||||
|
||||
if (!vmesa) return;
|
||||
fb.context = vmesa->hHWContext;
|
||||
fb.index = vmesa->depth.index;
|
||||
fb.type = VIDEO;
|
||||
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb);
|
||||
vmesa->depth.map = NULL;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
via_alloc_dma_buffer(viaContextPtr vmesa)
|
||||
{
|
||||
drmVIADMAInit init;
|
||||
drmVIADMAInit init;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
vmesa->dma = (GLuint *) malloc(VIA_DMA_BUFSIZ);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
vmesa->dma = (GLubyte *) malloc(VIA_DMA_BUFSIZ);
|
||||
|
||||
/*
|
||||
* Check whether AGP DMA has been initialized.
|
||||
*/
|
||||
|
||||
init.func = VIA_DMA_INITIALIZED;
|
||||
vmesa->useAgp =
|
||||
/*
|
||||
* Check whether AGP DMA has been initialized.
|
||||
*/
|
||||
init.func = VIA_DMA_INITIALIZED;
|
||||
vmesa->useAgp =
|
||||
( 0 == drmCommandWrite(vmesa->driFd, DRM_VIA_DMA_INIT,
|
||||
&init, sizeof(init)));
|
||||
if (vmesa->useAgp)
|
||||
printf("unichrome_dri.so: Using AGP.\n");
|
||||
else
|
||||
printf("unichrome_dri.so: Using PCI.\n");
|
||||
if (vmesa->useAgp)
|
||||
printf("unichrome_dri.so: Using AGP.\n");
|
||||
else
|
||||
printf("unichrome_dri.so: Using PCI.\n");
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return ((vmesa->dma) ? GL_TRUE : GL_FALSE);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return ((vmesa->dma) ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -25,18 +25,14 @@
|
||||
#ifndef _VIAFB_INC
|
||||
#define _VIAFB_INC
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "swrast/swrast.h"
|
||||
extern GLboolean via_alloc_front_buffer(viaContextPtr vmesa);
|
||||
extern GLboolean via_alloc_back_buffer(viaContextPtr vmesa);
|
||||
extern void via_free_back_buffer(viaContextPtr vmesa);
|
||||
extern void via_free_front_buffer(viaContextPtr vmesa);
|
||||
extern GLboolean via_alloc_depth_buffer(viaContextPtr vmesa);
|
||||
extern void via_free_depth_buffer(viaContextPtr vmesa);
|
||||
#include "via_context.h"
|
||||
|
||||
extern GLboolean via_alloc_draw_buffer(viaContextPtr vmesa, viaBuffer *buf);
|
||||
extern GLboolean via_alloc_dma_buffer(viaContextPtr vmesa);
|
||||
extern void via_free_dma_buffer(viaContextPtr vmesa);
|
||||
extern GLboolean via_alloc_texture(viaContextPtr vmesa, viaTextureObjectPtr t);
|
||||
/*=* John Sheng [2003.5.31] agp tex *=*/
|
||||
extern GLboolean via_alloc_texture_agp(viaContextPtr vmesa, viaTextureObjectPtr t);
|
||||
|
||||
extern void via_free_draw_buffer(viaContextPtr vmesa, viaBuffer *buf);
|
||||
extern void via_free_dma_buffer(viaContextPtr vmesa);
|
||||
extern void via_free_texture(viaContextPtr vmesa, viaTextureObjectPtr t);
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -28,58 +28,72 @@
|
||||
#include "via_context.h"
|
||||
|
||||
|
||||
void viaEmitPrim(viaContextPtr vmesa);
|
||||
void viaFlushPrims(viaContextPtr vmesa);
|
||||
void viaFlushPrimsLocked(viaContextPtr vmesa);
|
||||
void viaFinishPrimitive(viaContextPtr vmesa);
|
||||
void viaFlushDma(viaContextPtr vmesa);
|
||||
void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags);
|
||||
|
||||
void viaDmaFinish(viaContextPtr vmesa);
|
||||
void viaRegetLockQuiescent(viaContextPtr vmesa);
|
||||
void viaInitIoctlFuncs(GLcontext *ctx);
|
||||
void viaCopyBuffer(const __DRIdrawablePrivate *dpriv);
|
||||
void viaPageFlip(const __DRIdrawablePrivate *dpriv);
|
||||
int via_check_copy(int fd);
|
||||
void viaFillFrontBuffer(viaContextPtr vmesa);
|
||||
void viaFillFrontBufferSaam(viaContextPtr vmesa);
|
||||
void viaFillFrontPBuffer(viaContextPtr vmesa);
|
||||
void viaFillBackBuffer(viaContextPtr vmesa);
|
||||
void viaFillDepthBuffer(viaContextPtr vmesa, GLuint pixel);
|
||||
void viaFillStencilBuffer(viaContextPtr vmesa, GLuint pixel);
|
||||
void viaFillStencilDepthBuffer(viaContextPtr vmesa, GLuint pixel);
|
||||
void viaDoSwapBuffers(viaContextPtr vmesa);
|
||||
void viaDoSwapBuffersSaam(viaContextPtr vmesa);
|
||||
void viaDoSwapPBuffers(viaContextPtr vmesa);
|
||||
void viaCheckDma(viaContextPtr vmesa, GLuint bytes);
|
||||
|
||||
int flush_agp(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd);
|
||||
int flush_agp_saam(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd);
|
||||
int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf);
|
||||
#define VIA_FINISH_PRIM(vmesa) do { \
|
||||
if (vmesa->dmaLastPrim) \
|
||||
viaFinishPrimitive( vmesa ); \
|
||||
} while (0)
|
||||
|
||||
#define VIA_STATECHANGE(vmesa, flag) \
|
||||
do { \
|
||||
if (vmesa->dmaLow != vmesa->dmaLastPrim) \
|
||||
viaFlushPrims(vmesa); \
|
||||
vmesa->dirty |= flag; \
|
||||
} while (0) \
|
||||
|
||||
|
||||
#define VIA_FIREVERTICES(vmesa) \
|
||||
do { \
|
||||
if (vmesa->dmaLow) { \
|
||||
viaFlushPrims(vmesa); \
|
||||
} \
|
||||
} while (0)
|
||||
#define VIA_FLUSH_DMA(vmesa) do { \
|
||||
VIA_FINISH_PRIM(vmesa); \
|
||||
if (vmesa->dmaLow) \
|
||||
viaFlushDma(vmesa); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static __inline GLuint *viaCheckDma(viaContextPtr vmesa, int bytes)
|
||||
{
|
||||
if (vmesa->dmaLow + bytes > vmesa->dmaHigh) {
|
||||
if (VIA_DEBUG) fprintf(stderr, "buffer overflow in check dma = %d + %d = %d\n",
|
||||
vmesa->dmaLow, bytes, vmesa->dmaLow + bytes);
|
||||
viaFlushPrims(vmesa);
|
||||
}
|
||||
GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes);
|
||||
GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int line);
|
||||
#define viaAllocDma( v, b ) viaAllocDmaFunc(v, b, __FUNCTION__, __LINE__)
|
||||
|
||||
|
||||
#define RING_VARS GLuint *_vb = 0, _nr, _x;
|
||||
|
||||
#define BEGIN_RING(n) do { \
|
||||
if (_vb != 0) abort(); \
|
||||
_vb = viaAllocDma(vmesa, (n) * sizeof(GLuint)); \
|
||||
_nr = (n); \
|
||||
_x = 0; \
|
||||
} while (0)
|
||||
|
||||
#define BEGIN_RING_NOCHECK(n) do { \
|
||||
if (_vb != 0) abort(); \
|
||||
_vb = (GLuint *)(vmesa->dma + vmesa->dmaLow); \
|
||||
vmesa->dmaLow += (n) * sizeof(GLuint); \
|
||||
_nr = (n); \
|
||||
_x = 0; \
|
||||
} while (0)
|
||||
|
||||
#define OUT_RING(n) _vb[_x++] = (n)
|
||||
|
||||
#define ADVANCE_RING() do { \
|
||||
if (_x != _nr) abort(); \
|
||||
_vb = 0; \
|
||||
} while (0)
|
||||
|
||||
#define ADVANCE_RING_VARIABLE() do { \
|
||||
if (_x > _nr) abort(); \
|
||||
vmesa->dmaLow -= (_nr - _x) * sizeof(GLuint); \
|
||||
_vb = 0; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define QWORD_PAD_RING() do { \
|
||||
if (vmesa->dmaLow & 0x4) { \
|
||||
BEGIN_RING(1); \
|
||||
OUT_RING(HC_DUMMY); \
|
||||
ADVANCE_RING(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
GLuint *start = (GLuint *)(vmesa->dmaAddr + vmesa->dmaLow);
|
||||
return start;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -60,70 +60,25 @@
|
||||
|
||||
#define HAVE_ELTS 0
|
||||
|
||||
static const GLenum reducedPrim[GL_POLYGON + 1] = {
|
||||
GL_POINTS,
|
||||
GL_LINES,
|
||||
GL_LINES,
|
||||
GL_LINES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES
|
||||
};
|
||||
|
||||
/* Fallback to normal rendering.
|
||||
*/
|
||||
static void VERT_FALLBACK(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
fprintf(stderr, "VERT_FALLBACK\n");
|
||||
tnl->Driver.Render.PrimitiveNotify(ctx, flags & PRIM_MODE_MASK);
|
||||
tnl->Driver.Render.BuildVertices(ctx, start, count, ~0);
|
||||
tnl->Driver.Render.PrimTabVerts[flags & PRIM_MODE_MASK](ctx, start,
|
||||
count, flags);
|
||||
VIA_CONTEXT(ctx)->setupNewInputs = VERT_BIT_CLIP;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
#define LOCAL_VARS viaContextPtr vmesa = VIA_CONTEXT(ctx)
|
||||
/*
|
||||
#define INIT(prim) \
|
||||
do { \
|
||||
VIA_STATECHANGE(vmesa, 0); \
|
||||
viaRasterPrimitive(ctx, reducedPrim[prim], prim); \
|
||||
} while (0)
|
||||
*/
|
||||
#define INIT(prim) \
|
||||
do { \
|
||||
viaRasterPrimitive(ctx, reducedPrim[prim], prim); \
|
||||
} while (0)
|
||||
#define NEW_PRIMITIVE() VIA_STATECHANGE(vmesa, 0)
|
||||
#define NEW_BUFFER() VIA_FIREVERTICES(vmesa)
|
||||
#define INIT(prim) do { \
|
||||
viaRasterPrimitive(ctx, prim, prim); \
|
||||
} while (0)
|
||||
#define GET_CURRENT_VB_MAX_VERTS() \
|
||||
(((int)vmesa->dmaHigh - (int)vmesa->dmaLow) / (vmesa->vertexSize * 4))
|
||||
((VIA_DMA_BUF_SZ - (512 + (int)vmesa->dmaLow)) / (vmesa->vertexSize * 4))
|
||||
#define GET_SUBSEQUENT_VB_MAX_VERTS() \
|
||||
(VIA_DMA_BUF_SZ - 4) / (vmesa->vertexSize * 4)
|
||||
(VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4)
|
||||
|
||||
#define ALLOC_VERTS( nr ) \
|
||||
viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
|
||||
|
||||
#define EMIT_VERTS(ctx, j, nr) \
|
||||
via_emit_contiguous_verts(ctx, j, (j) + (nr))
|
||||
#define EMIT_VERTS(ctx, j, nr, buf) \
|
||||
via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
|
||||
|
||||
#define FINISH \
|
||||
do { \
|
||||
vmesa->primitiveRendered = GL_TRUE; \
|
||||
viaRasterPrimitiveFinish(ctx); \
|
||||
} while (0)
|
||||
|
||||
#define FLUSH() VIA_FINISH_PRIM( vmesa )
|
||||
|
||||
#define TAG(x) via_fast##x
|
||||
#include "via_dmatmp.h"
|
||||
#include "tnl_dd/t_dd_dmatmp.h"
|
||||
#undef TAG
|
||||
#undef LOCAL_VARS
|
||||
#undef INIT
|
||||
@@ -141,11 +96,9 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
|
||||
|
||||
/* Don't handle clipping or indexed vertices.
|
||||
*/
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
|
||||
if (VB->ClipOrMask || vmesa->renderIndex != 0 || VB->Elts) {
|
||||
if (VB->ClipOrMask ||
|
||||
vmesa->renderIndex != 0 ||
|
||||
!via_fastvalidate_render( ctx, VB )) {
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "slow path\n");
|
||||
fprintf(stderr, "ClipOrMask = %08x\n", VB->ClipOrMask);
|
||||
@@ -156,7 +109,6 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
vmesa->setupNewInputs = VERT_BIT_CLIP;
|
||||
vmesa->primitiveRendered = GL_TRUE;
|
||||
|
||||
tnl->Driver.Render.Start(ctx);
|
||||
|
||||
@@ -170,9 +122,6 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
|
||||
|
||||
tnl->Driver.Render.Finish(ctx);
|
||||
|
||||
/*=* DBG - viewperf7.0 : fix command buffer overflow *=*/
|
||||
if (vmesa->dmaLow > (VIA_DMA_BUFSIZ / 2))
|
||||
viaFlushPrims(vmesa);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
@@ -223,310 +172,3 @@ const struct tnl_pipeline_stage _via_fastrender_stage =
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Render whole vertex buffers, including projection of vertices from
|
||||
* clip space and clipping of primitives.
|
||||
*
|
||||
* This file makes calls to project vertices and to the point, line
|
||||
* and triangle rasterizers via the function pointers:
|
||||
*
|
||||
* context->Driver.Render.*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip single primitives */
|
||||
/**********************************************************************/
|
||||
#undef DIFFERENT_SIGNS
|
||||
#if defined(USE_IEEE)
|
||||
#define NEGATIVE(x) (GET_FLOAT_BITS(x) & (1 << 31))
|
||||
#define DIFFERENT_SIGNS(x, y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1 << 31))
|
||||
#else
|
||||
#define NEGATIVE(x) (x < 0)
|
||||
#define DIFFERENT_SIGNS(x,y) (x * y <= 0 && x - y != 0)
|
||||
/* Could just use (x*y<0) except for the flatshading requirements.
|
||||
* Maybe there's a better way?
|
||||
*/
|
||||
#endif
|
||||
|
||||
#define W(i) coord[i][3]
|
||||
#define Z(i) coord[i][2]
|
||||
#define Y(i) coord[i][1]
|
||||
#define X(i) coord[i][0]
|
||||
#define SIZE 4
|
||||
#define TAG(x) x##_4
|
||||
#include "via_vb_cliptmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Clip and render whole begin/end objects */
|
||||
/**********************************************************************/
|
||||
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
|
||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
||||
|
||||
|
||||
/* Vertices, with the possibility of clipping.
|
||||
*/
|
||||
#define RENDER_POINTS(start, count) \
|
||||
tnl->Driver.Render.Points(ctx, start, count)
|
||||
|
||||
#define RENDER_LINE(v1, v2) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte ormask = c1 | c2; \
|
||||
if (!ormask) \
|
||||
LineFunc(ctx, v1, v2); \
|
||||
else if (!(c1 & c2 & 0x3f)) \
|
||||
clip_line_4(ctx, v1, v2, ormask); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_TRI(v1, v2, v3) \
|
||||
if (VIA_DEBUG) fprintf(stderr, "RENDER_TRI - clip\n"); \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
|
||||
GLubyte ormask = c1 | c2 | c3; \
|
||||
if (!ormask) \
|
||||
TriangleFunc(ctx, v1, v2, v3); \
|
||||
else if (!(c1 & c2 & c3 & 0x3f)) \
|
||||
clip_tri_4(ctx, v1, v2, v3, ormask); \
|
||||
} while (0)
|
||||
|
||||
#define RENDER_QUAD(v1, v2, v3, v4) \
|
||||
do { \
|
||||
GLubyte c1 = mask[v1], c2 = mask[v2]; \
|
||||
GLubyte c3 = mask[v3], c4 = mask[v4]; \
|
||||
GLubyte ormask = c1 | c2 | c3 | c4; \
|
||||
if (!ormask) \
|
||||
QuadFunc(ctx, v1, v2, v3, v4); \
|
||||
else if (!(c1 & c2 & c3 & c4 & 0x3f)) \
|
||||
clip_quad_4(ctx, v1, v2, v3, v4, ormask); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOCAL_VARS \
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx); \
|
||||
struct vertex_buffer *VB = &tnl->vb; \
|
||||
const GLuint * const elt = VB->Elts; \
|
||||
const GLubyte *mask = VB->ClipMask; \
|
||||
const GLuint sz = VB->ClipPtr->size; \
|
||||
const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
|
||||
const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
|
||||
const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
|
||||
const GLboolean stipple = ctx->Line.StippleFlag; \
|
||||
(void) (LineFunc && TriangleFunc && QuadFunc); \
|
||||
(void) elt; (void) mask; (void) sz; (void) stipple;
|
||||
|
||||
#define POSTFIX \
|
||||
viaRasterPrimitiveFinish(ctx)
|
||||
|
||||
#define TAG(x) clip_##x##_verts
|
||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify(ctx, x)
|
||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple(ctx)
|
||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
||||
#define PRESERVE_VB_DEFS
|
||||
#include "via_vb_rendertmp.h"
|
||||
|
||||
|
||||
/* Elts, with the possibility of clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#undef TAG
|
||||
#define ELT(x) elt[x]
|
||||
#define TAG(x) clip_##x##_elts
|
||||
#include "via_vb_rendertmp.h"
|
||||
|
||||
/* TODO: do this for all primitives, verts and elts:
|
||||
*/
|
||||
static void clip_elt_triangles(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES];
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
const GLuint * const elt = VB->Elts;
|
||||
GLubyte *mask = VB->ClipMask;
|
||||
GLuint last = count-2;
|
||||
GLuint j;
|
||||
(void)flags;
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
tnl->Driver.Render.PrimitiveNotify(ctx, GL_TRIANGLES);
|
||||
|
||||
for (j = start; j < last; j += 3) {
|
||||
GLubyte c1 = mask[elt[j]];
|
||||
GLubyte c2 = mask[elt[j + 1]];
|
||||
GLubyte c3 = mask[elt[j + 2]];
|
||||
GLubyte ormask = c1 | c2 | c3;
|
||||
if (ormask) {
|
||||
if (start < j)
|
||||
render_tris(ctx, start, j, 0);
|
||||
if (!(c1 & c2 & c3 & 0x3f))
|
||||
clip_tri_4(ctx, elt[j], elt[j + 1], elt[j + 2], ormask);
|
||||
start = j+3;
|
||||
}
|
||||
}
|
||||
|
||||
if (start < j)
|
||||
render_tris(ctx, start, j, 0);
|
||||
|
||||
viaRasterPrimitiveFinish(ctx);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Helper functions for drivers */
|
||||
/**********************************************************************/
|
||||
/*
|
||||
void _tnl_RenderClippedPolygon(GLcontext *ctx, const GLuint *elts, GLuint n)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint *tmp = VB->Elts;
|
||||
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n, PRIM_BEGIN|PRIM_END);
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
void _tnl_RenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line(ctx, ii, jj);
|
||||
}
|
||||
*/
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render pipeline stage */
|
||||
/**********************************************************************/
|
||||
static GLboolean via_run_render(GLcontext *ctx,
|
||||
struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
/* DBG */
|
||||
GLuint newInputs = stage->changed_inputs;
|
||||
/*GLuint newInputs = stage->inputs;*/
|
||||
|
||||
tnl_render_func *tab;
|
||||
GLuint pass = 0;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
tnl->Driver.Render.Start(ctx);
|
||||
tnl->Driver.Render.BuildVertices(ctx, 0, VB->Count, newInputs);
|
||||
if (VB->ClipOrMask) {
|
||||
tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
|
||||
clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
|
||||
}
|
||||
else {
|
||||
tab = VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts;
|
||||
}
|
||||
|
||||
do {
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; i < VB->PrimitiveCount; i++) {
|
||||
GLuint flags = VB->Primitive[i].mode;
|
||||
GLuint start = VB->Primitive[i].start;
|
||||
GLuint length= VB->Primitive[i].count;
|
||||
ASSERT(length || (flags & PRIM_END));
|
||||
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON + 1);
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK](ctx, start, start + length,flags);
|
||||
}
|
||||
}
|
||||
while (tnl->Driver.Render.Multipass && tnl->Driver.Render.Multipass(ctx, ++pass));
|
||||
tnl->Driver.Render.Finish(ctx);
|
||||
|
||||
/*=* DBG - flush : if hw idel *=*/
|
||||
/*{
|
||||
GLuint volatile *pnEnginStatus = vmesa->regEngineStatus;
|
||||
GLuint nStatus;
|
||||
nStatus = *pnEnginStatus;
|
||||
if ((nStatus & 0xFFFEFFFF) == 0x00020000)
|
||||
viaFlushPrims(vmesa);
|
||||
}*/
|
||||
|
||||
/*=* DBG viewperf7.0 : fix command buffer overflow *=*/
|
||||
if (vmesa->dmaLow > (VIA_DMA_BUFSIZ / 2))
|
||||
viaFlushPrims(vmesa);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
/* Quite a bit of work involved in finding out the inputs for the
|
||||
* render stage.
|
||||
*/
|
||||
|
||||
static void via_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
GLuint inputs = VERT_BIT_CLIP;
|
||||
|
||||
if (ctx->Visual.rgbMode) {
|
||||
inputs |= VERT_BIT_COLOR0;
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
||||
inputs |= VERT_BIT_COLOR1;
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
inputs |= VERT_BIT_TEX0;
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[1]._ReallyEnabled) {
|
||||
inputs |= VERT_BIT_TEX1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*inputs |= VERT_BIT_INDEX;*/
|
||||
}
|
||||
|
||||
/*if (ctx->Point._Attenuated)
|
||||
inputs |= VERT_POINT_SIZE;*/
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
inputs |= VERT_BIT_FOG;
|
||||
|
||||
/*if (ctx->_TriangleCaps & DD_TRI_UNFILLED)
|
||||
inputs |= VERT_EDGE;
|
||||
|
||||
if (ctx->RenderMode == GL_FEEDBACK)
|
||||
inputs |= VERT_TEX_ANY;*/
|
||||
|
||||
stage->inputs = inputs;
|
||||
}
|
||||
|
||||
|
||||
static void dtr(struct tnl_pipeline_stage *stage)
|
||||
{
|
||||
(void)stage;
|
||||
}
|
||||
|
||||
|
||||
const struct tnl_pipeline_stage _via_render_stage =
|
||||
{
|
||||
"via render",
|
||||
(_NEW_BUFFERS |
|
||||
_DD_NEW_SEPARATE_SPECULAR |
|
||||
_DD_NEW_FLATSHADE |
|
||||
_NEW_TEXTURE |
|
||||
_NEW_LIGHT |
|
||||
_NEW_POINT |
|
||||
_NEW_FOG |
|
||||
_DD_NEW_TRI_UNFILLED |
|
||||
_NEW_RENDERMODE), /* re-check (new inputs) */
|
||||
0, /* re-run (always runs) */
|
||||
GL_TRUE, /* active */
|
||||
0, 0, /* inputs (set in check_render), outputs */
|
||||
0, 0, /* changed_inputs, private */
|
||||
dtr, /* destructor */
|
||||
via_check_render, /* check - initially set to alloc data */
|
||||
via_run_render /* run */
|
||||
};
|
||||
|
@@ -117,9 +117,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
|
||||
viaScreen->irqEnabled = gDRIPriv->irqEnabled;
|
||||
viaScreen->irqEnabled = 1;
|
||||
|
||||
#ifdef USE_XINERAMA
|
||||
viaScreen->drixinerama = gDRIPriv->drixinerama;
|
||||
#endif
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID);
|
||||
fprintf(stderr, "width = %08x\n", viaScreen->width);
|
||||
@@ -219,36 +216,24 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap)
|
||||
{
|
||||
/* KW: Bogus: Do this sort of thing in MakeCurrent or similar.
|
||||
*/
|
||||
viaContextPtr vmesa;
|
||||
viaContextPtr vmesa = 0;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
|
||||
mesaVis->depthBits != 24);
|
||||
|
||||
if (ctx)
|
||||
vmesa = VIA_CONTEXT(ctx);
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
/*=* John Sheng [2003.7.2] for visual config & patch viewperf *=*/
|
||||
if (vmesa && mesaVis->depthBits == 32 && vmesa->depthBits == 16) {
|
||||
vmesa->depthBits = mesaVis->depthBits;
|
||||
vmesa->depth.size *= 2;
|
||||
vmesa->depth.pitch *= 2;
|
||||
vmesa->depth.bpp *= 2;
|
||||
if (vmesa->depth.map)
|
||||
via_free_depth_buffer(vmesa);
|
||||
if (!via_alloc_depth_buffer(vmesa)) {
|
||||
via_free_depth_buffer(vmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
((__GLcontextModes*)mesaVis)->depthBits = 16; /* XXX : sure you want to change read-only data? */
|
||||
}
|
||||
|
||||
|
||||
/* KW: removed bogus depth recalculations.
|
||||
*/
|
||||
|
||||
if (isPixmap) {
|
||||
driDrawPriv->driverPrivate = (void *)
|
||||
_mesa_create_framebuffer(mesaVis,
|
||||
GL_FALSE, /* software depth buffer? */
|
||||
mesaVis->stencilBits > 0,
|
||||
swStencil,
|
||||
mesaVis->accumRedBits > 0,
|
||||
GL_FALSE /* s/w alpha planes */);
|
||||
|
||||
@@ -260,7 +245,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
|
||||
driDrawPriv->driverPrivate = (void *)
|
||||
_mesa_create_framebuffer(mesaVis,
|
||||
GL_FALSE, /* software depth buffer? */
|
||||
mesaVis->stencilBits > 0,
|
||||
swStencil,
|
||||
mesaVis->accumRedBits > 0,
|
||||
GL_FALSE /* s/w alpha planes */);
|
||||
|
||||
|
@@ -44,9 +44,6 @@ typedef struct {
|
||||
int fbFormat;
|
||||
int fbOffset;
|
||||
int fbSize;
|
||||
#ifdef USE_XINERAMA
|
||||
Bool drixinerama;
|
||||
#endif
|
||||
|
||||
int fbStride;
|
||||
|
||||
|
@@ -32,28 +32,13 @@
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define DBG 0
|
||||
#define LOCAL_VARS \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
viaScreenPrivate *viaScreen = vmesa->viaScreen; \
|
||||
GLuint pitch = vmesa->drawPitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
GLushort p; \
|
||||
char *buf = (char *)(vmesa->drawMap + \
|
||||
dPriv->x * viaScreen->bytesPerPixel + \
|
||||
dPriv->y * pitch); \
|
||||
char *read_buf = (char *)(vmesa->readMap + \
|
||||
dPriv->x * viaScreen->bytesPerPixel + \
|
||||
dPriv->y * pitch); \
|
||||
(void)read_buf; (void)buf; (void)p
|
||||
|
||||
#define LOCAL_DEPTH_VARS \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
viaScreenPrivate *viaScreen = vmesa->viaScreen; \
|
||||
GLuint pitch = viaScreen->backPitch; \
|
||||
GLuint depth_pitch = vmesa->depth.pitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(vmesa->depth.map + \
|
||||
dPriv->x * 2 + \
|
||||
dPriv->y * pitch)
|
||||
char *buf = (char *)(vmesa->depth.map + (vmesa->drawXoff * vmesa->depth.bpp/8))
|
||||
|
||||
#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
|
||||
_y >= miny && _y < maxy)
|
||||
@@ -72,124 +57,52 @@
|
||||
|
||||
#define Y_FLIP(_y) (height - _y - 1)
|
||||
|
||||
#define HW_LOCK() \
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
|
||||
LOCK_HARDWARE_QUIESCENT(vmesa);
|
||||
#define HW_LOCK()
|
||||
#define HW_CLIPLOOP() \
|
||||
do { \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
int _nc = dPriv->numClipRects; \
|
||||
while (_nc--) { \
|
||||
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
|
||||
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
|
||||
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
|
||||
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
|
||||
|
||||
/*=* [DBG] csmash saam : bitmap option menu can't be drawn in saam *=*/
|
||||
/*#define HW_CLIPLOOP() \
|
||||
do { \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
int _nc = dPriv->numClipRects; \
|
||||
while (_nc--) { \
|
||||
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
|
||||
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
|
||||
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
|
||||
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;*/
|
||||
#define HW_CLIPLOOP() \
|
||||
do { \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
int _nc = dPriv->numClipRects; \
|
||||
GLuint scrn = vmesa->saam & S_MASK; \
|
||||
if(scrn == S1) _nc = 1; \
|
||||
while (_nc--) { \
|
||||
int minx; \
|
||||
int miny; \
|
||||
int maxx; \
|
||||
int maxy; \
|
||||
if (!vmesa->saam) { \
|
||||
minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
|
||||
miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
|
||||
maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
|
||||
maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; \
|
||||
} \
|
||||
else { \
|
||||
minx = -10000; \
|
||||
miny = -10000; \
|
||||
maxx = 10000; \
|
||||
maxy = 10000; \
|
||||
}
|
||||
|
||||
/*else if (scrn == S0) { \
|
||||
minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
|
||||
miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
|
||||
maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
|
||||
maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; \
|
||||
} \
|
||||
else if (scrn == S1) { \
|
||||
drm_clip_rect_t *b = vmesa->sarea->boxes; \
|
||||
minx = b->x1; \
|
||||
miny = b->y1; \
|
||||
maxx = b->x2; \
|
||||
maxy = b->y2; \
|
||||
} \
|
||||
else { \
|
||||
drm_clip_rect_t *b = vmesa->sarea->boxes + vmesa->numClipRects;\
|
||||
minx = b->x1; \
|
||||
miny = b->y1; \
|
||||
maxx = b->x2; \
|
||||
maxy = b->y2; \
|
||||
}*/
|
||||
|
||||
#define HW_ENDCLIPLOOP() \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define HW_UNLOCK() \
|
||||
UNLOCK_HARDWARE(vmesa);
|
||||
|
||||
#define HW_UNLOCK()
|
||||
|
||||
/* 16 bit, 565 rgb color spanline and pixel functions
|
||||
*/
|
||||
/*=* [DBG] csmash : fix options worng position *=*/
|
||||
/*#define LOCAL_VARS \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
GLuint pitch = vmesa->drawPitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
GLushort p; \
|
||||
char *buf = (char *)(vmesa->drawMap + \
|
||||
dPriv->x * 2 + \
|
||||
dPriv->y * pitch); \
|
||||
char *read_buf = (char *)(vmesa->readMap + \
|
||||
dPriv->x * 2 + \
|
||||
dPriv->y * pitch); \
|
||||
(void)read_buf; (void)buf; (void)p*/
|
||||
|
||||
#undef LOCAL_VARS
|
||||
#define LOCAL_VARS \
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
GLuint pitch = vmesa->drawPitch; \
|
||||
GLuint draw_pitch = vmesa->drawBuffer->pitch; \
|
||||
GLuint read_pitch = vmesa->readBuffer->pitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
GLushort p; \
|
||||
char *buf, *read_buf; \
|
||||
p = 0; \
|
||||
if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { \
|
||||
buf = (char *)(vmesa->drawMap); \
|
||||
read_buf = (char *)(vmesa->readMap); \
|
||||
} \
|
||||
else { \
|
||||
buf = (char *)(vmesa->drawMap + \
|
||||
dPriv->x * 2 + \
|
||||
dPriv->y * pitch); \
|
||||
read_buf = (char *)(vmesa->readMap + \
|
||||
dPriv->x * 2 + \
|
||||
dPriv->y * pitch); \
|
||||
}
|
||||
GLushort p = 0; \
|
||||
char *buf = (char *)(vmesa->drawBuffer->origMap + vmesa->drawXoff * 2); \
|
||||
char *read_buf = (char *)(vmesa->readBuffer->origMap + vmesa->drawXoff * 2); \
|
||||
(void) (read_pitch && draw_pitch && buf && read_buf && p);
|
||||
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = PACK_COLOR_565(color[0], color[1], color[2])
|
||||
|
||||
#define WRITE_RGBA(_x, _y, r, g, b, a) \
|
||||
*(GLushort *)(buf + _x * 2 + _y * pitch) = ((((int)r & 0xf8) << 8) | \
|
||||
*(GLushort *)(buf + _x * 2 + _y * draw_pitch) = ((((int)r & 0xf8) << 8) | \
|
||||
(((int)g & 0xfc) << 3) | \
|
||||
(((int)b & 0xf8) >> 3))
|
||||
|
||||
#define WRITE_PIXEL(_x, _y, p) \
|
||||
*(GLushort *)(buf + _x * 2 + _y * pitch) = p
|
||||
*(GLushort *)(buf + _x * 2 + _y * draw_pitch) = p
|
||||
|
||||
#define READ_RGBA(rgba, _x, _y) \
|
||||
do { \
|
||||
GLushort p = *(GLushort *)(read_buf + _x * 2 + _y * pitch); \
|
||||
GLushort p = *(GLushort *)(read_buf + _x * 2 + _y * read_pitch); \
|
||||
rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
|
||||
rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
|
||||
rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
|
||||
@@ -203,29 +116,23 @@
|
||||
*/
|
||||
#undef LOCAL_VARS
|
||||
#undef LOCAL_DEPTH_VARS
|
||||
#undef INIT_MONO_PIXEL
|
||||
#undef DBG
|
||||
#define DBG 0
|
||||
|
||||
#define LOCAL_VARS \
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
GLuint pitch = vmesa->drawPitch; \
|
||||
GLuint draw_pitch = vmesa->drawBuffer->pitch; \
|
||||
GLuint read_pitch = vmesa->readBuffer->pitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
GLuint p; \
|
||||
char *buf, *read_buf; \
|
||||
p = 0; \
|
||||
if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { \
|
||||
buf = (char *)(vmesa->drawMap); \
|
||||
read_buf = (char *)(vmesa->readMap); \
|
||||
} \
|
||||
else { \
|
||||
buf = (char *)(vmesa->drawMap + \
|
||||
dPriv->x * 4 + \
|
||||
dPriv->y * pitch); \
|
||||
read_buf = (char *)(vmesa->readMap + \
|
||||
dPriv->x * 4 + \
|
||||
dPriv->y * pitch); \
|
||||
}
|
||||
GLuint p = 0; \
|
||||
char *buf = (char *)(vmesa->drawBuffer->origMap + vmesa->drawXoff * 4); \
|
||||
char *read_buf = (char *)(vmesa->readBuffer->origMap + vmesa->drawXoff * 4); \
|
||||
(void) (read_pitch && draw_pitch && buf && read_buf && p);
|
||||
|
||||
#define GET_SRC_PTR(_x, _y) (read_buf + _x * 4 + _y * pitch)
|
||||
#define GET_DST_PTR(_x, _y) ( buf + _x * 4 + _y * pitch)
|
||||
#define GET_SRC_PTR(_x, _y) (read_buf + _x * 4 + _y * read_pitch)
|
||||
#define GET_DST_PTR(_x, _y) ( buf + _x * 4 + _y * draw_pitch)
|
||||
#define SPANTMP_PIXEL_FMT GL_BGRA
|
||||
#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
|
||||
|
||||
@@ -236,27 +143,21 @@
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
/*=* John Sheng [2003.6.16] fix exy press 'i' dirty screen *=*/
|
||||
/*#define LOCAL_DEPTH_VARS \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
GLuint pitch = vmesa->depth.pitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(vmesa->depth.map + \
|
||||
dPriv->x * 2 + \
|
||||
dPriv->y * pitch) */
|
||||
#define LOCAL_DEPTH_VARS \
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
|
||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
|
||||
/*viaScreenPrivate *viaScreen = vmesa->viaScreen;*/ \
|
||||
GLuint pitch = vmesa->depth.pitch; \
|
||||
GLuint depth_pitch = vmesa->depth.pitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(vmesa->depth.map)
|
||||
char *buf = (char *)(vmesa->depth.map + (vmesa->drawXoff * vmesa->depth.bpp/8))
|
||||
|
||||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
|
||||
|
||||
|
||||
#define WRITE_DEPTH(_x, _y, d) \
|
||||
*(GLushort *)(buf + _x * 2 + _y * pitch) = d;
|
||||
*(GLushort *)(buf + _x * 2 + _y * depth_pitch) = d;
|
||||
|
||||
#define READ_DEPTH(d, _x, _y) \
|
||||
d = *(GLushort *)(buf + _x * 2 + _y * pitch);
|
||||
d = *(GLushort *)(buf + _x * 2 + _y * depth_pitch);
|
||||
|
||||
#define TAG(x) via##x##_16
|
||||
#include "depthtmp.h"
|
||||
@@ -264,54 +165,80 @@
|
||||
/* 32 bit depthbuffer functions.
|
||||
*/
|
||||
#define WRITE_DEPTH(_x, _y, d) \
|
||||
*(GLuint *)(buf + _x * 4 + _y * pitch) = d;
|
||||
*(GLuint *)(buf + _x * 4 + _y * depth_pitch) = d;
|
||||
|
||||
#define READ_DEPTH(d, _x, _y) \
|
||||
d = *(GLuint *)(buf + _x * 4 + _y * pitch);
|
||||
d = *(GLuint *)(buf + _x * 4 + _y * depth_pitch);
|
||||
|
||||
#define TAG(x) via##x##_32
|
||||
#include "depthtmp.h"
|
||||
|
||||
/* 24/8 bit depthbuffer functions.
|
||||
*/
|
||||
/*
|
||||
#define WRITE_DEPTH(_x, _y, d) { \
|
||||
GLuint tmp = *(GLuint *)(buf + _x * 4 + y * pitch); \
|
||||
tmp &= 0xff; \
|
||||
tmp |= (d) & 0xffffff00; \
|
||||
*(GLuint *)(buf + _x * 4 + _y * pitch) = tmp; \
|
||||
|
||||
#define READ_DEPTH(d, _x, _y) \
|
||||
d = (*(GLuint *)(buf + _x * 4 + _y * pitch) & ~0xff) >> 8;
|
||||
|
||||
/* 24/8 bit interleaved depth/stencil functions
|
||||
*/
|
||||
#define WRITE_DEPTH( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \
|
||||
tmp &= 0x000000ff; \
|
||||
tmp |= ((d)<<8); \
|
||||
*(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = (*(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch)) >> 8;
|
||||
|
||||
|
||||
#define TAG(x) via##x##_24_8
|
||||
#include "depthtmp.h"
|
||||
*/
|
||||
|
||||
#define WRITE_STENCIL( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \
|
||||
tmp &= 0xffffff00; \
|
||||
tmp |= (d); \
|
||||
*(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_STENCIL( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) & 0xff;
|
||||
|
||||
#define TAG(x) via##x##_24_8
|
||||
#include "stenciltmp.h"
|
||||
|
||||
|
||||
|
||||
static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
|
||||
GLuint bufferBit)
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
|
||||
if (bufferBit == DD_FRONT_LEFT_BIT) {
|
||||
vmesa->drawMap = (char *)vmesa->driScreen->pFB;
|
||||
vmesa->readMap = (char *)vmesa->driScreen->pFB;
|
||||
vmesa->drawPitch = vmesa->front.pitch;
|
||||
vmesa->readPitch = vmesa->front.pitch;
|
||||
vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
|
||||
}
|
||||
else if (bufferBit == DD_BACK_LEFT_BIT) {
|
||||
vmesa->drawMap = vmesa->back.map;
|
||||
vmesa->readMap = vmesa->back.map;
|
||||
vmesa->drawPitch = vmesa->back.pitch;
|
||||
vmesa->readPitch = vmesa->back.pitch;
|
||||
vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
|
||||
}
|
||||
else {
|
||||
ASSERT(0);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/* Move locking out to get reasonable span performance.
|
||||
*/
|
||||
void viaSpanRenderStart( GLcontext *ctx )
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
VIA_FINISH_PRIM(vmesa);
|
||||
LOCK_HARDWARE(vmesa);
|
||||
viaFlushDmaLocked(vmesa, 0);
|
||||
WAIT_IDLE(vmesa);
|
||||
}
|
||||
|
||||
void viaSpanRenderFinish( GLcontext *ctx )
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
_swrast_flush( ctx );
|
||||
UNLOCK_HARDWARE( vmesa );
|
||||
}
|
||||
|
||||
void viaInitSpanFuncs(GLcontext *ctx)
|
||||
{
|
||||
@@ -320,7 +247,7 @@ void viaInitSpanFuncs(GLcontext *ctx)
|
||||
|
||||
swdd->SetBuffer = viaSetBuffer;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);
|
||||
if (vmesa->viaScreen->bitsPerPixel == 0x10) {
|
||||
if (vmesa->viaScreen->bitsPerPixel == 16) {
|
||||
swdd->WriteRGBASpan = viaWriteRGBASpan_565;
|
||||
swdd->WriteRGBSpan = viaWriteRGBSpan_565;
|
||||
swdd->WriteMonoRGBASpan = viaWriteMonoRGBASpan_565;
|
||||
@@ -329,24 +256,44 @@ void viaInitSpanFuncs(GLcontext *ctx)
|
||||
swdd->ReadRGBASpan = viaReadRGBASpan_565;
|
||||
swdd->ReadRGBAPixels = viaReadRGBAPixels_565;
|
||||
}
|
||||
else if (vmesa->viaScreen->bitsPerPixel == 0x20) {
|
||||
else if (vmesa->viaScreen->bitsPerPixel == 32) {
|
||||
viaInitPointers_8888( swdd );
|
||||
}
|
||||
else
|
||||
ASSERT(0);
|
||||
else {
|
||||
fprintf(stderr, "%s: failed\n", __FUNCTION__);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (vmesa->glCtx->Visual.depthBits == 0x10) {
|
||||
if (vmesa->glCtx->Visual.depthBits == 16) {
|
||||
swdd->ReadDepthSpan = viaReadDepthSpan_16;
|
||||
swdd->WriteDepthSpan = viaWriteDepthSpan_16;
|
||||
swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_16;
|
||||
swdd->ReadDepthPixels = viaReadDepthPixels_16;
|
||||
swdd->WriteDepthPixels = viaWriteDepthPixels_16;
|
||||
}
|
||||
else if (vmesa->glCtx->Visual.depthBits == 0x20) {
|
||||
else if (vmesa->glCtx->Visual.depthBits == 24) {
|
||||
fprintf(stderr, "%s: 24/8 span functions\n", __FUNCTION__);
|
||||
swdd->ReadDepthSpan = viaReadDepthSpan_24_8;
|
||||
swdd->WriteDepthSpan = viaWriteDepthSpan_24_8;
|
||||
swdd->ReadDepthPixels = viaReadDepthPixels_24_8;
|
||||
swdd->WriteDepthPixels = viaWriteDepthPixels_24_8;
|
||||
|
||||
swdd->WriteStencilSpan = viaWriteStencilSpan_24_8;
|
||||
swdd->ReadStencilSpan = viaReadStencilSpan_24_8;
|
||||
swdd->WriteStencilPixels = viaWriteStencilPixels_24_8;
|
||||
swdd->ReadStencilPixels = viaReadStencilPixels_24_8;
|
||||
}
|
||||
else if (vmesa->glCtx->Visual.depthBits == 32) {
|
||||
swdd->ReadDepthSpan = viaReadDepthSpan_32;
|
||||
swdd->WriteDepthSpan = viaWriteDepthSpan_32;
|
||||
swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_32;
|
||||
swdd->ReadDepthPixels = viaReadDepthPixels_32;
|
||||
swdd->WriteDepthPixels = viaWriteDepthPixels_32;
|
||||
}
|
||||
|
||||
swdd->SpanRenderStart = viaSpanRenderStart;
|
||||
swdd->SpanRenderFinish = viaSpanRenderFinish;
|
||||
|
||||
|
||||
swdd->WriteCI8Span = NULL;
|
||||
swdd->WriteCI32Span = NULL;
|
||||
|
@@ -26,5 +26,7 @@
|
||||
#define _VIA_SPAN_H
|
||||
|
||||
extern void viaInitSpanFuncs(GLcontext *ctx);
|
||||
extern void viaSpanRenderStart( GLcontext *ctx );
|
||||
extern void viaSpanRenderFinish( GLcontext *ctx );
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,18 +30,8 @@
|
||||
extern void viaInitState(GLcontext *ctx);
|
||||
extern void viaInitStateFuncs(GLcontext *ctx);
|
||||
extern void viaCalcViewport(GLcontext *ctx);
|
||||
extern void viaPrintDirty(const char *msg, GLuint state);
|
||||
extern void viaChooseTextureState(GLcontext *ctx);
|
||||
extern void viaChooseColorState(GLcontext *ctx);
|
||||
extern void viaChooseDepthState(GLcontext *ctx);
|
||||
extern void viaChoosePolygonState(GLcontext *ctx);
|
||||
extern void viaChoosePoint(GLcontext *ctx);
|
||||
extern void viaChooseLine(GLcontext *ctx);
|
||||
extern void viaChooseTriangle(GLcontext *ctx);
|
||||
extern void viaChooseFogState(GLcontext *ctx);
|
||||
extern void viaChooseStencilState(GLcontext *ctx);
|
||||
extern void viaChooseLightState(GLcontext *ctx);
|
||||
extern void viaChooseLineState(GLcontext *ctx);
|
||||
extern void viaValidateState(GLcontext *ctx);
|
||||
extern void viaEmitState(viaContextPtr vmesa);
|
||||
|
||||
extern void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode);
|
||||
#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode)
|
||||
|
@@ -237,10 +237,8 @@ static void viaDeleteTexture(GLcontext *ctx, struct gl_texture_object *texObj)
|
||||
if (t) {
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
if (vmesa) {
|
||||
/*=* John Sheng [2003.7.18] viewperf frames/sec *=*/
|
||||
/*VIA_FIREVERTICES(vmesa);*/
|
||||
if (vmesa->dma) { /* imply vmesa is not under destroying */
|
||||
VIA_FIREVERTICES(vmesa);
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
}
|
||||
viaDestroyTexObj(vmesa, t);
|
||||
}
|
||||
|
@@ -63,12 +63,10 @@ void viaDestroyTexObj(viaContextPtr vmesa, viaTextureObjectPtr t)
|
||||
if (vmesa) {
|
||||
if (vmesa->CurrentTexObj[0] == t) {
|
||||
vmesa->CurrentTexObj[0] = 0;
|
||||
vmesa->dirty &= ~VIA_UPLOAD_TEX0;
|
||||
}
|
||||
|
||||
if (vmesa->CurrentTexObj[1] == t) {
|
||||
vmesa->CurrentTexObj[1] = 0;
|
||||
vmesa->dirty &= ~VIA_UPLOAD_TEX1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,10 +429,10 @@ void viaUploadTexImages(viaContextPtr vmesa, viaTextureObjectPtr t)
|
||||
/*t->bufAddr = (char *)((GLuint)vmesa->driScreen->pFB + t->texMem.offset);*/
|
||||
|
||||
if (t == vmesa->CurrentTexObj[0])
|
||||
VIA_STATECHANGE(vmesa, VIA_UPLOAD_TEX0);
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
|
||||
if (t == vmesa->CurrentTexObj[1])
|
||||
VIA_STATECHANGE(vmesa, VIA_UPLOAD_TEX1);
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
|
||||
viaUpdateTexLRU(vmesa, t);
|
||||
|
||||
|
@@ -233,12 +233,6 @@ static void viaSetTexImages(viaContextPtr vmesa,
|
||||
|
||||
numLevels = lastLevel - firstLevel + 1;
|
||||
|
||||
/*=* [DBG] fgfs : fix mipmap level 11 over hw limitations and result in segmentation fault *=*/
|
||||
if(numLevels > 10) {
|
||||
numLevels = 10;
|
||||
t->lastLevel = firstLevel + 9;
|
||||
}
|
||||
|
||||
log2Width = tObj->Image[0][firstLevel]->WidthLog2;
|
||||
log2Height = tObj->Image[0][firstLevel]->HeightLog2;
|
||||
log2Pitch = logbase2(tObj->Image[0][firstLevel]->Width * baseImage->TexFormat->TexelBytes);
|
||||
@@ -270,7 +264,8 @@ static void viaSetTexImages(viaContextPtr vmesa,
|
||||
t->totalSize = (*texSize)[log2Height][log2Width];
|
||||
t->texMem.size = t->totalSize;
|
||||
t->maxLevel = i - 1;
|
||||
t->dirty = VIA_UPLOAD_TEX0 | VIA_UPLOAD_TEX1;
|
||||
/* t->dirty = VIA_UPLOAD_TEX0 | VIA_UPLOAD_TEX1; */
|
||||
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "log2Width = %d\n", log2Width);
|
||||
fprintf(stderr, "log2Height = %d\n", log2Height);
|
||||
@@ -643,36 +638,36 @@ static void viaUpdateTexEnv(GLcontext *ctx, GLuint unit)
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void viaUpdateTexUnit(GLcontext *ctx, GLuint unit)
|
||||
static GLboolean viaUpdateTexUnit(GLcontext *ctx, GLuint unit)
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
if (texUnit->_ReallyEnabled) {
|
||||
|
||||
if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT ||
|
||||
texUnit->_ReallyEnabled == TEXTURE_1D_BIT) {
|
||||
|
||||
struct gl_texture_object *tObj = texUnit->_Current;
|
||||
viaTextureObjectPtr t = (viaTextureObjectPtr)tObj->DriverData;
|
||||
|
||||
/* Upload teximages (not pipelined)
|
||||
*/
|
||||
if (t->dirtyImages) {
|
||||
VIA_FIREVERTICES(vmesa);
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
viaSetTexImages(vmesa, tObj);
|
||||
if (!t->bufAddr) {
|
||||
FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, GL_TRUE);
|
||||
return;
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, GL_TRUE);
|
||||
return;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Update state if this is a different texture object to last
|
||||
* time.
|
||||
*/
|
||||
if (vmesa->CurrentTexObj[unit] != t) {
|
||||
VIA_STATECHANGE(vmesa, (VIA_UPLOAD_TEX0 << unit));
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
vmesa->CurrentTexObj[unit] = t;
|
||||
viaUpdateTexLRU(vmesa, t); /* done too often */
|
||||
}
|
||||
@@ -684,23 +679,27 @@ static void viaUpdateTexUnit(GLcontext *ctx, GLuint unit)
|
||||
vmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
|
||||
viaUpdateTexEnv(ctx, unit);
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
else if (texUnit->_ReallyEnabled) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
else {
|
||||
vmesa->CurrentTexObj[unit] = 0;
|
||||
vmesa->TexEnvImageFmt[unit] = 0;
|
||||
vmesa->dirty &= ~(VIA_UPLOAD_TEX0 << unit);
|
||||
VIA_STATECHANGE(vmesa, VIA_UPLOAD_CTX);
|
||||
VIA_FLUSH_DMA(vmesa);
|
||||
return GL_TRUE;
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void viaUpdateTextureState(GLcontext *ctx)
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, GL_FALSE);
|
||||
viaUpdateTexUnit(ctx, 0);
|
||||
viaUpdateTexUnit(ctx, 1);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
|
||||
GLuint ok = (viaUpdateTexUnit(ctx, 0) &&
|
||||
viaUpdateTexUnit(ctx, 1));
|
||||
|
||||
FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, !ok);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -39,12 +39,11 @@
|
||||
|
||||
static struct {
|
||||
void (*emit)(GLcontext *, GLuint, GLuint, void *, GLuint);
|
||||
tnl_interp_func interp;
|
||||
tnl_copy_pv_func copyPv;
|
||||
tnl_interp_func interp;
|
||||
tnl_copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)(GLcontext *ctx);
|
||||
GLuint vertexSize;
|
||||
GLuint vertexStrideShift;
|
||||
GLuint vertexFormat;
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_format;
|
||||
} setup_tab[VIA_MAX_SETUP];
|
||||
|
||||
#define TINY_VERTEX_FORMAT 1
|
||||
@@ -71,12 +70,9 @@ static struct {
|
||||
#define VERTEX_COLOR via_color_t
|
||||
#define GET_VIEWPORT_MAT() VIA_CONTEXT(ctx)->ViewportMatrix.m
|
||||
#define GET_TEXSOURCE(n) n
|
||||
#define GET_VERTEX_FORMAT() VIA_CONTEXT(ctx)->vertexSize
|
||||
#define GET_VERTEX_SIZE() (1<<GET_VERTEX_STRIDE_SHIFT())
|
||||
#define GET_VERTEX_FORMAT() VIA_CONTEXT(ctx)->vertexFormat
|
||||
#define GET_VERTEX_SIZE() VIA_CONTEXT(ctx)->vertexSize * sizeof(GLuint)
|
||||
#define GET_VERTEX_STORE() VIA_CONTEXT(ctx)->verts
|
||||
#define GET_VERTEX_STRIDE_SHIFT() VIA_CONTEXT(ctx)->vertexStrideShift
|
||||
#define GET_UBYTE_COLOR_STORE() &VIA_CONTEXT(ctx)->UbyteColor
|
||||
#define GET_UBYTE_SPEC_COLOR_STORE() &VIA_CONTEXT(ctx)->UbyteSecondaryColor
|
||||
#define INVALIDATE_STORED_VERTICES()
|
||||
|
||||
#define HAVE_HW_VIEWPORT 0
|
||||
@@ -90,18 +86,18 @@ static struct {
|
||||
#define HAVE_TEX3_VERTICES 0
|
||||
#define HAVE_PTEX_VERTICES 0
|
||||
|
||||
#define UNVIEWPORT_VARS GLfloat h = VIA_CONTEXT(ctx)->driDrawable->h
|
||||
#define UNVIEWPORT_X(x) x - SUBPIXEL_X
|
||||
#define UNVIEWPORT_VARS \
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
|
||||
GLfloat h = vmesa->driDrawable->h, depth_max = vmesa->depth_max, xoff = vmesa->drawXoff;
|
||||
|
||||
#define UNVIEWPORT_X(x) x - (SUBPIXEL_X + xoff)
|
||||
#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
|
||||
#define UNVIEWPORT_Z(z) z * (float)0xffffffff
|
||||
#define UNVIEWPORT_Z(z) z * (float)depth_max
|
||||
|
||||
#define PTEX_FALLBACK() FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_TEXTURE, 1)
|
||||
|
||||
#define IMPORT_FLOAT_COLORS via_import_float_colors
|
||||
#define IMPORT_FLOAT_SPEC_COLORS via_import_float_spec_colors
|
||||
|
||||
#define INTERP_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].interp
|
||||
#define COPY_PV_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].copyPv
|
||||
#define COPY_PV_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].copy_pv
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
@@ -116,94 +112,94 @@ static struct {
|
||||
***********************************************************************/
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT)
|
||||
#define TAG(x) x##_wg
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT)
|
||||
#define TAG(x) x##_wgs
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgt0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_TEX1_BIT)
|
||||
#define TAG(x) x##_wgt0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgpt0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_TEX1_BIT |\
|
||||
VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgpt0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgst0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
|
||||
VIA_TEX1_BIT)
|
||||
#define TAG(x) x##_wgst0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
|
||||
VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgspt0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
|
||||
VIA_TEX1_BIT | VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgspt0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT)
|
||||
#define TAG(x) x##_wgf
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT)
|
||||
#define TAG(x) x##_wgfs
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgft0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
|
||||
VIA_TEX1_BIT)
|
||||
#define TAG(x) x##_wgft0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
|
||||
VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfpt0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
|
||||
VIA_TEX1_BIT | VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfpt0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
|
||||
VIA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgfst0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
|
||||
VIA_TEX0_BIT | VIA_TEX1_BIT)
|
||||
#define TAG(x) x##_wgfst0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
|
||||
VIA_TEX0_BIT | VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfspt0
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
|
||||
VIA_TEX0_BIT | VIA_TEX1_BIT | VIA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfspt0t1
|
||||
#include "via_dd_vbtmp.h"
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
static void init_setup_tab(void) {
|
||||
|
||||
@@ -241,13 +237,11 @@ void viaPrintSetupFlags(char *msg, GLuint flags) {
|
||||
(flags & VIA_TEX1_BIT) ? " tex-1," : "");
|
||||
}
|
||||
|
||||
void viaCheckTexSizes(GLcontext *ctx) {
|
||||
void viaCheckTexSizes(GLcontext *ctx)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
if (VIA_DEBUG) {
|
||||
fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
fprintf(stderr, "setupIndex = %x\n", vmesa->setupIndex);
|
||||
}
|
||||
|
||||
if (!setup_tab[vmesa->setupIndex].check_tex_sizes(ctx)) {
|
||||
/* Invalidate stored verts
|
||||
*/
|
||||
@@ -257,8 +251,11 @@ void viaCheckTexSizes(GLcontext *ctx) {
|
||||
if (!vmesa->Fallback &&
|
||||
!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
|
||||
tnl->Driver.Render.Interp = setup_tab[vmesa->setupIndex].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[vmesa->setupIndex].copyPv;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[vmesa->setupIndex].copy_pv;
|
||||
}
|
||||
|
||||
if (vmesa->Fallback)
|
||||
tnl->Driver.Render.Start(ctx);
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
@@ -269,14 +266,16 @@ void viaBuildVertices(GLcontext *ctx,
|
||||
GLuint newinputs)
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
GLubyte *v = ((GLubyte *)vmesa->verts + (start << vmesa->vertexStrideShift));
|
||||
GLuint stride = 1 << vmesa->vertexStrideShift;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
GLuint stride = vmesa->vertexSize * sizeof(GLuint);
|
||||
GLubyte *v = (GLubyte *)vmesa->verts + start * stride;
|
||||
|
||||
newinputs |= vmesa->setupNewInputs;
|
||||
vmesa->setupNewInputs = 0;
|
||||
|
||||
if (!newinputs)
|
||||
return;
|
||||
if (newinputs & VERT_BIT_CLIP) {
|
||||
|
||||
if (newinputs & VERT_BIT_POS) {
|
||||
setup_tab[vmesa->setupIndex].emit(ctx, start, count, v, stride);
|
||||
}
|
||||
else {
|
||||
@@ -307,14 +306,13 @@ void viaBuildVertices(GLcontext *ctx,
|
||||
setup_tab[ind].emit(ctx, start, count, v, stride);
|
||||
}
|
||||
}
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
void viaChooseVertexState(GLcontext *ctx) {
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
GLuint ind = VIA_XYZW_BIT | VIA_RGBA_BIT;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
||||
ind |= VIA_SPEC_BIT;
|
||||
|
||||
@@ -327,7 +325,7 @@ void viaChooseVertexState(GLcontext *ctx) {
|
||||
ind |= VIA_TEX0_BIT;
|
||||
|
||||
vmesa->setupIndex = ind;
|
||||
if (VIA_DEBUG) fprintf(stderr, "setupIndex = %x\n", vmesa->setupIndex);
|
||||
viaPrintSetupFlags(__FUNCTION__, ind);
|
||||
|
||||
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
|
||||
tnl->Driver.Render.Interp = via_interp_extras;
|
||||
@@ -335,30 +333,29 @@ void viaChooseVertexState(GLcontext *ctx) {
|
||||
}
|
||||
else {
|
||||
tnl->Driver.Render.Interp = setup_tab[ind].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[ind].copyPv;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
|
||||
}
|
||||
|
||||
vmesa->vertexSize = setup_tab[ind].vertexSize;
|
||||
vmesa->vertexStrideShift = setup_tab[ind].vertexStrideShift;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
|
||||
vmesa->vertexSize = setup_tab[ind].vertex_size;
|
||||
vmesa->vertexFormat = setup_tab[ind].vertex_format;
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s, size %d\n", __FUNCTION__, vmesa->vertexSize);
|
||||
}
|
||||
|
||||
void via_emit_contiguous_verts(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count) {
|
||||
void *via_emit_contiguous_verts(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
void *dest)
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
GLuint vertexSize = vmesa->vertexSize * 4;
|
||||
GLuint *dest = viaCheckDma(vmesa, (count - start) * vertexSize);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
|
||||
if (VIA_DEBUG) fprintf(stderr, "choose setup_tab[0x%x]\n", vmesa->setupIndex);
|
||||
setup_tab[vmesa->setupIndex].emit(ctx, start, count, dest, vertexSize);
|
||||
vmesa->dmaLow += (count - start) * vertexSize;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
GLuint stride = vmesa->vertexSize * 4;
|
||||
setup_tab[vmesa->setupIndex].emit(ctx, start, count, dest, stride);
|
||||
return (void *)((char *)dest + (count - start) * stride);
|
||||
}
|
||||
|
||||
void viaInitVB(GLcontext *ctx) {
|
||||
|
||||
void viaInitVB(GLcontext *ctx)
|
||||
{
|
||||
viaContextPtr vmesa = VIA_CONTEXT(ctx);
|
||||
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
|
||||
|
||||
@@ -380,14 +377,4 @@ void viaFreeVB(GLcontext *ctx) {
|
||||
ALIGN_FREE(vmesa->verts);
|
||||
vmesa->verts = 0;
|
||||
}
|
||||
|
||||
if (vmesa->UbyteSecondaryColor.Ptr) {
|
||||
ALIGN_FREE((void*)vmesa->UbyteSecondaryColor.Ptr);
|
||||
vmesa->UbyteSecondaryColor.Ptr = 0;
|
||||
}
|
||||
|
||||
if (vmesa->UbyteColor.Ptr) {
|
||||
ALIGN_FREE((void*)vmesa->UbyteColor.Ptr);
|
||||
vmesa->UbyteColor.Ptr = 0;
|
||||
}
|
||||
}
|
||||
|
@@ -52,9 +52,10 @@ extern void viaBuildVertices(GLcontext *ctx,
|
||||
GLuint newinputs);
|
||||
|
||||
|
||||
extern void via_emit_contiguous_verts(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count);
|
||||
extern void *via_emit_contiguous_verts(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
void *dest);
|
||||
|
||||
extern void via_translate_vertex(GLcontext *ctx,
|
||||
const viaVertex *src,
|
||||
|
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* 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, 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
|
||||
* VIA, S3 GRAPHICS, 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.
|
||||
*/
|
||||
|
||||
|
||||
#define CLIP_DOTPROD(K, A, B, C, D) X(K) * A + Y(K) * B + Z(K) * C + W(K) * D
|
||||
|
||||
#define POLY_CLIP(PLANE, A, B, C, D) \
|
||||
do { \
|
||||
if (mask & PLANE) { \
|
||||
GLuint idxPrev = inlist[0]; \
|
||||
GLfloat dpPrev = CLIP_DOTPROD(idxPrev, A, B, C, D); \
|
||||
GLuint outcount = 0; \
|
||||
GLuint i; \
|
||||
\
|
||||
inlist[n] = inlist[0]; /* prevent rotation of vertices */ \
|
||||
for (i = 1; i <= n; i++) { \
|
||||
GLuint idx = inlist[i]; \
|
||||
GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D); \
|
||||
\
|
||||
clipmask[idxPrev] |= PLANE; \
|
||||
if (!NEGATIVE(dpPrev)) { \
|
||||
outlist[outcount++] = idxPrev; \
|
||||
clipmask[idxPrev] &= ~PLANE; \
|
||||
} \
|
||||
\
|
||||
if (DIFFERENT_SIGNS(dp, dpPrev)) { \
|
||||
GLuint newvert = VB->LastClipped++; \
|
||||
VB->ClipMask[newvert] = 0; \
|
||||
outlist[outcount++] = newvert; \
|
||||
if (NEGATIVE(dp)) { \
|
||||
/* Going out of bounds. Avoid division by zero as we \
|
||||
* know dp != dpPrev from DIFFERENT_SIGNS, above. \
|
||||
*/ \
|
||||
GLfloat t = dp / (dp - dpPrev); \
|
||||
INTERP_4F(t, coord[newvert], coord[idx], coord[idxPrev]); \
|
||||
interp(ctx, t, newvert, idx, idxPrev, GL_TRUE); \
|
||||
} \
|
||||
else { \
|
||||
/* Coming back in. \
|
||||
*/ \
|
||||
GLfloat t = dpPrev / (dpPrev - dp); \
|
||||
INTERP_4F(t, coord[newvert], coord[idxPrev], coord[idx]); \
|
||||
interp(ctx, t, newvert, idxPrev, idx, GL_FALSE); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
idxPrev = idx; \
|
||||
dpPrev = dp; \
|
||||
} \
|
||||
\
|
||||
if (outcount < 3) \
|
||||
return; \
|
||||
\
|
||||
{ \
|
||||
GLuint *tmp = inlist; \
|
||||
inlist = outlist; \
|
||||
outlist = tmp; \
|
||||
n = outcount; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LINE_CLIP(PLANE, A, B, C, D) \
|
||||
do { \
|
||||
if (mask & PLANE) { \
|
||||
GLfloat dpI = CLIP_DOTPROD(ii, A, B, C, D); \
|
||||
GLfloat dpJ = CLIP_DOTPROD(jj, A, B, C, D); \
|
||||
\
|
||||
if (DIFFERENT_SIGNS(dpI, dpJ)) { \
|
||||
GLuint newvert = VB->LastClipped++; \
|
||||
VB->ClipMask[newvert] = 0; \
|
||||
if (NEGATIVE(dpJ)) { \
|
||||
GLfloat t = dpI / (dpI - dpJ); \
|
||||
VB->ClipMask[jj] |= PLANE; \
|
||||
INTERP_4F(t, coord[newvert], coord[ii], coord[jj]); \
|
||||
interp(ctx, t, newvert, ii, jj, GL_FALSE); \
|
||||
jj = newvert; \
|
||||
} \
|
||||
else { \
|
||||
GLfloat t = dpJ / (dpJ - dpI); \
|
||||
VB->ClipMask[ii] |= PLANE; \
|
||||
INTERP_4F(t, coord[newvert], coord[jj], coord[ii]); \
|
||||
interp(ctx, t, newvert, jj, ii, GL_FALSE); \
|
||||
ii = newvert; \
|
||||
} \
|
||||
} \
|
||||
else if (NEGATIVE(dpI)) \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Clip a line against the viewport and user clip planes.
|
||||
*/
|
||||
static INLINE void
|
||||
TAG(clip_line)(GLcontext *ctx, GLuint i, GLuint j, GLubyte mask)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
tnl_interp_func interp = tnl->Driver.Render.Interp;
|
||||
GLfloat (*coord)[4] = VB->ClipPtr->data;
|
||||
GLuint ii = i, jj = j, p;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
VB->LastClipped = VB->Count;
|
||||
|
||||
if (mask & 0x3f) {
|
||||
LINE_CLIP(CLIP_RIGHT_BIT, -1, 0, 0, 1);
|
||||
LINE_CLIP(CLIP_LEFT_BIT, 1, 0, 0, 1);
|
||||
LINE_CLIP(CLIP_TOP_BIT, 0, -1, 0, 1);
|
||||
LINE_CLIP(CLIP_BOTTOM_BIT, 0, 1, 0, 1);
|
||||
LINE_CLIP(CLIP_FAR_BIT, 0, 0, -1, 1);
|
||||
LINE_CLIP(CLIP_NEAR_BIT, 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
if (mask & CLIP_USER_BIT) {
|
||||
for (p = 0; p < MAX_CLIP_PLANES; p++) {
|
||||
if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
|
||||
GLfloat a = ctx->Transform._ClipUserPlane[p][0];
|
||||
GLfloat b = ctx->Transform._ClipUserPlane[p][1];
|
||||
GLfloat c = ctx->Transform._ClipUserPlane[p][2];
|
||||
GLfloat d = ctx->Transform._ClipUserPlane[p][3];
|
||||
LINE_CLIP(CLIP_USER_BIT, a, b, c, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((ctx->_TriangleCaps & DD_FLATSHADE) && j != jj)
|
||||
tnl->Driver.Render.CopyPV(ctx, jj, j);
|
||||
|
||||
tnl->Driver.Render.ClippedLine(ctx, ii, jj);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
/* Clip a triangle against the viewport and user clip planes.
|
||||
*/
|
||||
static INLINE void
|
||||
TAG(clip_tri)(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
tnl_interp_func interp = tnl->Driver.Render.Interp;
|
||||
GLfloat (*coord)[4] = VB->ClipPtr->data;
|
||||
GLuint pv = v2;
|
||||
GLuint vlist[2][MAX_CLIPPED_VERTICES];
|
||||
GLuint *inlist = vlist[0], *outlist = vlist[1];
|
||||
GLuint p;
|
||||
GLubyte *clipmask = VB->ClipMask;
|
||||
GLuint n = 3;
|
||||
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
ASSIGN_3V(inlist, v2, v0, v1); /* pv rotated to slot zero */
|
||||
|
||||
VB->LastClipped = VB->Count;
|
||||
|
||||
if (mask & 0x3f) {
|
||||
POLY_CLIP(CLIP_RIGHT_BIT, -1, 0, 0, 1);
|
||||
POLY_CLIP(CLIP_LEFT_BIT, 1, 0, 0, 1);
|
||||
POLY_CLIP(CLIP_TOP_BIT, 0, -1, 0, 1);
|
||||
POLY_CLIP(CLIP_BOTTOM_BIT, 0, 1, 0, 1);
|
||||
POLY_CLIP(CLIP_FAR_BIT, 0, 0, -1, 1);
|
||||
POLY_CLIP(CLIP_NEAR_BIT, 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
if (mask & CLIP_USER_BIT) {
|
||||
for (p = 0; p < MAX_CLIP_PLANES; p++) {
|
||||
if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
|
||||
GLfloat a = ctx->Transform._ClipUserPlane[p][0];
|
||||
GLfloat b = ctx->Transform._ClipUserPlane[p][1];
|
||||
GLfloat c = ctx->Transform._ClipUserPlane[p][2];
|
||||
GLfloat d = ctx->Transform._ClipUserPlane[p][3];
|
||||
POLY_CLIP(CLIP_USER_BIT, a, b, c, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
if (pv != inlist[0]) {
|
||||
ASSERT(inlist[0] >= VB->Count);
|
||||
tnl->Driver.Render.CopyPV(ctx, inlist[0], pv);
|
||||
}
|
||||
}
|
||||
|
||||
tnl->Driver.Render.ClippedPolygon(ctx, inlist, n);
|
||||
}
|
||||
|
||||
|
||||
/* Clip a quad against the viewport and user clip planes.
|
||||
*/
|
||||
static INLINE void
|
||||
TAG(clip_quad)(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
|
||||
GLubyte mask)
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
tnl_interp_func interp = tnl->Driver.Render.Interp;
|
||||
GLfloat (*coord)[4] = VB->ClipPtr->data;
|
||||
GLuint pv = v3;
|
||||
GLuint vlist[2][MAX_CLIPPED_VERTICES];
|
||||
GLuint *inlist = vlist[0], *outlist = vlist[1];
|
||||
GLuint p;
|
||||
GLubyte *clipmask = VB->ClipMask;
|
||||
GLuint n = 4;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
ASSIGN_4V(inlist, v3, v0, v1, v2); /* pv rotated to slot zero */
|
||||
|
||||
VB->LastClipped = VB->Count;
|
||||
|
||||
if (mask & 0x3f) {
|
||||
POLY_CLIP(CLIP_RIGHT_BIT, -1, 0, 0, 1);
|
||||
POLY_CLIP(CLIP_LEFT_BIT, 1, 0, 0, 1);
|
||||
POLY_CLIP(CLIP_TOP_BIT, 0, -1, 0, 1);
|
||||
POLY_CLIP(CLIP_BOTTOM_BIT, 0, 1, 0, 1);
|
||||
POLY_CLIP(CLIP_FAR_BIT, 0, 0, -1, 1);
|
||||
POLY_CLIP(CLIP_NEAR_BIT, 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
if (mask & CLIP_USER_BIT) {
|
||||
for (p = 0; p < MAX_CLIP_PLANES; p++) {
|
||||
if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
|
||||
GLfloat a = ctx->Transform._ClipUserPlane[p][0];
|
||||
GLfloat b = ctx->Transform._ClipUserPlane[p][1];
|
||||
GLfloat c = ctx->Transform._ClipUserPlane[p][2];
|
||||
GLfloat d = ctx->Transform._ClipUserPlane[p][3];
|
||||
POLY_CLIP(CLIP_USER_BIT, a, b, c, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
||||
if (pv != inlist[0]) {
|
||||
ASSERT(inlist[0] >= VB->Count);
|
||||
tnl->Driver.Render.CopyPV(ctx, inlist[0], pv);
|
||||
}
|
||||
}
|
||||
|
||||
tnl->Driver.Render.ClippedPolygon(ctx, inlist, n);
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
#undef W
|
||||
#undef Z
|
||||
#undef Y
|
||||
#undef X
|
||||
#undef SIZE
|
||||
#undef TAG
|
||||
#undef POLY_CLIP
|
||||
#undef LINE_CLIP
|
@@ -1,474 +0,0 @@
|
||||
/*
|
||||
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
|
||||
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* 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, 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
|
||||
* VIA, S3 GRAPHICS, 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 POSTFIX
|
||||
#define POSTFIX
|
||||
#endif
|
||||
|
||||
#ifndef INIT
|
||||
#define INIT(x)
|
||||
#endif
|
||||
|
||||
#ifndef NEED_EDGEFLAG_SETUP
|
||||
#define NEED_EDGEFLAG_SETUP 0
|
||||
#define EDGEFLAG_GET(a) 0
|
||||
#define EDGEFLAG_SET(a,b) (void)b
|
||||
#endif
|
||||
|
||||
#ifndef RESET_STIPPLE
|
||||
#define RESET_STIPPLE
|
||||
#endif
|
||||
|
||||
#ifndef RESET_OCCLUSION
|
||||
#define RESET_OCCLUSION
|
||||
#endif
|
||||
|
||||
#ifndef TEST_PRIM_END
|
||||
#define TEST_PRIM_END(flags) (flags & PRIM_END)
|
||||
#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
|
||||
#define TEST_PRIM_PARITY(flags) (flags & PRIM_PARITY)
|
||||
#endif
|
||||
|
||||
#ifndef ELT
|
||||
#define ELT(x) x
|
||||
#endif
|
||||
|
||||
#ifndef RENDER_TAB_QUALIFIER
|
||||
#define RENDER_TAB_QUALIFIER static
|
||||
#endif
|
||||
|
||||
static void TAG(render_points)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
|
||||
RESET_OCCLUSION;
|
||||
INIT(GL_POINTS);
|
||||
RENDER_POINTS(start, count);
|
||||
POSTFIX;
|
||||
}
|
||||
|
||||
static void TAG(render_lines)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
RESET_OCCLUSION;
|
||||
INIT(GL_LINES);
|
||||
for (j = start + 1; j < count; j += 2) {
|
||||
RESET_STIPPLE;
|
||||
RENDER_LINE(ELT(j - 1), ELT(j));
|
||||
}
|
||||
POSTFIX;
|
||||
}
|
||||
|
||||
static void TAG(render_line_strip)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
RESET_OCCLUSION;
|
||||
INIT(GL_LINES);
|
||||
|
||||
if (TEST_PRIM_BEGIN(flags)) {
|
||||
RESET_STIPPLE;
|
||||
}
|
||||
|
||||
for (j = start + 1; j < count; j++)
|
||||
RENDER_LINE(ELT(j - 1), ELT(j));
|
||||
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_line_loop)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint i;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
RESET_OCCLUSION;
|
||||
INIT(GL_LINES);
|
||||
|
||||
if (start + 1 < count) {
|
||||
if (TEST_PRIM_BEGIN(flags)) {
|
||||
RESET_STIPPLE;
|
||||
RENDER_LINE(ELT(start), ELT(start + 1));
|
||||
}
|
||||
|
||||
for (i = start + 2 ; i < count ; i++) {
|
||||
RENDER_LINE(ELT(i - 1), ELT(i));
|
||||
}
|
||||
|
||||
if (TEST_PRIM_END(flags)) {
|
||||
RENDER_LINE(ELT(count - 1), ELT(start));
|
||||
}
|
||||
}
|
||||
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_triangles)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
if (NEED_EDGEFLAG_SETUP) {
|
||||
for (j = start + 2; j < count; j += 3) {
|
||||
/* Leave the edgeflags as supplied by the user.
|
||||
*/
|
||||
RESET_STIPPLE;
|
||||
RENDER_TRI(ELT(j - 2), ELT(j - 1), ELT(j));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (j = start + 2; j < count; j += 3) {
|
||||
RENDER_TRI(ELT(j - 2), ELT(j - 1), ELT(j));
|
||||
}
|
||||
}
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_tri_strip)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
GLuint parity = 0;
|
||||
LOCAL_VARS;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
|
||||
if (NEED_EDGEFLAG_SETUP) {
|
||||
for (j = start + 2; j < count; j++, parity ^= 1) {
|
||||
GLuint ej2 = ELT(j - 2 + parity);
|
||||
GLuint ej1 = ELT(j - 1 - parity);
|
||||
GLuint ej = ELT(j);
|
||||
GLboolean ef2 = EDGEFLAG_GET(ej2);
|
||||
GLboolean ef1 = EDGEFLAG_GET(ej1);
|
||||
GLboolean ef = EDGEFLAG_GET(ej);
|
||||
if (TEST_PRIM_BEGIN(flags)) {
|
||||
RESET_STIPPLE;
|
||||
}
|
||||
EDGEFLAG_SET(ej2, GL_TRUE);
|
||||
EDGEFLAG_SET(ej1, GL_TRUE);
|
||||
EDGEFLAG_SET(ej, GL_TRUE);
|
||||
RENDER_TRI(ej2, ej1, ej);
|
||||
EDGEFLAG_SET(ej2, ef2);
|
||||
EDGEFLAG_SET(ej1, ef1);
|
||||
EDGEFLAG_SET(ej, ef);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (j = start + 2; j < count; j++, parity ^= 1) {
|
||||
RENDER_TRI(ELT(j - 2 + parity), ELT(j - 1 - parity), ELT(j));
|
||||
}
|
||||
}
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_tri_fan)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
if (NEED_EDGEFLAG_SETUP) {
|
||||
for (j = start + 2; j < count; j++) {
|
||||
/* For trifans, all edges are boundary.
|
||||
*/
|
||||
GLuint ejs = ELT(start);
|
||||
GLuint ej1 = ELT(j - 1);
|
||||
GLuint ej = ELT(j);
|
||||
GLboolean efs = EDGEFLAG_GET(ejs);
|
||||
GLboolean ef1 = EDGEFLAG_GET(ej1);
|
||||
GLboolean ef = EDGEFLAG_GET(ej);
|
||||
if (TEST_PRIM_BEGIN(flags)) {
|
||||
RESET_STIPPLE;
|
||||
}
|
||||
EDGEFLAG_SET(ejs, GL_TRUE);
|
||||
EDGEFLAG_SET(ej1, GL_TRUE);
|
||||
EDGEFLAG_SET(ej, GL_TRUE);
|
||||
RENDER_TRI(ejs, ej1, ej);
|
||||
EDGEFLAG_SET(ejs, efs);
|
||||
EDGEFLAG_SET(ej1, ef1);
|
||||
EDGEFLAG_SET(ej, ef);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (j = start + 2; j < count; j++) {
|
||||
RENDER_TRI(ELT(start), ELT(j - 1), ELT(j));
|
||||
}
|
||||
}
|
||||
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_poly)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j = start + 2;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
|
||||
if (NEED_EDGEFLAG_SETUP) {
|
||||
GLboolean efstart = EDGEFLAG_GET(ELT(start));
|
||||
GLboolean efcount = EDGEFLAG_GET(ELT(count - 1));
|
||||
|
||||
/* If the primitive does not begin here, the first edge
|
||||
* is non-boundary.
|
||||
*/
|
||||
if (!TEST_PRIM_BEGIN(flags)) {
|
||||
EDGEFLAG_SET(ELT(start), GL_FALSE);
|
||||
}
|
||||
else {
|
||||
RESET_STIPPLE;
|
||||
}
|
||||
|
||||
/* If the primitive does not end here, the final edge is
|
||||
* non-boundary.
|
||||
*/
|
||||
if (!TEST_PRIM_END(flags)) {
|
||||
EDGEFLAG_SET(ELT(count - 1), GL_FALSE);
|
||||
}
|
||||
|
||||
/* Draw the first triangles (possibly zero)
|
||||
*/
|
||||
if (j+1<count) {
|
||||
GLboolean ef = EDGEFLAG_GET(ELT(j));
|
||||
EDGEFLAG_SET(ELT(j), GL_FALSE);
|
||||
RENDER_TRI(ELT(j - 1), ELT(j), ELT(start));
|
||||
EDGEFLAG_SET(ELT(j), ef);
|
||||
j++;
|
||||
|
||||
/* Don't render the first edge again:
|
||||
*/
|
||||
EDGEFLAG_SET(ELT(start), GL_FALSE);
|
||||
|
||||
for (;j+1<count;j++) {
|
||||
GLboolean efj = EDGEFLAG_GET(ELT(j));
|
||||
EDGEFLAG_SET(ELT(j), GL_FALSE);
|
||||
RENDER_TRI(ELT(j - 1), ELT(j), ELT(start));
|
||||
EDGEFLAG_SET(ELT(j), efj);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the last or only triangle
|
||||
*/
|
||||
if (j < count) {
|
||||
RENDER_TRI(ELT(j-1), ELT(j), ELT(start));
|
||||
}
|
||||
|
||||
/* Restore the first and last edgeflags:
|
||||
*/
|
||||
EDGEFLAG_SET(ELT(count - 1), efcount);
|
||||
EDGEFLAG_SET(ELT(start), efstart);
|
||||
}
|
||||
else {
|
||||
for (j = start + 2; j < count; j++) {
|
||||
RENDER_TRI(ELT(j - 1), ELT(j), ELT(start));
|
||||
}
|
||||
}
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_quads)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
if (NEED_EDGEFLAG_SETUP) {
|
||||
for (j = start + 3; j < count; j += 4) {
|
||||
/* Use user-specified edgeflags for quads.
|
||||
*/
|
||||
RESET_STIPPLE;
|
||||
RENDER_QUAD(ELT(j - 3), ELT(j - 2), ELT(j - 1), ELT(j));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (j = start + 3; j < count; j += 4) {
|
||||
RENDER_QUAD(ELT(j - 3), ELT(j - 2), ELT(j - 1), ELT(j));
|
||||
}
|
||||
}
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_quad_strip)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
GLuint j;
|
||||
LOCAL_VARS;
|
||||
(void)flags;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#ifdef PERFORMANCE_MEASURE
|
||||
if (VIA_PERFORMANCE) P_M;
|
||||
#endif
|
||||
INIT(GL_TRIANGLES);
|
||||
if (NEED_EDGEFLAG_SETUP) {
|
||||
for (j = start + 3; j < count; j += 2) {
|
||||
/* All edges are boundary. Set edgeflags to 1, draw the
|
||||
* quad, and restore them to the original values.
|
||||
*/
|
||||
GLboolean ef3 = EDGEFLAG_GET(ELT(j - 3));
|
||||
GLboolean ef2 = EDGEFLAG_GET(ELT(j - 2));
|
||||
GLboolean ef1 = EDGEFLAG_GET(ELT(j - 1));
|
||||
GLboolean ef = EDGEFLAG_GET(ELT(j));
|
||||
if (TEST_PRIM_BEGIN(flags)) {
|
||||
RESET_STIPPLE;
|
||||
}
|
||||
EDGEFLAG_SET(ELT(j - 3), GL_TRUE);
|
||||
EDGEFLAG_SET(ELT(j - 2), GL_TRUE);
|
||||
EDGEFLAG_SET(ELT(j - 1), GL_TRUE);
|
||||
EDGEFLAG_SET(ELT(j), GL_TRUE);
|
||||
RENDER_QUAD(ELT(j - 1), ELT(j - 3), ELT(j - 2), ELT(j));
|
||||
EDGEFLAG_SET(ELT(j - 3), ef3);
|
||||
EDGEFLAG_SET(ELT(j - 2), ef2);
|
||||
EDGEFLAG_SET(ELT(j - 1), ef1);
|
||||
EDGEFLAG_SET(ELT(j), ef);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (j = start + 3; j < count; j += 2) {
|
||||
RENDER_QUAD(ELT(j - 1), ELT(j - 3), ELT(j - 2), ELT(j));
|
||||
}
|
||||
}
|
||||
POSTFIX;
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
static void TAG(render_noop)(GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags)
|
||||
{
|
||||
(void)(ctx && start && count && flags);
|
||||
}
|
||||
|
||||
RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON + 2])(GLcontext *,
|
||||
GLuint,
|
||||
GLuint,
|
||||
GLuint) =
|
||||
{
|
||||
TAG(render_points),
|
||||
TAG(render_lines),
|
||||
TAG(render_line_loop),
|
||||
TAG(render_line_strip),
|
||||
TAG(render_triangles),
|
||||
TAG(render_tri_strip),
|
||||
TAG(render_tri_fan),
|
||||
TAG(render_quads),
|
||||
TAG(render_quad_strip),
|
||||
TAG(render_poly),
|
||||
TAG(render_noop),
|
||||
};
|
||||
|
||||
#ifndef PRESERVE_VB_DEFS
|
||||
#undef RENDER_TRI
|
||||
#undef RENDER_QUAD
|
||||
#undef RENDER_LINE
|
||||
#undef RENDER_POINTS
|
||||
#undef LOCAL_VARS
|
||||
#undef INIT
|
||||
#undef POSTFIX
|
||||
#undef RESET_STIPPLE
|
||||
#undef DBG
|
||||
#undef ELT
|
||||
#undef RENDER_TAB_QUALIFIER
|
||||
#endif
|
||||
|
||||
#ifndef PRESERVE_TAG
|
||||
#undef TAG
|
||||
#endif
|
||||
|
||||
#undef PRESERVE_VB_DEFS
|
||||
#undef PRESERVE_TAG
|
@@ -56,6 +56,10 @@ class PrintGlxProtoStubs(glX_XML.GlxProto):
|
||||
glX_XML.printFastcall()
|
||||
glX_XML.printNoinline()
|
||||
print ''
|
||||
print '#if !defined __GNUC__ || __GNUC__ < 3'
|
||||
print '# define __builtin_expect(x, y) x'
|
||||
print '#endif'
|
||||
print ''
|
||||
print '/* If the size and opcode values are known at compile-time, this will, on'
|
||||
print ' * x86 at least, emit them with a single instruction.'
|
||||
print ' */'
|
||||
@@ -71,13 +75,13 @@ read_reply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_ar
|
||||
|
||||
(void) _XReply(dpy, (xReply *) & reply, 0, False);
|
||||
if (size != 0) {
|
||||
if ((reply.size >= 1) || reply_is_always_array) {
|
||||
if ((reply.length > 0) || reply_is_always_array) {
|
||||
const GLint bytes = (reply_is_always_array)
|
||||
? (4 * reply.length) : (reply.size * size);
|
||||
const GLint extra = 4 - (bytes & 3);
|
||||
|
||||
_XRead(dpy, dest, bytes);
|
||||
if ( extra != 0 ) {
|
||||
if ( extra < 4 ) {
|
||||
_XEatData(dpy, extra);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +95,7 @@ read_reply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_ar
|
||||
|
||||
#define X_GLXSingle 0
|
||||
|
||||
static NOINLINE GLubyte *
|
||||
static NOINLINE FASTCALL GLubyte *
|
||||
setup_single_request( __GLXcontext * gc, GLint sop, GLint cmdlen )
|
||||
{
|
||||
xGLXSingleReq * req;
|
||||
@@ -106,7 +110,7 @@ setup_single_request( __GLXcontext * gc, GLint sop, GLint cmdlen )
|
||||
return (GLubyte *)(req) + sz_xGLXSingleReq;
|
||||
}
|
||||
|
||||
static NOINLINE GLubyte *
|
||||
static NOINLINE FASTCALL GLubyte *
|
||||
setup_vendor_request( __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen )
|
||||
{
|
||||
xGLXVendorPrivateReq * req;
|
||||
@@ -147,7 +151,7 @@ generic_%u_byte( GLint rop, const void * ptr )
|
||||
emit_header(gc->pc, rop, cmdlen);
|
||||
(void) memcpy((void *)(gc->pc + 4), ptr, %u);
|
||||
gc->pc += cmdlen;
|
||||
if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
|
||||
if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
|
||||
}
|
||||
""" % (n, n + 4, n)
|
||||
|
||||
@@ -189,8 +193,22 @@ generic_%u_byte( GLint rop, const void * ptr )
|
||||
self.common_func_print_just_header(f)
|
||||
|
||||
print ' __GLXcontext * const gc = __glXGetCurrentContext();'
|
||||
print ' Display * const dpy = gc->currentDpy;'
|
||||
|
||||
|
||||
# The only reason that single and vendor private commands need
|
||||
# a variable called 'dpy' is becuase they use the SyncHandle
|
||||
# macro. For whatever brain-dead reason, that macro is hard-
|
||||
# coded to use a variable called 'dpy' instead of taking a
|
||||
# parameter.
|
||||
|
||||
if not f.glx_rop:
|
||||
print ' Display * const dpy = gc->currentDpy;'
|
||||
skip_condition = "dpy != NULL"
|
||||
elif f.can_be_large:
|
||||
skip_condition = "gc->currentDpy != NULL"
|
||||
else:
|
||||
skip_condition = None
|
||||
|
||||
|
||||
if f.fn_return_type != 'void':
|
||||
print ' %s retval = (%s) 0;' % (f.fn_return_type, f.fn_return_type)
|
||||
|
||||
@@ -199,26 +217,23 @@ generic_%u_byte( GLint rop, const void * ptr )
|
||||
|
||||
print ' const GLuint cmdlen = %s;' % (f.command_length())
|
||||
|
||||
if f.counter != None:
|
||||
print ' if (%s < 0) %s' % (f.counter, f.return_string())
|
||||
if f.counter:
|
||||
if skip_condition:
|
||||
skip_condition = "(%s >= 0) && (%s)" % (f.counter, skip_condition)
|
||||
else:
|
||||
skip_condition = "%s >= 0" % (f.counter)
|
||||
|
||||
if f.can_be_large:
|
||||
print ' if (dpy == NULL) return;'
|
||||
print ' if ( ((gc->pc + cmdlen) > gc->bufEnd)'
|
||||
print ' || (cmdlen > gc->maxSmallRenderCommandSize)) {'
|
||||
print ' (void) __glXFlushRenderBuffer(gc, gc->pc);'
|
||||
print ' }'
|
||||
|
||||
if skip_condition:
|
||||
print ' if (__builtin_expect(%s, 1)) {' % (skip_condition)
|
||||
return 1
|
||||
else:
|
||||
print ' (void) dpy;'
|
||||
|
||||
return
|
||||
return 0
|
||||
|
||||
|
||||
def printSingleFunction(self, f):
|
||||
self.common_func_print_header(f)
|
||||
|
||||
print ' if (dpy != NULL) {'
|
||||
|
||||
if f.fn_parameters != []:
|
||||
pc_decl = "GLubyte const * pc ="
|
||||
else:
|
||||
@@ -249,9 +264,9 @@ generic_%u_byte( GLint rop, const void * ptr )
|
||||
else:
|
||||
aa = "GL_FALSE"
|
||||
|
||||
print " %s read_reply(gc->currentDpy, %s, %s, %s);" % (return_str, output_size, output_str, aa)
|
||||
print " %s read_reply(dpy, %s, %s, %s);" % (return_str, output_size, output_str, aa)
|
||||
|
||||
print ' UnlockDisplay(gc->currentDpy); SyncHandle();'
|
||||
print ' UnlockDisplay(dpy); SyncHandle();'
|
||||
print ' }'
|
||||
print ' %s' % f.return_string()
|
||||
print '}'
|
||||
@@ -278,33 +293,41 @@ generic_%u_byte( GLint rop, const void * ptr )
|
||||
print ''
|
||||
return
|
||||
|
||||
self.common_func_print_header(f)
|
||||
|
||||
if f.can_be_large:
|
||||
print ' if (cmdlen <= gc->maxSmallRenderCommandSize) {'
|
||||
if self.common_func_print_header(f):
|
||||
indent = " "
|
||||
trailer = " }"
|
||||
else:
|
||||
indent = ""
|
||||
trailer = None
|
||||
|
||||
if f.can_be_large:
|
||||
print '%s if (cmdlen <= gc->maxSmallRenderCommandSize) {' % (indent)
|
||||
print '%s if ( (gc->pc + cmdlen) > gc->bufEnd ) {' % (indent)
|
||||
print '%s (void) __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
|
||||
print '%s }' % (indent)
|
||||
indent += " "
|
||||
|
||||
print '%s emit_header(gc->pc, %s, cmdlen);' % (indent, f.opcode_real_name())
|
||||
|
||||
self.common_emit_args(f, "gc->pc", indent, 4, 0)
|
||||
print '%s gc->pc += cmdlen;' % (indent)
|
||||
print '%s if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' % (indent)
|
||||
print '%s if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' % (indent)
|
||||
|
||||
if f.can_be_large:
|
||||
print ' }'
|
||||
print ' else {'
|
||||
print ' const GLint op = %s;' % (f.opcode_real_name())
|
||||
print ' const GLuint cmdlenLarge = cmdlen + 4;'
|
||||
print ' (void) memcpy((void *)(gc->pc + 0), (void *)(&op), 4);'
|
||||
print ' (void) memcpy((void *)(gc->pc + 4), (void *)(&cmdlenLarge), 4);'
|
||||
offset = self.common_emit_args(f, "gc->pc", indent, 8, 1)
|
||||
print '%s}' % (indent)
|
||||
print '%selse {' % (indent)
|
||||
print '%s const GLint op = %s;' % (indent, f.opcode_real_name())
|
||||
print '%s const GLuint cmdlenLarge = cmdlen + 4;' % (indent)
|
||||
print '%s GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
|
||||
print '%s (void) memcpy((void *)(pc + 0), (void *)(&op), 4);' % (indent)
|
||||
print '%s (void) memcpy((void *)(pc + 4), (void *)(&cmdlenLarge), 4);' % (indent)
|
||||
offset = self.common_emit_args(f, "pc", indent, 8, 1)
|
||||
|
||||
p = f.variable_length_parameter()
|
||||
print ' __glXSendLargeCommand(gc, gc->pc, %u, %s, %s);' % (offset + 8, p.name, p.size_string())
|
||||
print ' }'
|
||||
print '%s __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (indent, offset + 8, p.name, p.size_string())
|
||||
print '%s}' % (indent)
|
||||
|
||||
if trailer: print trailer
|
||||
print '}'
|
||||
print ''
|
||||
return
|
||||
|
@@ -149,7 +149,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
|
||||
line.dx = line.x1 - line.x0;
|
||||
line.dy = line.y1 - line.y0;
|
||||
line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
|
||||
line.halfWidth = 0.5F * ctx->Line.Width;
|
||||
line.halfWidth = 0.5F * ctx->Line._Width;
|
||||
|
||||
if (line.len == 0.0 || IS_INF_OR_NAN(line.len))
|
||||
return;
|
||||
|
@@ -68,7 +68,7 @@ draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor )
|
||||
|
||||
ASSERT(span->end < MAX_WIDTH);
|
||||
|
||||
width = (GLint) CLAMP( ctx->Line.Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH );
|
||||
width = (GLint) CLAMP( ctx->Line._Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH );
|
||||
|
||||
if (width & 1)
|
||||
start = width / 2;
|
||||
@@ -144,7 +144,7 @@ draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor )
|
||||
span.arrayMask |= SPAN_MASK; \
|
||||
compute_stipple_mask(ctx, span.end, span.array->mask); \
|
||||
} \
|
||||
if (ctx->Line.Width > 1.0) { \
|
||||
if (ctx->Line._Width > 1.0) { \
|
||||
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
|
||||
} \
|
||||
else { \
|
||||
@@ -163,7 +163,7 @@ draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor )
|
||||
span.arrayMask |= SPAN_MASK; \
|
||||
compute_stipple_mask(ctx, span.end, span.array->mask); \
|
||||
} \
|
||||
if (ctx->Line.Width > 1.0) { \
|
||||
if (ctx->Line._Width > 1.0) { \
|
||||
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
|
||||
} \
|
||||
else { \
|
||||
@@ -183,7 +183,7 @@ draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor )
|
||||
span.arrayMask |= SPAN_MASK; \
|
||||
compute_stipple_mask(ctx, span.end, span.array->mask); \
|
||||
} \
|
||||
if (ctx->Line.Width > 1.0) { \
|
||||
if (ctx->Line._Width > 1.0) { \
|
||||
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
|
||||
} \
|
||||
else { \
|
||||
@@ -204,7 +204,7 @@ draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor )
|
||||
span.arrayMask |= SPAN_MASK; \
|
||||
compute_stipple_mask(ctx, span.end, span.array->mask); \
|
||||
} \
|
||||
if (ctx->Line.Width > 1.0) { \
|
||||
if (ctx->Line._Width > 1.0) { \
|
||||
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
|
||||
} \
|
||||
else { \
|
||||
@@ -310,7 +310,7 @@ _swrast_choose_line( GLcontext *ctx )
|
||||
USE(textured_line);
|
||||
}
|
||||
}
|
||||
else if (ctx->Depth.Test || ctx->Fog.Enabled || ctx->Line.Width != 1.0
|
||||
else if (ctx->Depth.Test || ctx->Fog.Enabled || ctx->Line._Width != 1.0
|
||||
|| ctx->Line.StippleFlag) {
|
||||
/* no texture, but Z, fog, width>1, stipple, etc. */
|
||||
if (rgbmode)
|
||||
|
@@ -246,7 +246,7 @@ _swrast_choose_point( GLcontext *ctx )
|
||||
/* textured */
|
||||
USE(textured_rgba_point);
|
||||
}
|
||||
else if (ctx->Point.Size != 1.0) {
|
||||
else if (ctx->Point._Size != 1.0) {
|
||||
/* large points */
|
||||
if (rgbMode) {
|
||||
USE(general_rgba_point);
|
||||
|
Reference in New Issue
Block a user