mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-20 04:30:22 +01:00
Initial add of some (disabled) SiS 6326 drawing code integrated from Alan Cox's
last drop I saw, which was in turn based on a code drop of mine. Texturing, culling, and several extensions are unimplemented, and some features could probably be improved. It's untested, but there don't appear to be regressions on the 300-series code, so I'd like to get these bits in now so that it can be worked on as not a huge diff.
This commit is contained in:
parent
7e4cc1c29f
commit
f1113fa99d
11 changed files with 1895 additions and 59 deletions
|
|
@ -10,6 +10,8 @@ LIBNAME = sis_dri.so
|
|||
# MINIGLX_SOURCES = server/sis_dri.c
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
sis6326_state.c \
|
||||
sis6326_clear.c \
|
||||
sis_alloc.c \
|
||||
sis_clear.c \
|
||||
sis_context.c \
|
||||
|
|
|
|||
236
src/mesa/drivers/dri/sis/sis6326_clear.c
Normal file
236
src/mesa/drivers/dri/sis/sis6326_clear.c
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* Copyright 2005 Eric Anholt
|
||||
* 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, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <anholt@FreeBSD.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sis_context.h"
|
||||
#include "sis_state.h"
|
||||
#include "sis_lock.h"
|
||||
#include "sis_reg.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "macros.h"
|
||||
|
||||
static void sis_clear_front_buffer(GLcontext *ctx, GLenum mask, GLint x,
|
||||
GLint y, GLint width, GLint height);
|
||||
static void sis_clear_back_buffer(GLcontext *ctx, GLenum mask, GLint x,
|
||||
GLint y, GLint width, GLint height);
|
||||
static void sis_clear_z_buffer(GLcontext * ctx, GLbitfield mask, GLint x,
|
||||
GLint y, GLint width, GLint height );
|
||||
|
||||
static void
|
||||
set_color_pattern( sisContextPtr smesa, GLubyte red, GLubyte green,
|
||||
GLubyte blue, GLubyte alpha )
|
||||
{
|
||||
/* XXX only RGB565 and ARGB8888 */
|
||||
switch (smesa->colorFormat)
|
||||
{
|
||||
case DST_FORMAT_ARGB_8888:
|
||||
smesa->clearColorPattern = (alpha << 24) +
|
||||
(red << 16) + (green << 8) + (blue);
|
||||
break;
|
||||
case DST_FORMAT_RGB_565:
|
||||
smesa->clearColorPattern = ((red >> 3) << 11) +
|
||||
((green >> 2) << 5) + (blue >> 3);
|
||||
smesa->clearColorPattern |= smesa->clearColorPattern << 16;
|
||||
break;
|
||||
default:
|
||||
sis_fatal_error("Bad dst color format\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sis6326UpdateZPattern(sisContextPtr smesa, GLclampd z)
|
||||
{
|
||||
smesa->clearZStencilPattern = FLOAT_TO_USHORT(z * 65535.0);
|
||||
}
|
||||
|
||||
void
|
||||
sis6326DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
GLint x, GLint y, GLint width, GLint height)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
GLint x1, y1, width1, height1;
|
||||
|
||||
if (all) {
|
||||
GLframebuffer *buffer = ctx->DrawBuffer;
|
||||
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
width1 = buffer->Width;
|
||||
height1 = buffer->Height;
|
||||
} else {
|
||||
x1 = x;
|
||||
y1 = Y_FLIP(y+height-1);
|
||||
width1 = width;
|
||||
height1 = height;
|
||||
}
|
||||
/* XXX: Scissoring */
|
||||
|
||||
fprintf(stderr, "Clear\n");
|
||||
|
||||
/* Mask out any non-existent buffers */
|
||||
if (smesa->depth.offset == 0 || !ctx->Depth.Mask)
|
||||
mask &= ~BUFFER_BIT_DEPTH;
|
||||
|
||||
LOCK_HARDWARE();
|
||||
|
||||
if (mask & BUFFER_BIT_FRONT_LEFT) {
|
||||
sis_clear_front_buffer(ctx, mask, x1, y1, width1, height1);
|
||||
mask &= ~BUFFER_BIT_FRONT_LEFT;
|
||||
}
|
||||
|
||||
if (mask & BUFFER_BIT_BACK_LEFT) {
|
||||
sis_clear_back_buffer(ctx, mask, x1, y1, width1, height1);
|
||||
mask &= ~BUFFER_BIT_BACK_LEFT;
|
||||
}
|
||||
|
||||
if (mask & BUFFER_BIT_DEPTH) {
|
||||
sis_clear_z_buffer(ctx, mask, x1, y1, width1, height1);
|
||||
mask &= ~BUFFER_BIT_DEPTH;
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE();
|
||||
|
||||
if (mask != 0)
|
||||
_swrast_Clear(ctx, mask, all, x1, y1, width, height);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sis6326DDClearColor(GLcontext *ctx, const GLfloat color[4])
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
GLubyte c[4];
|
||||
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
|
||||
|
||||
set_color_pattern( smesa, c[0], c[1], c[2], c[3] );
|
||||
}
|
||||
|
||||
void
|
||||
sis6326DDClearDepth(GLcontext *ctx, GLclampd d)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
sis6326UpdateZPattern(smesa, d);
|
||||
}
|
||||
|
||||
static void
|
||||
sis_clear_back_buffer(GLcontext *ctx, GLenum mask, GLint x, GLint y,
|
||||
GLint width, GLint height)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
/* XXX: The order of writing these registers seems to matter, while
|
||||
* it actually shouldn't.
|
||||
*/
|
||||
mWait3DCmdQueue(6);
|
||||
MMIO(REG_6326_BitBlt_DstSrcPitch, smesa->back.pitch << 16);
|
||||
MMIO(REG_6326_BitBlt_fgColor, SiS_ROP_PATCOPY |
|
||||
smesa->clearColorPattern);
|
||||
MMIO(REG_6326_BitBlt_bgColor, SiS_ROP_PATCOPY |
|
||||
smesa->clearColorPattern);
|
||||
MMIO(REG_6326_BitBlt_DstAddr, smesa->back.offset +
|
||||
(y+height) * smesa->back.pitch +
|
||||
(x+width) * smesa->bytesPerPixel);
|
||||
MMIO(REG_6326_BitBlt_HeightWidth, ((height-1) << 16) |
|
||||
(width * smesa->bytesPerPixel));
|
||||
MMIO_WMB();
|
||||
MMIO(REG_6326_BitBlt_Cmd, BLT_PAT_BG);
|
||||
}
|
||||
|
||||
static void
|
||||
sis_clear_front_buffer(GLcontext *ctx, GLenum mask, GLint x, GLint y,
|
||||
GLint width, GLint height)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
int count;
|
||||
drm_clip_rect_t *pExtents = NULL;
|
||||
|
||||
pExtents = smesa->driDrawable->pClipRects;
|
||||
count = smesa->driDrawable->numClipRects;
|
||||
|
||||
mWait3DCmdQueue(3);
|
||||
MMIO(REG_6326_BitBlt_DstSrcPitch, smesa->front.pitch << 16);
|
||||
MMIO(REG_6326_BitBlt_fgColor, SiS_ROP_PATCOPY |
|
||||
smesa->clearColorPattern);
|
||||
MMIO(REG_6326_BitBlt_bgColor, SiS_ROP_PATCOPY |
|
||||
smesa->clearColorPattern);
|
||||
|
||||
while (count--) {
|
||||
GLint x1 = pExtents->x1 - smesa->driDrawable->x;
|
||||
GLint y1 = pExtents->y1 - smesa->driDrawable->y;
|
||||
GLint x2 = pExtents->x2 - smesa->driDrawable->x;
|
||||
GLint y2 = pExtents->y2 - smesa->driDrawable->y;
|
||||
|
||||
if (x > x1)
|
||||
x1 = x;
|
||||
if (y > y1)
|
||||
y1 = y;
|
||||
|
||||
if (x + width < x2)
|
||||
x2 = x + width;
|
||||
if (y + height < y2)
|
||||
y2 = y + height;
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
pExtents++;
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
continue;
|
||||
|
||||
mWait3DCmdQueue(3);
|
||||
MMIO(REG_6326_BitBlt_DstAddr, smesa->front.offset +
|
||||
(y2-1) * smesa->front.pitch + x2 * smesa->bytesPerPixel);
|
||||
MMIO(REG_6326_BitBlt_HeightWidth, ((height-1) << 16) |
|
||||
(width * smesa->bytesPerPixel));
|
||||
MMIO_WMB();
|
||||
MMIO(REG_6326_BitBlt_Cmd, BLT_PAT_BG);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sis_clear_z_buffer(GLcontext * ctx, GLbitfield mask, GLint x, GLint y,
|
||||
GLint width, GLint height)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
mWait3DCmdQueue(6);
|
||||
MMIO(REG_6326_BitBlt_DstAddr,
|
||||
smesa->depth.offset + y * smesa->depth.pitch + x * 2);
|
||||
MMIO(REG_6326_BitBlt_DstSrcPitch, smesa->depth.pitch << 16);
|
||||
MMIO(REG_6326_BitBlt_HeightWidth, ((height-1) << 16) | (width * 2));
|
||||
MMIO(REG_6326_BitBlt_fgColor, SiS_ROP_PATCOPY | smesa->clearZStencilPattern);
|
||||
MMIO(REG_6326_BitBlt_bgColor, SiS_ROP_PATCOPY | smesa->clearZStencilPattern);
|
||||
MMIO_WMB();
|
||||
MMIO(REG_6326_BitBlt_Cmd, BLT_PAT_BG | BLT_XINC | BLT_YINC);
|
||||
}
|
||||
|
||||
408
src/mesa/drivers/dri/sis/sis6326_reg.h
Normal file
408
src/mesa/drivers/dri/sis/sis6326_reg.h
Normal file
|
|
@ -0,0 +1,408 @@
|
|||
/*
|
||||
* Copyright 2005 Eric Anholt
|
||||
* 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, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <anholt@FreeBSD.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _sis6326_reg_h_
|
||||
#define _sis6326_reg_h_
|
||||
|
||||
#define REG_6326_BitBlt_SrcAddr 0x8280
|
||||
#define REG_6326_BitBlt_DstAddr 0x8284
|
||||
#define REG_6326_BitBlt_DstSrcPitch 0x8288
|
||||
#define REG_6326_BitBlt_HeightWidth 0x828c
|
||||
#define REG_6326_BitBlt_fgColor 0x8290
|
||||
#define REG_6326_BitBlt_bgColor 0x8294
|
||||
#define REG_6326_BitBlt_Mask30 0x8298
|
||||
#define REG_6326_BitBlt_Mask74 0x829c
|
||||
#define REG_6326_BitBlt_ClipTopLeft 0x82a0
|
||||
#define REG_6326_BitBlt_ClitBottomRight 0x82a4
|
||||
#define REG_6326_BitBlt_Cmd 0x82a8
|
||||
#define REG_6326_BitBlt_Pat 0x82ac
|
||||
|
||||
#define REG_6326_3D_TSFSa 0x8800
|
||||
#define REG_6326_3D_TSZa 0x8804
|
||||
#define REG_6326_3D_TSXa 0x8808
|
||||
#define REG_6326_3D_TSYa 0x880C
|
||||
#define REG_6326_3D_TSARGBa 0x8810
|
||||
#define REG_6326_3D_TSUa 0x8814
|
||||
#define REG_6326_3D_TSVa 0x8818
|
||||
#define REG_6326_3D_TSWa 0x881C
|
||||
|
||||
#define REG_6326_3D_TSFSb 0x8820
|
||||
#define REG_6326_3D_TSZb 0x8824
|
||||
#define REG_6326_3D_TSXb 0x8828
|
||||
#define REG_6326_3D_TSYb 0x882C
|
||||
#define REG_6326_3D_TSARGBb 0x8830
|
||||
#define REG_6326_3D_TSUb 0x8834
|
||||
#define REG_6326_3D_TSVb 0x8838
|
||||
#define REG_6326_3D_TSWb 0x883C
|
||||
|
||||
#define REG_6326_3D_TSFSc 0x8840
|
||||
#define REG_6326_3D_TSZc 0x8844
|
||||
#define REG_6326_3D_TSXc 0x8848
|
||||
#define REG_6326_3D_TSYc 0x884C
|
||||
#define REG_6326_3D_TSARGBc 0x8850
|
||||
#define REG_6326_3D_TSUc 0x8854
|
||||
#define REG_6326_3D_TSVc 0x8858
|
||||
#define REG_6326_3D_TSWc 0x885C
|
||||
|
||||
#define REG_6326_3D_TEnable 0x8A00
|
||||
#define REG_6326_3D_ZSet 0x8A04
|
||||
#define REG_6326_3D_ZAddress 0x8A08
|
||||
|
||||
#define REG_6326_3D_AlphaSet 0x8A0C
|
||||
#define REG_6326_3D_AlphaAddress 0x8A10
|
||||
#define REG_6326_3D_DstSet 0x8A14
|
||||
#define REG_6326_3D_DstAddress 0x8A18
|
||||
#define REG_6326_3D_LinePattern 0x8A1C
|
||||
#define REG_6326_3D_FogSet 0x8A20
|
||||
|
||||
#define REG_6326_3D_DstSrcBlendMode 0x8A28
|
||||
|
||||
#define REG_6326_3D_ClipTopBottom 0x8A30
|
||||
#define REG_6326_3D_ClipLeftRight 0x8A34
|
||||
|
||||
#define REG_6326_3D_TextureSet 0x8A38
|
||||
#define REG_6326_3D_TextureBlendSet 0x8A3C
|
||||
/* Low transparency value is in TextureBlendSet */
|
||||
#define REG_6326_3D_TextureTransparencyColorHigh 0x8A40
|
||||
|
||||
#define REG_6326_3D_TextureAddress0 0x8A44
|
||||
#define REG_6326_3D_TextureAddress1 0x8A48
|
||||
#define REG_6326_3D_TextureAddress2 0x8A4C
|
||||
#define REG_6326_3D_TextureAddress3 0x8A50
|
||||
#define REG_6326_3D_TextureAddress4 0x8A54
|
||||
#define REG_6326_3D_TextureAddress5 0x8A58
|
||||
#define REG_6326_3D_TextureAddress6 0x8A5C
|
||||
#define REG_6326_3D_TextureAddress7 0x8A60
|
||||
#define REG_6326_3D_TextureAddress8 0x8A64
|
||||
#define REG_6326_3D_TextureAddress9 0x8A68
|
||||
|
||||
#define REG_6326_3D_TexturePitch01 0x8A6C
|
||||
#define REG_6326_3D_TexturePitch23 0x8A70
|
||||
#define REG_6326_3D_TexturePitch45 0x8A74
|
||||
#define REG_6326_3D_TexturePitch67 0x8A78
|
||||
#define REG_6326_3D_TexturePitch89 0x8A7C
|
||||
|
||||
#define REG_6326_3D_TextureWidthHeight 0x8A80
|
||||
#define REG_6326_3D_TextureBorderColor 0x8A90
|
||||
|
||||
#define REG_6326_3D_EndPrimitiveList 0x8Aff
|
||||
|
||||
/*
|
||||
* REG_6326_BitBlt_fgColor (0x8290-0x8293)
|
||||
* REG_6326_BitBlt_bgColor (0x8294-0x8297)
|
||||
*/
|
||||
#define MASK_BltRop 0xff000000
|
||||
#define MASK_BltColor 0x00ffffff
|
||||
|
||||
#define SiS_ROP_SRCCOPY 0xcc000000
|
||||
#define SiS_ROP_PATCOPY 0xf0000000
|
||||
|
||||
/*
|
||||
* REG_6326_BitBlt_Cmd (0x82a8-0x82ab)
|
||||
*/
|
||||
#define MASK_QueueStatus 0x0000ffff
|
||||
#define MASK_BltCmd0 0x00ff0000
|
||||
#define MASK_BltCmd1 0xff000000
|
||||
|
||||
#define BLT_SRC_BG 0x00000000
|
||||
#define BLT_SRC_FG 0x00010000
|
||||
#define BLT_SRC_VID 0x00020000
|
||||
#define BLT_SRC_CPU 0x00030000
|
||||
#define BLT_PAT_BG 0x00000000
|
||||
#define BLT_PAT_FG 0x00040000
|
||||
#define BLT_PAT_PAT 0x000b0000
|
||||
#define BLT_XINC 0x00100000
|
||||
#define BLT_YINC 0x00200000
|
||||
#define BLT_CLIP 0x00400000
|
||||
#define BLT_BUSY 0x04000000
|
||||
|
||||
/*
|
||||
* REG_3D_PrimitiveSet -- Define Fire Primitive Mask (89F8h-89FBh)
|
||||
*/
|
||||
#define MASK_6326_DrawPrimitiveCommand 0x00000007
|
||||
#define MASK_6326_SetFirePosition 0x00000F00
|
||||
#define MASK_6326_ShadingMode 0x001c0000
|
||||
#define MASK_6326_Direction 0x0003f000
|
||||
|
||||
/* OP_3D_{POINT,LINE,TRIANGLE}_DRAW same as 300-series */
|
||||
/* OP_3D_DIRECTION*_ same as 300-series */
|
||||
|
||||
#define OP_6326_3D_FIRE_TFIRE 0x00000000
|
||||
#define OP_6326_3D_FIRE_TSARGBa 0x00000100
|
||||
#define OP_6326_3D_FIRE_TSWa 0x00000200
|
||||
#define OP_6326_3D_FIRE_TSARGBb 0x00000300
|
||||
#define OP_6326_3D_FIRE_TSWb 0x00000400
|
||||
#define OP_6326_3D_FIRE_TSARGBc 0x00000500
|
||||
#define OP_6326_3D_FIRE_TSWc 0x00000600
|
||||
#define OP_6326_3D_FIRE_TSVc 0x00000700
|
||||
|
||||
#define OP_6326_3D_ATOP 0x00000000
|
||||
#define OP_6326_3D_BTOP 0x00010000
|
||||
#define OP_6326_3D_CTOP 0x00020000
|
||||
#define OP_6326_3D_AMID 0x00000000
|
||||
#define OP_6326_3D_BMID 0x00004000
|
||||
#define OP_6326_3D_CMID 0x00008000
|
||||
#define OP_6326_3D_ABOT 0x00000000
|
||||
#define OP_6326_3D_BBOT 0x00001000
|
||||
#define OP_6326_3D_CBOT 0x00002000
|
||||
|
||||
#define OP_6326_3D_SHADE_FLAT_TOP 0x00040000
|
||||
#define OP_6326_3D_SHADE_FLAT_MID 0x00080000
|
||||
#define OP_6326_3D_SHADE_FLAT_BOT 0x000c0000
|
||||
#define OP_6326_3D_SHADE_FLAT_GOURAUD 0x00100000
|
||||
|
||||
|
||||
/*
|
||||
* REG_6326_3D_EngineFire
|
||||
*/
|
||||
#define MASK_CmdQueueLen 0x0FFF0000
|
||||
#define ENG_3DIDLEQE 0x00000002
|
||||
#define ENG_3DIDLE 0x00000001
|
||||
|
||||
/*
|
||||
* REG_6326_3D_TEnable -- Define Capility Enable Mask (8A00h-8A03h)
|
||||
*/
|
||||
#define S_ENABLE_Dither (1 << 0)
|
||||
#define S_ENABLE_Transparency (1 << 1)
|
||||
#define S_ENABLE_Blend (1 << 2)
|
||||
#define S_ENABLE_Fog (1 << 3)
|
||||
#define S_ENABLE_Specular (1 << 4)
|
||||
#define S_ENABLE_LargeCache (1 << 5)
|
||||
#define S_ENABLE_TextureCache (1 << 7)
|
||||
#define S_ENABLE_TextureTransparency (1 << 8)
|
||||
#define S_ENABLE_TexturePerspective (1 << 9)
|
||||
#define S_ENABLE_Texture (1 << 10)
|
||||
#define S_ENABLE_PrimSetup (1 << 11)
|
||||
#define S_ENABLE_LinePattern (1 << 12)
|
||||
#define S_ENABLE_StippleAlpha (1 << 13) /* requires S_ENABLE_Stipple */
|
||||
#define S_ENABLE_Stipple (1 << 14)
|
||||
#define S_ENABLE_AlphaBuffer (1 << 16)
|
||||
#define S_ENABLE_AlphaTest (1 << 17)
|
||||
#define S_ENABLE_AlphaWrite (1 << 18)
|
||||
#define S_ENABLE_ZTest (1 << 20)
|
||||
#define S_ENABLE_ZWrite (1 << 21)
|
||||
|
||||
/*
|
||||
* REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh)
|
||||
*/
|
||||
#define MASK_6326_ZBufferPitch 0x00003FFF
|
||||
#define MASK_6326_ZTestMode 0x00070000
|
||||
#define MASK_6326_ZBufferFormat 0x00100000
|
||||
|
||||
#define S_ZSET_FORMAT_8 0x00000000
|
||||
#define S_ZSET_FORMAT_16 0x00100000
|
||||
|
||||
#define S_ZSET_PASS_NEVER 0x00000000
|
||||
#define S_ZSET_PASS_LESS 0x00010000
|
||||
#define S_ZSET_PASS_EQUAL 0x00020000
|
||||
#define S_ZSET_PASS_LEQUAL 0x00030000
|
||||
#define S_ZSET_PASS_GREATER 0x00040000
|
||||
#define S_ZSET_PASS_NOTEQUAL 0x00050000
|
||||
#define S_ZSET_PASS_GEQUAL 0x00060000
|
||||
#define S_ZSET_PASS_ALWAYS 0x00070000
|
||||
|
||||
/*
|
||||
* REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A0Ch-8A0Fh)
|
||||
*/
|
||||
#define MASK_AlphaBufferPitch 0x000003FF
|
||||
#define MASK_AlphaRefValue 0x00FF0000
|
||||
#define MASK_AlphaTestMode 0x07000000
|
||||
#define MASK_AlphaBufferFormat 0x30000000
|
||||
|
||||
#define S_ASET_FORMAT_8 0x30000000
|
||||
|
||||
#define S_ASET_PASS_NEVER 0x00000000
|
||||
#define S_ASET_PASS_LESS 0x01000000
|
||||
#define S_ASET_PASS_EQUAL 0x02000000
|
||||
#define S_ASET_PASS_LEQUAL 0x03000000
|
||||
#define S_ASET_PASS_GREATER 0x04000000
|
||||
#define S_ASET_PASS_NOTEQUAL 0x05000000
|
||||
#define S_ASET_PASS_GEQUAL 0x06000000
|
||||
#define S_ASET_PASS_ALWAYS 0x07000000
|
||||
|
||||
/*
|
||||
* REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A14h-8A17h)
|
||||
*/
|
||||
/* pitch, format, depth, rgborder, rop bits same as 300-series */
|
||||
|
||||
/*
|
||||
* REG_6326_3D_FogSet -- Define Fog Mask (8A20h-8A23h)
|
||||
*/
|
||||
#define MASK_6326_FogColor 0x00FFFFFF
|
||||
#define MASK_6326_FogMode 0x01000000
|
||||
|
||||
#define FOGMODE_6326_CONST 0x00000000
|
||||
#define FOGMODE_6326_LINEAR 0x01000000
|
||||
|
||||
/*
|
||||
* REG_6326_3D_DstSrcBlendMode (0x8A28 - 0x8A2B)
|
||||
*/
|
||||
#define MASK_6326_SrcBlendMode 0xf0000000
|
||||
#define MASK_6326_DstBlendMode 0x0f000000
|
||||
#define MASK_6326_TransparencyColor 0x00ffffff
|
||||
|
||||
#define S_DBLEND_ZERO 0x00000000
|
||||
#define S_DBLEND_ONE 0x10000000
|
||||
#define S_DBLEND_SRC_COLOR 0x20000000
|
||||
#define S_DBLEND_INV_SRC_COLOR 0x30000000
|
||||
#define S_DBLEND_SRC_ALPHA 0x40000000
|
||||
#define S_DBLEND_INV_SRC_ALPHA 0x50000000
|
||||
#define S_DBLEND_DST_ALPHA 0x60000000
|
||||
#define S_DBLEND_INV_DST_ALPHA 0x70000000
|
||||
|
||||
#define S_SBLEND_ZERO 0x00000000
|
||||
#define S_SBLEND_ONE 0x01000000
|
||||
#define S_SBLEND_SRC_ALPHA 0x04000000
|
||||
#define S_SBLEND_INV_SRC_ALPHA 0x05000000
|
||||
#define S_SBLEND_DST_ALPHA 0x06000000
|
||||
#define S_SBLEND_INV_DST_ALPHA 0x07000000
|
||||
#define S_SBLEND_DST_COLOR 0x08000000
|
||||
#define S_SBLEND_INV_DST_COLOR 0x09000000
|
||||
#define S_SBLEND_SRC_ALPHA_SAT 0x0A000000
|
||||
#define S_SBLEND_BOTH_SRC_ALPHA 0x0B000000
|
||||
#define S_SBLEND_BOTH_INV_SRC_ALPHA 0x0C000000
|
||||
|
||||
/*
|
||||
* REG_6326_3D_TextureSet (0x8A38 - 0x8A3B)
|
||||
*/
|
||||
#define MASK_6326_TextureMinFilter 0x00000007
|
||||
#define MASK_6326_TextureMagFilter 0x00000008
|
||||
#define MASK_6326_ClearTexCache 0x00000010
|
||||
#define MASK_6326_TextureInSystem 0x00000020
|
||||
#define MASK_6326_TextureLevel 0x00000F00
|
||||
#define MASK_6326_TextureSignYUVFormat 0x00008000
|
||||
#define MASK_6326_TextureMappingMode 0x00FF0000
|
||||
|
||||
#define TEXEL_6326_BGR_ORDER 0x80000000
|
||||
|
||||
#define TEXEL_6326_INDEX1 0x00000000
|
||||
#define TEXEL_6326_INDEX2 0x01000000
|
||||
#define TEXEL_6326_INDEX4 0x02000000
|
||||
|
||||
#define TEXEL_6326_M4 0x10000000
|
||||
#define TEXEL_6326_AM44 0x16000000
|
||||
|
||||
#define TEXEL_6326_YUV422 0x20000000 /* YUYV */
|
||||
#define TEXEL_6326_YVU422 0x21000000 /* YVYU */
|
||||
#define TEXEL_6326_UVY422 0x22000000 /* UYVY */
|
||||
#define TEXEL_6326_VUY422 0x23000000 /* VYUY */
|
||||
|
||||
#define TEXEL_6326_L1 0x30000000
|
||||
#define TEXEL_6326_L2 0x31000000
|
||||
#define TEXEL_6326_L4 0x32000000
|
||||
#define TEXEL_6326_L8 0x33000000
|
||||
|
||||
#define TEXEL_6326_AL22 0x35000000
|
||||
#define TEXEL_6326_AL44 0x38000000
|
||||
#define TEXEL_6326_AL88 0x3c000000
|
||||
|
||||
#define TEXEL_6326_RGB_332_8 0x40000000
|
||||
#define TEXEL_6326_RGB_233_8 0x41000000
|
||||
#define TEXEL_6326_RGB_232_8 0x42000000
|
||||
#define TEXEL_6326_ARGB_1232_8 0x43000000
|
||||
|
||||
#define TEXEL_6326_RGB_555_16 0x50000000
|
||||
#define TEXEL_6326_RGB_565_16 0x51000000
|
||||
#define TEXEL_6326_ARGB_1555_16 0x52000000
|
||||
#define TEXEL_6326_ARGB_4444_16 0x53000000
|
||||
#define TEXEL_6326_ARGB_8332_16 0x54000000
|
||||
#define TEXEL_6326_ARGB_8233_16 0x55000000
|
||||
#define TEXEL_6326_ARGB_8232_16 0x56000000
|
||||
|
||||
#define TEXEL_6326_ARGB_8565_24 0x63000000
|
||||
#define TEXEL_6326_ARGB_8555_24 0x67000000
|
||||
#define TEXEL_6326_RGB_888_24 0x68000000
|
||||
|
||||
#define TEXEL_6326_ARGB_8888_32 0x73000000
|
||||
#define TEXEL_6326_ARGB_0888_32 0x74000000
|
||||
|
||||
#define TEX_MAP_WRAP_U 0x00010000
|
||||
#define TEX_MAP_WRAP_V 0x00020000
|
||||
#define TEX_MAP_MIRROR_U 0x00040000
|
||||
#define TEX_MAP_MIRROR_V 0x00080000
|
||||
#define TEX_MAP_CLAMP_U 0x00100000
|
||||
#define TEX_MAP_CLAMP_V 0x00200000
|
||||
#define TEX_MAP_USE_CTB_SMOOTH 0x00400000
|
||||
#define TEX_MAP_USE_CTB 0x00800000
|
||||
|
||||
#define TEX_FILTER_NEAREST 0x00000000
|
||||
#define TEX_FILTER_LINEAR 0x00000001
|
||||
#define TEX_FILTER_NEAREST_MIP_NEAREST 0x00000002
|
||||
#define TEX_FILTER_NEAREST_MIP_LINEAR 0x00000003
|
||||
#define TEX_FILTER_LINEAR_MIP_NEAREST 0x00000004
|
||||
#define TEX_FILTER_LINEAR_MIP_LINEAR 0x00000005
|
||||
#define TEX_FILTER_MAG_NEAREST 0x00000000
|
||||
#define TEX_FILTER_MAG_LINEAR 0x00000008
|
||||
|
||||
/*
|
||||
* REG_6326_3D_TextureBlendSet (0x8A3C - 0x8A3F)
|
||||
*/
|
||||
#define MASK_TextureTransparencyLowB 0x000000ff
|
||||
#define MASK_TextureTransparencyLowG 0x0000FF00
|
||||
#define MASK_TextureTransparencyLowR 0x00ff0000
|
||||
#define MASK_TextureBlend 0x0f000000
|
||||
|
||||
#define TB_C_CS (0 << 26)
|
||||
#define TB_C_CF (1 << 26)
|
||||
#define TB_C_CFCS (2 << 26) /* also 3 << 26 */
|
||||
#define TB_C_CFOMAS_ASCS (4 << 26)
|
||||
#define TB_C_CSOMAF_AFCF (6 << 26) /* also 7 << 26 */
|
||||
|
||||
#define TB_A_AS (0 << 24)
|
||||
#define TB_A_AF (1 << 24)
|
||||
#define TB_A_AFAS (1 << 24)
|
||||
|
||||
/*
|
||||
* REG_6326_3D_TextureTransparencyColorHigh (0x8A40 - 0x8A43)
|
||||
*/
|
||||
#define MASK_TextureTransparencyHighB 0x000000FF
|
||||
#define MASK_TextureTransparencyHighG 0x0000FF00
|
||||
#define MASK_TextureTransparencyHighR 0x00FF0000
|
||||
|
||||
/*
|
||||
* REG_3D_TexturePitch01-89 (0x8A6C - 0x8A7F)
|
||||
*/
|
||||
#define MASK_TexturePitchOdd 0x000003FF
|
||||
#define MASK_TexturePitchEven 0x03FF0000
|
||||
#define SHIFT_TexturePitchEven 16
|
||||
|
||||
/*
|
||||
* REG_3D_TextureWidthHeightMix (0x8A80 - 0x8A83)
|
||||
*/
|
||||
#define MASK_TextureWidthLog2 0xf0000000
|
||||
#define MASK_TextureHeightLog2 0x0f000000
|
||||
|
||||
/*
|
||||
* REG_3D_TextureBorderColor (0x8A90 - 0x8A93)
|
||||
*/
|
||||
#define MASK_TextureBorderColorB 0x000000FF
|
||||
#define MASK_TextureBorderColorG 0x0000FF00
|
||||
#define MASK_TextureBorderColorR 0x00FF0000
|
||||
#define MASK_TextureBorderColorA 0xFF000000
|
||||
|
||||
#endif /* _sis6326_reg_h_ */
|
||||
753
src/mesa/drivers/dri/sis/sis6326_state.c
Normal file
753
src/mesa/drivers/dri/sis/sis6326_state.c
Normal file
|
|
@ -0,0 +1,753 @@
|
|||
/*
|
||||
* Copyright 2005 Eric Anholt
|
||||
* 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, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <anholt@FreeBSD.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sis_context.h"
|
||||
#include "sis_state.h"
|
||||
#include "sis_tris.h"
|
||||
#include "sis_lock.h"
|
||||
#include "sis_tex.h"
|
||||
#include "sis_reg.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "enums.h"
|
||||
#include "colormac.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "array_cache/acache.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
/* =============================================================
|
||||
* Alpha blending
|
||||
*/
|
||||
|
||||
static void
|
||||
sis6326DDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
GLubyte refbyte;
|
||||
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
CLAMPED_FLOAT_TO_UBYTE(refbyte, ref);
|
||||
current->hwAlpha = refbyte << 16;
|
||||
|
||||
/* Alpha Test function */
|
||||
switch (func)
|
||||
{
|
||||
case GL_NEVER:
|
||||
current->hwAlpha |= S_ASET_PASS_NEVER;
|
||||
break;
|
||||
case GL_LESS:
|
||||
current->hwAlpha |= S_ASET_PASS_LESS;
|
||||
break;
|
||||
case GL_EQUAL:
|
||||
current->hwAlpha |= S_ASET_PASS_EQUAL;
|
||||
break;
|
||||
case GL_LEQUAL:
|
||||
current->hwAlpha |= S_ASET_PASS_LEQUAL;
|
||||
break;
|
||||
case GL_GREATER:
|
||||
current->hwAlpha |= S_ASET_PASS_GREATER;
|
||||
break;
|
||||
case GL_NOTEQUAL:
|
||||
current->hwAlpha |= S_ASET_PASS_NOTEQUAL;
|
||||
break;
|
||||
case GL_GEQUAL:
|
||||
current->hwAlpha |= S_ASET_PASS_GEQUAL;
|
||||
break;
|
||||
case GL_ALWAYS:
|
||||
current->hwAlpha |= S_ASET_PASS_ALWAYS;
|
||||
break;
|
||||
}
|
||||
|
||||
prev->hwAlpha = current->hwAlpha;
|
||||
smesa->GlobalFlag |= GFLAG_ALPHASETTING;
|
||||
}
|
||||
|
||||
static void
|
||||
sis6326DDBlendFuncSeparate( GLcontext *ctx,
|
||||
GLenum sfactorRGB, GLenum dfactorRGB,
|
||||
GLenum sfactorA, GLenum dfactorA )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
current->hwDstSrcBlend = 0;
|
||||
|
||||
switch (dfactorRGB)
|
||||
{
|
||||
case GL_ZERO:
|
||||
current->hwDstSrcBlend |= S_DBLEND_ZERO;
|
||||
break;
|
||||
case GL_ONE:
|
||||
current->hwDstSrcBlend |= S_DBLEND_ONE;
|
||||
break;
|
||||
case GL_SRC_COLOR:
|
||||
current->hwDstSrcBlend |= S_DBLEND_SRC_COLOR;
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_COLOR:
|
||||
current->hwDstSrcBlend |= S_DBLEND_INV_SRC_COLOR;
|
||||
break;
|
||||
case GL_SRC_ALPHA:
|
||||
current->hwDstSrcBlend |= S_DBLEND_SRC_ALPHA;
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
current->hwDstSrcBlend |= S_DBLEND_INV_SRC_ALPHA;
|
||||
break;
|
||||
case GL_DST_ALPHA:
|
||||
current->hwDstSrcBlend |= S_DBLEND_DST_ALPHA;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
current->hwDstSrcBlend |= S_DBLEND_INV_DST_ALPHA;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (sfactorRGB)
|
||||
{
|
||||
case GL_ZERO:
|
||||
current->hwDstSrcBlend |= S_SBLEND_ZERO;
|
||||
break;
|
||||
case GL_ONE:
|
||||
current->hwDstSrcBlend |= S_SBLEND_ONE;
|
||||
break;
|
||||
case GL_SRC_ALPHA:
|
||||
current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA;
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
current->hwDstSrcBlend |= S_SBLEND_INV_SRC_ALPHA;
|
||||
break;
|
||||
case GL_DST_ALPHA:
|
||||
current->hwDstSrcBlend |= S_SBLEND_DST_ALPHA;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
current->hwDstSrcBlend |= S_SBLEND_INV_DST_ALPHA;
|
||||
break;
|
||||
case GL_DST_COLOR:
|
||||
current->hwDstSrcBlend |= S_SBLEND_DST_COLOR;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_COLOR:
|
||||
current->hwDstSrcBlend |= S_SBLEND_INV_DST_COLOR;
|
||||
break;
|
||||
case GL_SRC_ALPHA_SATURATE:
|
||||
current->hwDstSrcBlend |= S_SBLEND_SRC_ALPHA_SAT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (current->hwDstSrcBlend != prev->hwDstSrcBlend) {
|
||||
prev->hwDstSrcBlend = current->hwDstSrcBlend;
|
||||
smesa->GlobalFlag |= GFLAG_DSTBLEND;
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Depth testing
|
||||
*/
|
||||
|
||||
static void
|
||||
sis6326DDDepthFunc( GLcontext *ctx, GLenum func )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
current->hwZ &= ~MASK_6326_ZTestMode;
|
||||
switch (func)
|
||||
{
|
||||
case GL_LESS:
|
||||
current->hwZ |= S_ZSET_PASS_LESS;
|
||||
break;
|
||||
case GL_GEQUAL:
|
||||
current->hwZ |= S_ZSET_PASS_GEQUAL;
|
||||
break;
|
||||
case GL_LEQUAL:
|
||||
current->hwZ |= S_ZSET_PASS_LEQUAL;
|
||||
break;
|
||||
case GL_GREATER:
|
||||
current->hwZ |= S_ZSET_PASS_GREATER;
|
||||
break;
|
||||
case GL_NOTEQUAL:
|
||||
current->hwZ |= S_ZSET_PASS_NOTEQUAL;
|
||||
break;
|
||||
case GL_EQUAL:
|
||||
current->hwZ |= S_ZSET_PASS_EQUAL;
|
||||
break;
|
||||
case GL_ALWAYS:
|
||||
current->hwZ |= S_ZSET_PASS_ALWAYS;
|
||||
break;
|
||||
case GL_NEVER:
|
||||
current->hwZ |= S_ZSET_PASS_NEVER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (current->hwZ != prev->hwZ) {
|
||||
prev->hwZ = current->hwZ;
|
||||
smesa->GlobalFlag |= GFLAG_ZSETTING;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sis6326DDDepthMask( GLcontext *ctx, GLboolean flag )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
if (ctx->Depth.Test)
|
||||
current->hwCapEnable |= S_ENABLE_ZWrite;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_ZWrite;
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Fog
|
||||
*/
|
||||
|
||||
static void
|
||||
sis6326DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
|
||||
GLint fogColor;
|
||||
|
||||
switch(pname)
|
||||
{
|
||||
case GL_FOG_COLOR:
|
||||
fogColor = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16;
|
||||
fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8;
|
||||
fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
|
||||
current->hwFog = 0x01000000 | fogColor;
|
||||
if (current->hwFog != prev->hwFog) {
|
||||
prev->hwFog = current->hwFog;
|
||||
smesa->GlobalFlag |= GFLAG_FOGSETTING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Clipping
|
||||
*/
|
||||
|
||||
void
|
||||
sis6326UpdateClipping(GLcontext *ctx)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
GLint x1, y1, x2, y2;
|
||||
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
x2 = smesa->width - 1;
|
||||
y2 = smesa->height - 1;
|
||||
|
||||
if (ctx->Scissor.Enabled) {
|
||||
if (ctx->Scissor.X > x1)
|
||||
x1 = ctx->Scissor.X;
|
||||
if (ctx->Scissor.Y > y1)
|
||||
y1 = ctx->Scissor.Y;
|
||||
if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2)
|
||||
x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
|
||||
if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2)
|
||||
y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1;
|
||||
}
|
||||
|
||||
y1 = Y_FLIP(y1);
|
||||
y2 = Y_FLIP(y2);
|
||||
|
||||
/*current->clipTopBottom = (y2 << 13) | y1;
|
||||
current->clipLeftRight = (x1 << 13) | x2;*/ /* XXX */
|
||||
current->clipTopBottom = (0 << 13) | smesa->height;
|
||||
current->clipLeftRight = (0 << 13) | smesa->width;
|
||||
|
||||
if ((current->clipTopBottom != prev->clipTopBottom) ||
|
||||
(current->clipLeftRight != prev->clipLeftRight)) {
|
||||
prev->clipTopBottom = current->clipTopBottom;
|
||||
prev->clipLeftRight = current->clipLeftRight;
|
||||
smesa->GlobalFlag |= GFLAG_CLIPPING;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sis6326DDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
|
||||
{
|
||||
if (ctx->Scissor.Enabled)
|
||||
sis6326UpdateClipping( ctx );
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Culling
|
||||
*/
|
||||
|
||||
static void
|
||||
sis6326UpdateCull( GLcontext *ctx )
|
||||
{
|
||||
/* XXX culling */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sis6326DDCullFace( GLcontext *ctx, GLenum mode )
|
||||
{
|
||||
sis6326UpdateCull( ctx );
|
||||
}
|
||||
|
||||
static void
|
||||
sis6326DDFrontFace( GLcontext *ctx, GLenum mode )
|
||||
{
|
||||
sis6326UpdateCull( ctx );
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Masks
|
||||
*/
|
||||
|
||||
static void sis6326DDColorMask( GLcontext *ctx,
|
||||
GLboolean r, GLboolean g,
|
||||
GLboolean b, GLboolean a )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
if (r && g && b && ((ctx->Visual.alphaBits == 0) || a)) {
|
||||
FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 0);
|
||||
} else {
|
||||
FALLBACK(smesa, SIS_FALLBACK_WRITEMASK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Rendering attributes
|
||||
*/
|
||||
|
||||
static void sis6326UpdateSpecular(GLcontext *ctx)
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
if (NEED_SECONDARY_COLOR(ctx))
|
||||
current->hwCapEnable |= S_ENABLE_Specular;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_Specular;
|
||||
}
|
||||
|
||||
static void sis6326DDLightModelfv(GLcontext *ctx, GLenum pname,
|
||||
const GLfloat *param)
|
||||
{
|
||||
if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
|
||||
sis6326UpdateSpecular(ctx);
|
||||
}
|
||||
}
|
||||
static void sis6326DDShadeModel( GLcontext *ctx, GLenum mode )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
/* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
|
||||
smesa->hw_primitive = -1;
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Window position
|
||||
*/
|
||||
|
||||
/* =============================================================
|
||||
* Viewport
|
||||
*/
|
||||
|
||||
static void sis6326CalcViewport( GLcontext *ctx )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
const GLfloat *v = ctx->Viewport._WindowMap.m;
|
||||
GLfloat *m = smesa->hw_viewport;
|
||||
|
||||
/* See also sis_translate_vertex.
|
||||
*/
|
||||
m[MAT_SX] = v[MAT_SX];
|
||||
m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
|
||||
m[MAT_SY] = - v[MAT_SY];
|
||||
m[MAT_TY] = - v[MAT_TY] + smesa->driDrawable->h + SUBPIXEL_Y;
|
||||
m[MAT_SZ] = v[MAT_SZ] * smesa->depth_scale;
|
||||
m[MAT_TZ] = v[MAT_TZ] * smesa->depth_scale;
|
||||
}
|
||||
|
||||
static void sis6326DDViewport( GLcontext *ctx,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height )
|
||||
{
|
||||
sis6326CalcViewport( ctx );
|
||||
}
|
||||
|
||||
static void sis6326DDDepthRange( GLcontext *ctx,
|
||||
GLclampd nearval, GLclampd farval )
|
||||
{
|
||||
sis6326CalcViewport( ctx );
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
static void
|
||||
sis6326DDLogicOpCode( GLcontext *ctx, GLenum opcode )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
if (!ctx->Color.ColorLogicOpEnabled)
|
||||
return;
|
||||
|
||||
current->hwDstSet &= ~MASK_ROP2;
|
||||
switch (opcode)
|
||||
{
|
||||
case GL_CLEAR:
|
||||
current->hwDstSet |= LOP_CLEAR;
|
||||
break;
|
||||
case GL_SET:
|
||||
current->hwDstSet |= LOP_SET;
|
||||
break;
|
||||
case GL_COPY:
|
||||
current->hwDstSet |= LOP_COPY;
|
||||
break;
|
||||
case GL_COPY_INVERTED:
|
||||
current->hwDstSet |= LOP_COPY_INVERTED;
|
||||
break;
|
||||
case GL_NOOP:
|
||||
current->hwDstSet |= LOP_NOOP;
|
||||
break;
|
||||
case GL_INVERT:
|
||||
current->hwDstSet |= LOP_INVERT;
|
||||
break;
|
||||
case GL_AND:
|
||||
current->hwDstSet |= LOP_AND;
|
||||
break;
|
||||
case GL_NAND:
|
||||
current->hwDstSet |= LOP_NAND;
|
||||
break;
|
||||
case GL_OR:
|
||||
current->hwDstSet |= LOP_OR;
|
||||
break;
|
||||
case GL_NOR:
|
||||
current->hwDstSet |= LOP_NOR;
|
||||
break;
|
||||
case GL_XOR:
|
||||
current->hwDstSet |= LOP_XOR;
|
||||
break;
|
||||
case GL_EQUIV:
|
||||
current->hwDstSet |= LOP_EQUIV;
|
||||
break;
|
||||
case GL_AND_REVERSE:
|
||||
current->hwDstSet |= LOP_AND_REVERSE;
|
||||
break;
|
||||
case GL_AND_INVERTED:
|
||||
current->hwDstSet |= LOP_AND_INVERTED;
|
||||
break;
|
||||
case GL_OR_REVERSE:
|
||||
current->hwDstSet |= LOP_OR_REVERSE;
|
||||
break;
|
||||
case GL_OR_INVERTED:
|
||||
current->hwDstSet |= LOP_OR_INVERTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (current->hwDstSet != prev->hwDstSet) {
|
||||
prev->hwDstSet = current->hwDstSet;
|
||||
smesa->GlobalFlag |= GFLAG_DESTSETTING;
|
||||
}
|
||||
}
|
||||
|
||||
void sis6326DDDrawBuffer( GLcontext *ctx, GLenum mode )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
if(getenv("SIS_DRAW_FRONT"))
|
||||
ctx->DrawBuffer->_ColorDrawBufferMask[0] = GL_FRONT_LEFT;
|
||||
|
||||
/*
|
||||
* _DrawDestMask is easier to cope with than <mode>.
|
||||
*/
|
||||
current->hwDstSet &= ~MASK_DstBufferPitch;
|
||||
switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
|
||||
case BUFFER_BIT_FRONT_LEFT:
|
||||
current->hwOffsetDest = smesa->front.offset;
|
||||
current->hwDstSet |= smesa->front.pitch;
|
||||
FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
|
||||
break;
|
||||
case BUFFER_BIT_BACK_LEFT:
|
||||
current->hwOffsetDest = smesa->back.offset;
|
||||
current->hwDstSet |= smesa->back.pitch;
|
||||
FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
|
||||
break;
|
||||
default:
|
||||
/* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
|
||||
FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
|
||||
return;
|
||||
}
|
||||
|
||||
if (current->hwDstSet != prev->hwDstSet) {
|
||||
prev->hwDstSet = current->hwDstSet;
|
||||
smesa->GlobalFlag |= GFLAG_DESTSETTING;
|
||||
}
|
||||
|
||||
if (current->hwOffsetDest != prev->hwOffsetDest) {
|
||||
prev->hwOffsetDest = current->hwOffsetDest;
|
||||
smesa->GlobalFlag |= GFLAG_DESTSETTING;
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* Polygon stipple
|
||||
*/
|
||||
|
||||
/* =============================================================
|
||||
* Render mode
|
||||
*/
|
||||
|
||||
/* =============================================================
|
||||
* State enable/disable
|
||||
*/
|
||||
|
||||
static void
|
||||
sis6326DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
switch (cap)
|
||||
{
|
||||
case GL_ALPHA_TEST:
|
||||
if (state)
|
||||
current->hwCapEnable |= S_ENABLE_AlphaTest;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_AlphaTest;
|
||||
break;
|
||||
case GL_BLEND:
|
||||
/* TODO: */
|
||||
if (state)
|
||||
/* if (state & !ctx->Color.ColorLogicOpEnabled) */
|
||||
current->hwCapEnable |= S_ENABLE_Blend;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_Blend;
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
/* XXX culling */
|
||||
break;
|
||||
case GL_DEPTH_TEST:
|
||||
if (state && smesa->depth.offset != 0)
|
||||
current->hwCapEnable |= S_ENABLE_ZTest;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_ZTest;
|
||||
sis6326DDDepthMask( ctx, ctx->Depth.Mask );
|
||||
break;
|
||||
case GL_DITHER:
|
||||
if (state)
|
||||
current->hwCapEnable |= S_ENABLE_Dither;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_Dither;
|
||||
break;
|
||||
case GL_FOG:
|
||||
if (state)
|
||||
current->hwCapEnable |= S_ENABLE_Fog;
|
||||
else
|
||||
current->hwCapEnable &= ~S_ENABLE_Fog;
|
||||
break;
|
||||
case GL_COLOR_LOGIC_OP:
|
||||
if (state)
|
||||
sis6326DDLogicOpCode( ctx, ctx->Color.LogicOp );
|
||||
else
|
||||
sis6326DDLogicOpCode( ctx, GL_COPY );
|
||||
break;
|
||||
case GL_SCISSOR_TEST:
|
||||
sis6326UpdateClipping( ctx );
|
||||
break;
|
||||
case GL_STENCIL_TEST:
|
||||
if (state) {
|
||||
FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1);
|
||||
} else {
|
||||
FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0);
|
||||
}
|
||||
break;
|
||||
case GL_LIGHTING:
|
||||
case GL_COLOR_SUM_EXT:
|
||||
sis6326UpdateSpecular(ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================================
|
||||
* State initialization, management
|
||||
*/
|
||||
|
||||
/* Called before beginning of rendering. */
|
||||
void
|
||||
sis6326UpdateHWState( GLcontext *ctx )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
|
||||
if (smesa->NewGLState & _NEW_TEXTURE)
|
||||
sisUpdateTextureState( ctx );
|
||||
|
||||
if (current->hwCapEnable ^ prev->hwCapEnable) {
|
||||
prev->hwCapEnable = current->hwCapEnable;
|
||||
smesa->GlobalFlag |= GFLAG_ENABLESETTING;
|
||||
}
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_RENDER_STATES)
|
||||
sis_update_render_state( smesa );
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES)
|
||||
sis_update_texture_state( smesa );
|
||||
}
|
||||
|
||||
static void
|
||||
sis6326DDInvalidateState( GLcontext *ctx, GLuint new_state )
|
||||
{
|
||||
sisContextPtr smesa = SIS_CONTEXT(ctx);
|
||||
|
||||
_swrast_InvalidateState( ctx, new_state );
|
||||
_swsetup_InvalidateState( ctx, new_state );
|
||||
_ac_InvalidateState( ctx, new_state );
|
||||
_tnl_InvalidateState( ctx, new_state );
|
||||
smesa->NewGLState |= new_state;
|
||||
}
|
||||
|
||||
/* Initialize the context's hardware state.
|
||||
*/
|
||||
void sis6326DDInitState( sisContextPtr smesa )
|
||||
{
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
__GLSiSHardware *current = &smesa->current;
|
||||
GLcontext *ctx = smesa->glCtx;
|
||||
|
||||
/* add Texture Perspective Enable */
|
||||
current->hwCapEnable = S_ENABLE_TextureCache |
|
||||
S_ENABLE_TexturePerspective | S_ENABLE_Dither;
|
||||
|
||||
/* Z test mode is LESS */
|
||||
current->hwZ = S_ZSET_PASS_LESS | S_ZSET_FORMAT_16;
|
||||
if (ctx->Visual.depthBits > 0)
|
||||
current->hwCapEnable |= S_ENABLE_ZWrite;
|
||||
|
||||
/* Alpha test mode is ALWAYS, alpha ref value is 0 */
|
||||
current->hwAlpha = S_ASET_PASS_ALWAYS;
|
||||
|
||||
/* ROP2 is COPYPEN */
|
||||
current->hwDstSet = LOP_COPY;
|
||||
|
||||
/* LinePattern is 0, Repeat Factor is 0 */
|
||||
current->hwLinePattern = 0x00008000;
|
||||
|
||||
/* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
|
||||
current->hwDstSrcBlend = S_SBLEND_ONE | S_DBLEND_ZERO;
|
||||
|
||||
switch (smesa->bytesPerPixel)
|
||||
{
|
||||
case 2:
|
||||
current->hwDstSet |= DST_FORMAT_RGB_565;
|
||||
break;
|
||||
case 4:
|
||||
current->hwDstSet |= DST_FORMAT_ARGB_8888;
|
||||
break;
|
||||
}
|
||||
|
||||
smesa->depth_scale = 1.0 / (GLfloat)0xffff;
|
||||
|
||||
smesa->clearTexCache = GL_TRUE;
|
||||
|
||||
smesa->clearColorPattern = 0;
|
||||
|
||||
sis6326UpdateZPattern(smesa, 1.0);
|
||||
sis6326UpdateCull(ctx);
|
||||
|
||||
/* Set initial fog settings. Start and end are the same case. */
|
||||
sis6326DDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
|
||||
sis6326DDFogfv( ctx, GL_FOG_END, &ctx->Fog.End );
|
||||
sis6326DDFogfv( ctx, GL_FOG_MODE, NULL );
|
||||
|
||||
memcpy(prev, current, sizeof(__GLSiSHardware));
|
||||
}
|
||||
|
||||
/* Initialize the driver's state functions.
|
||||
*/
|
||||
void sis6326DDInitStateFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.UpdateState = sis6326DDInvalidateState;
|
||||
|
||||
ctx->Driver.Clear = sis6326DDClear;
|
||||
ctx->Driver.ClearColor = sis6326DDClearColor;
|
||||
ctx->Driver.ClearDepth = sis6326DDClearDepth;
|
||||
|
||||
ctx->Driver.AlphaFunc = sis6326DDAlphaFunc;
|
||||
ctx->Driver.BlendFuncSeparate = sis6326DDBlendFuncSeparate;
|
||||
ctx->Driver.ColorMask = sis6326DDColorMask;
|
||||
ctx->Driver.CullFace = sis6326DDCullFace;
|
||||
ctx->Driver.DepthMask = sis6326DDDepthMask;
|
||||
ctx->Driver.DepthFunc = sis6326DDDepthFunc;
|
||||
ctx->Driver.DepthRange = sis6326DDDepthRange;
|
||||
ctx->Driver.DrawBuffer = sis6326DDDrawBuffer;
|
||||
ctx->Driver.Enable = sis6326DDEnable;
|
||||
ctx->Driver.FrontFace = sis6326DDFrontFace;
|
||||
ctx->Driver.Fogfv = sis6326DDFogfv;
|
||||
ctx->Driver.Hint = NULL;
|
||||
ctx->Driver.Lightfv = NULL;
|
||||
ctx->Driver.LogicOpcode = sis6326DDLogicOpCode;
|
||||
ctx->Driver.PolygonMode = NULL;
|
||||
ctx->Driver.PolygonStipple = NULL;
|
||||
ctx->Driver.RenderMode = NULL;
|
||||
ctx->Driver.Scissor = sis6326DDScissor;
|
||||
ctx->Driver.ShadeModel = sis6326DDShadeModel;
|
||||
ctx->Driver.LightModelfv = sis6326DDLightModelfv;
|
||||
ctx->Driver.Viewport = sis6326DDViewport;
|
||||
|
||||
/* Pixel path fallbacks. */
|
||||
ctx->Driver.Accum = _swrast_Accum;
|
||||
ctx->Driver.Bitmap = _swrast_Bitmap;
|
||||
ctx->Driver.CopyPixels = _swrast_CopyPixels;
|
||||
ctx->Driver.DrawPixels = _swrast_DrawPixels;
|
||||
ctx->Driver.ReadPixels = _swrast_ReadPixels;
|
||||
|
||||
/* Swrast hooks for imaging extensions: */
|
||||
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
|
||||
ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
|
||||
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
|
||||
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
|
||||
}
|
||||
|
|
@ -86,6 +86,16 @@ struct dri_extension card_extensions[] =
|
|||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
struct dri_extension card_extensions_6326[] =
|
||||
{
|
||||
{ "GL_ARB_multisample", GL_ARB_multisample_functions },
|
||||
/*{ "GL_ARB_texture_border_clamp", NULL },*/
|
||||
{ "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
|
||||
/*{ "GL_ARB_texture_mirrored_repeat", NULL },*/
|
||||
/*{ "GL_MESA_ycbcr_texture", NULL },*/
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static const struct dri_debug_control debug_control[] =
|
||||
{
|
||||
{ "fall", DEBUG_FALLBACKS },
|
||||
|
|
@ -97,9 +107,15 @@ WaitEngIdle (sisContextPtr smesa)
|
|||
{
|
||||
GLuint engineState;
|
||||
|
||||
do {
|
||||
engineState = MMIO_READ(REG_CommandQueue);
|
||||
} while ((engineState & SiS_EngIdle) != SiS_EngIdle);
|
||||
if (smesa->is6326) {
|
||||
do {
|
||||
engineState = MMIO_READ(REG_3D_EngineFire); /* XXX right reg? */
|
||||
} while ((engineState & ENG_3DIDLEQE) != 0);
|
||||
} else {
|
||||
do {
|
||||
engineState = MMIO_READ(REG_CommandQueue);
|
||||
} while ((engineState & SiS_EngIdle) != SiS_EngIdle);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -107,9 +123,15 @@ Wait2DEngIdle (sisContextPtr smesa)
|
|||
{
|
||||
GLuint engineState;
|
||||
|
||||
do {
|
||||
engineState = MMIO_READ(REG_CommandQueue);
|
||||
} while ((engineState & SiS_EngIdle2d) != SiS_EngIdle2d);
|
||||
if (smesa->is6326) {
|
||||
do {
|
||||
engineState = MMIO_READ(REG_6326_BitBlt_Cmd);
|
||||
} while ((engineState & BLT_BUSY) != 0);
|
||||
} else {
|
||||
do {
|
||||
engineState = MMIO_READ(REG_CommandQueue);
|
||||
} while ((engineState & SiS_EngIdle2d) != SiS_EngIdle2d);
|
||||
}
|
||||
}
|
||||
|
||||
/* To be called from mWait3DCmdQueue. Separate function for profiling
|
||||
|
|
@ -118,9 +140,16 @@ Wait2DEngIdle (sisContextPtr smesa)
|
|||
void
|
||||
WaitingFor3dIdle(sisContextPtr smesa, int wLen)
|
||||
{
|
||||
while (*(smesa->CurrentQueueLenPtr) < wLen) {
|
||||
*(smesa->CurrentQueueLenPtr) =
|
||||
(MMIO_READ(REG_CommandQueue) & MASK_QueueLen) - 20;
|
||||
if (smesa->is6326) {
|
||||
while (*(smesa->CurrentQueueLenPtr) < wLen) {
|
||||
*(smesa->CurrentQueueLenPtr) =
|
||||
((GLuint)MMIO_READ(REG_3D_EngineFire) >> 16) * 2;
|
||||
}
|
||||
} else {
|
||||
while (*(smesa->CurrentQueueLenPtr) < wLen) {
|
||||
*(smesa->CurrentQueueLenPtr) =
|
||||
(MMIO_READ(REG_CommandQueue) & MASK_QueueLen) - 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +202,7 @@ sisCreateContext( const __GLcontextModes *glVisual,
|
|||
|
||||
sisScreen = smesa->sisScreen = (sisScreenPtr)(sPriv->private);
|
||||
|
||||
smesa->is6326 = GL_FALSE; /* XXX */
|
||||
smesa->driContext = driContextPriv;
|
||||
smesa->driScreen = sPriv;
|
||||
smesa->driDrawable = NULL;
|
||||
|
|
@ -214,6 +244,16 @@ sisCreateContext( const __GLcontextModes *glVisual,
|
|||
sis_fatal_error("Bad bytesPerPixel %d.\n", smesa->bytesPerPixel);
|
||||
}
|
||||
|
||||
if (smesa->is6326) {
|
||||
ctx->Const.MaxTextureUnits = 1;
|
||||
ctx->Const.MaxTextureLevels = 9;
|
||||
} else {
|
||||
ctx->Const.MaxTextureUnits = 2;
|
||||
ctx->Const.MaxTextureLevels = 11;
|
||||
}
|
||||
ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
|
||||
ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
|
||||
|
||||
/* Parse configuration files */
|
||||
driParseConfigFiles (&smesa->optionCache, &sisScreen->optionCache,
|
||||
sisScreen->driScreen->myNum, "sis");
|
||||
|
|
@ -274,11 +314,16 @@ sisCreateContext( const __GLcontextModes *glVisual,
|
|||
_tnl_allow_vertex_fog( ctx, GL_FALSE );
|
||||
|
||||
/* XXX these should really go right after _mesa_init_driver_functions() */
|
||||
sisDDInitStateFuncs( ctx );
|
||||
sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */
|
||||
if (smesa->is6326) {
|
||||
sis6326DDInitStateFuncs( ctx );
|
||||
sis6326DDInitState( smesa ); /* Initializes smesa->zFormat, important */
|
||||
} else {
|
||||
sisDDInitStateFuncs( ctx );
|
||||
sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */
|
||||
sisDDInitStencilFuncs( ctx );
|
||||
}
|
||||
sisInitTriFuncs( ctx );
|
||||
sisDDInitSpanFuncs( ctx );
|
||||
sisDDInitStencilFuncs( ctx );
|
||||
|
||||
driInitExtensions( ctx, card_extensions, GL_FALSE );
|
||||
|
||||
|
|
@ -553,3 +598,127 @@ sis_update_texture_state (sisContextPtr smesa)
|
|||
smesa->GlobalFlag &= ~GFLAG_TEXTURE_STATES;
|
||||
}
|
||||
|
||||
void
|
||||
sis6326_update_render_state( sisContextPtr smesa )
|
||||
{
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
|
||||
mWait3DCmdQueue (45);
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_ENABLESETTING) {
|
||||
if (!smesa->clearTexCache) {
|
||||
MMIO(REG_6326_3D_TEnable, prev->hwCapEnable);
|
||||
} else {
|
||||
MMIO(REG_6326_3D_TEnable, prev->hwCapEnable & ~S_ENABLE_TextureCache);
|
||||
MMIO(REG_6326_3D_TEnable, prev->hwCapEnable);
|
||||
smesa->clearTexCache = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Z Setting */
|
||||
if (smesa->GlobalFlag & GFLAG_ZSETTING) {
|
||||
MMIO(REG_6326_3D_ZSet, prev->hwZ);
|
||||
MMIO(REG_6326_3D_ZAddress, prev->hwOffsetZ);
|
||||
}
|
||||
|
||||
/* Alpha Setting */
|
||||
if (smesa->GlobalFlag & GFLAG_ALPHASETTING)
|
||||
MMIO(REG_6326_3D_AlphaSet, prev->hwAlpha);
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_DESTSETTING) {
|
||||
MMIO(REG_6326_3D_DstSet, prev->hwDstSet);
|
||||
MMIO(REG_6326_3D_DstAddress, prev->hwOffsetDest);
|
||||
}
|
||||
|
||||
/* Fog Setting */
|
||||
if (smesa->GlobalFlag & GFLAG_FOGSETTING) {
|
||||
MMIO(REG_6326_3D_FogSet, prev->hwFog);
|
||||
}
|
||||
|
||||
/* Miscellaneous Setting */
|
||||
if (smesa->GlobalFlag & GFLAG_DSTBLEND)
|
||||
MMIO(REG_6326_3D_DstSrcBlendMode, prev->hwDstSrcBlend);
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_CLIPPING) {
|
||||
MMIO(REG_6326_3D_ClipTopBottom, prev->clipTopBottom);
|
||||
MMIO(REG_6326_3D_ClipLeftRight, prev->clipLeftRight);
|
||||
}
|
||||
|
||||
smesa->GlobalFlag &= ~GFLAG_RENDER_STATES;
|
||||
}
|
||||
|
||||
void
|
||||
sis6326_update_texture_state (sisContextPtr smesa)
|
||||
{
|
||||
__GLSiSHardware *prev = &smesa->prev;
|
||||
|
||||
mWait3DCmdQueue (55);
|
||||
if (smesa->clearTexCache || (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS)) {
|
||||
MMIO(REG_6326_3D_TEnable, prev->hwCapEnable & ~S_ENABLE_TextureCache);
|
||||
MMIO(REG_6326_3D_TEnable, prev->hwCapEnable);
|
||||
smesa->clearTexCache = GL_FALSE;
|
||||
}
|
||||
|
||||
/* Texture Setting */
|
||||
if (smesa->GlobalFlag & CFLAG_TEXTURERESET)
|
||||
MMIO(REG_6326_3D_TextureSet, prev->texture[0].hwTextureSet);
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP)
|
||||
MMIO(REG_6326_3D_TextureWidthHeight, prev->texture[0].hwTexWidthHeight);
|
||||
|
||||
/*
|
||||
MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh);
|
||||
MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow);
|
||||
*/
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR)
|
||||
MMIO(REG_6326_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor);
|
||||
|
||||
if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS) {
|
||||
switch ((prev->texture[0].hwTextureSet & MASK_6326_TextureLevel) >> 8)
|
||||
{
|
||||
case 9:
|
||||
MMIO(REG_6326_3D_TextureAddress9, prev->texture[0].texOffset9);
|
||||
/* FALLTHROUGH */
|
||||
case 8:
|
||||
MMIO(REG_6326_3D_TextureAddress8, prev->texture[0].texOffset8);
|
||||
MMIO(REG_6326_3D_TexturePitch89, prev->texture[0].texPitch89);
|
||||
/* FALLTHROUGH */
|
||||
case 7:
|
||||
MMIO(REG_6326_3D_TextureAddress7, prev->texture[0].texOffset7);
|
||||
/* FALLTHROUGH */
|
||||
case 6:
|
||||
MMIO(REG_6326_3D_TextureAddress6, prev->texture[0].texOffset6);
|
||||
MMIO(REG_6326_3D_TexturePitch67, prev->texture[0].texPitch67);
|
||||
/* FALLTHROUGH */
|
||||
case 5:
|
||||
MMIO(REG_6326_3D_TextureAddress5, prev->texture[0].texOffset5);
|
||||
/* FALLTHROUGH */
|
||||
case 4:
|
||||
MMIO(REG_6326_3D_TextureAddress4, prev->texture[0].texOffset4);
|
||||
MMIO(REG_6326_3D_TexturePitch45, prev->texture[0].texPitch45);
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
MMIO(REG_6326_3D_TextureAddress3, prev->texture[0].texOffset3);
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
MMIO(REG_6326_3D_TextureAddress2, prev->texture[0].texOffset2);
|
||||
MMIO(REG_6326_3D_TexturePitch23, prev->texture[0].texPitch23);
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
MMIO(REG_6326_3D_TextureAddress1, prev->texture[0].texOffset1);
|
||||
/* FALLTHROUGH */
|
||||
case 0:
|
||||
MMIO(REG_6326_3D_TextureAddress0, prev->texture[0].texOffset0);
|
||||
MMIO(REG_6326_3D_TexturePitch01, prev->texture[0].texPitch01);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* texture environment */
|
||||
if (smesa->GlobalFlag & GFLAG_TEXTUREENV) {
|
||||
MMIO(REG_6326_3D_TextureBlendSet, prev->hwTexBlendSet);
|
||||
}
|
||||
|
||||
smesa->GlobalFlag &= ~GFLAG_TEXTURE_STATES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include "sis_screen.h"
|
||||
#include "sis_reg.h"
|
||||
#include "sis6326_reg.h"
|
||||
#include "sis_dri.h"
|
||||
|
||||
/* for GLboolean */
|
||||
|
|
@ -65,7 +66,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define SIS_FALLBACK_TEXENV1 0x0010
|
||||
#define SIS_FALLBACK_DRAW_BUFFER 0x0020
|
||||
#define SIS_FALLBACK_STENCIL 0x0040
|
||||
#define SIS_FALLBACK_DISABLE 0x0080
|
||||
#define SIS_FALLBACK_WRITEMASK 0x0080
|
||||
#define SIS_FALLBACK_DISABLE 0x0100
|
||||
|
||||
/* Flags for hardware state that needs to be updated */
|
||||
#define GFLAG_ENABLESETTING 0x00000001
|
||||
|
|
@ -132,7 +134,8 @@ typedef struct sis_tex_obj {
|
|||
sisTexImage image[SIS_MAX_TEXTURE_LEVELS]; /* Image data for each mipmap
|
||||
* level */
|
||||
GLenum format; /* One of GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
|
||||
* GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA */
|
||||
* GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA
|
||||
* MESA_YCBCR */
|
||||
GLint hwformat; /* One of the TEXEL_ defines */
|
||||
GLint numImages; /* Number of images loaded into .image */
|
||||
} sisTexObj, *sisTexObjPtr;
|
||||
|
|
@ -146,6 +149,7 @@ typedef struct __GLSiSTextureRec
|
|||
GLint hwTextureMip;
|
||||
GLint hwTextureClrHigh;
|
||||
GLint hwTextureClrLow;
|
||||
GLint hwTexWidthHeight; /* 6326: Texture Blending Setting */
|
||||
GLint hwTextureBorderColor;
|
||||
|
||||
GLint texOffset0;
|
||||
|
|
@ -205,6 +209,7 @@ typedef struct __GLSiSHardwareRec
|
|||
|
||||
GLint hwTexEnvColor; /* Texture Blending Setting */
|
||||
|
||||
GLint hwTexBlendSet; /* 6326 */
|
||||
GLint hwTexBlendColor0;
|
||||
GLint hwTexBlendColor1;
|
||||
GLint hwTexBlendAlpha0;
|
||||
|
|
@ -322,6 +327,7 @@ struct sis_context
|
|||
__GLSiSHardware prev, current;
|
||||
|
||||
int Chipset;
|
||||
GLboolean is6326;
|
||||
|
||||
GLint drawableID;
|
||||
|
||||
|
|
@ -395,6 +401,12 @@ struct sis_context
|
|||
#define MMIO_READ(reg) *(volatile GLint *)(smesa->IOBase + (reg))
|
||||
#define MMIO_READf(reg) *(volatile GLfloat *)(smesa->IOBase + (reg))
|
||||
|
||||
#if defined(__i386__) || defined(__amd64__)
|
||||
#define MMIO_WMB() __asm __volatile("" : : : "memory")
|
||||
#else
|
||||
#error platform needs WMB
|
||||
#endif
|
||||
|
||||
#define mEndPrimitive() \
|
||||
{ \
|
||||
*(volatile GLubyte *)(smesa->IOBase + REG_3D_EndPrimitiveList) = 0xff; \
|
||||
|
|
@ -446,6 +458,8 @@ void WaitingFor3dIdle(sisContextPtr smesa, int wLen);
|
|||
/* update to hw */
|
||||
extern void sis_update_texture_state( sisContextPtr smesa );
|
||||
extern void sis_update_render_state( sisContextPtr smesa );
|
||||
extern void sis6326_update_texture_state( sisContextPtr smesa );
|
||||
extern void sis6326_update_render_state( sisContextPtr smesa );
|
||||
|
||||
/* ================================================================
|
||||
* Debugging:
|
||||
|
|
|
|||
|
|
@ -66,7 +66,10 @@ sisGetLock( sisContextPtr smesa, GLuint flags )
|
|||
if ( smesa->lastStamp != dPriv->lastStamp ) {
|
||||
sisUpdateBufferSize( smesa );
|
||||
sisUpdateClipping( smesa->glCtx );
|
||||
sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] );
|
||||
if (smesa->is6326)
|
||||
sis6326DDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] );
|
||||
else
|
||||
sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] );
|
||||
driUpdateFramebufferSize(smesa->glCtx, dPriv);
|
||||
smesa->lastStamp = dPriv->lastStamp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,6 +290,12 @@ sisUpdateClipping( GLcontext *ctx )
|
|||
|
||||
GLint x1, y1, x2, y2;
|
||||
|
||||
if (smesa->is6326) {
|
||||
/* XXX: 6326 has its own clipping for now. Should be fixed */
|
||||
sis6326UpdateClipping(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
x2 = smesa->width - 1;
|
||||
|
|
@ -824,7 +830,7 @@ void sisDDInitState( sisContextPtr smesa )
|
|||
*/
|
||||
void sisDDInitStateFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.UpdateState = sisDDInvalidateState;
|
||||
ctx->Driver.UpdateState = sisDDInvalidateState;
|
||||
|
||||
ctx->Driver.Clear = sisDDClear;
|
||||
ctx->Driver.ClearColor = sisDDClearColor;
|
||||
|
|
|
|||
|
|
@ -34,20 +34,37 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include "sis_context.h"
|
||||
|
||||
extern void sisDDInitState( sisContextPtr smesa );
|
||||
extern void sisDDInitStateFuncs( GLcontext *ctx );
|
||||
/* sis6326_clear.c */
|
||||
extern void sis6326DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
GLint x, GLint y, GLint width, GLint height );
|
||||
extern void sis6326DDClearColor( GLcontext * ctx, const GLfloat color[4] );
|
||||
extern void sis6326DDClearDepth( GLcontext * ctx, GLclampd d );
|
||||
extern void sis6326UpdateZPattern(sisContextPtr smesa, GLclampd z);
|
||||
|
||||
/* sis_clear.c */
|
||||
extern void sisDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
GLint x, GLint y, GLint width, GLint height );
|
||||
extern void sisDDClearColor( GLcontext * ctx, const GLfloat color[4] );
|
||||
extern void sisDDClearDepth( GLcontext * ctx, GLclampd d );
|
||||
extern void sisDDClearStencil( GLcontext * ctx, GLint s );
|
||||
extern void sisDDFogfv( GLcontext * ctx, GLenum pname, const GLfloat * params );
|
||||
extern void sisDDDepthMask( GLcontext * ctx, GLboolean flag );
|
||||
|
||||
extern void sisUpdateClipping( GLcontext * gc );
|
||||
extern void sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z,
|
||||
int stencil );
|
||||
|
||||
/* sis_fog.c */
|
||||
extern void sisDDFogfv( GLcontext * ctx, GLenum pname, const GLfloat * params );
|
||||
|
||||
/* sis6326_state.c */
|
||||
extern void sis6326DDInitState( sisContextPtr smesa );
|
||||
extern void sis6326DDInitStateFuncs( GLcontext *ctx );
|
||||
extern void sis6326UpdateClipping( GLcontext * gc );
|
||||
extern void sis6326DDDrawBuffer( GLcontext *ctx, GLenum mode );
|
||||
extern void sis6326UpdateHWState( GLcontext *ctx );
|
||||
|
||||
/* sis_state.c */
|
||||
extern void sisDDInitState( sisContextPtr smesa );
|
||||
extern void sisDDInitStateFuncs( GLcontext *ctx );
|
||||
extern void sisDDDepthMask( GLcontext * ctx, GLboolean flag );
|
||||
extern void sisUpdateClipping( GLcontext * gc );
|
||||
extern void sisDDDrawBuffer( GLcontext *ctx, GLenum mode );
|
||||
extern void sisUpdateHWState( GLcontext *ctx );
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include "sis_alloc.h"
|
||||
#include "sis_tex.h"
|
||||
|
||||
/* 6326 and 300-series shared */
|
||||
static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
OP_3D_POINT_DRAW, /* GL_POINTS */
|
||||
OP_3D_LINE_DRAW, /* GL_LINES */
|
||||
|
|
@ -68,6 +69,11 @@ static const GLuint hw_prim_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = {
|
|||
OP_3D_FIRE_TSARGBb,
|
||||
OP_3D_FIRE_TSARGBc
|
||||
};
|
||||
static const GLuint hw_prim_6326_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = {
|
||||
OP_6326_3D_FIRE_TSARGBa,
|
||||
OP_6326_3D_FIRE_TSARGBb,
|
||||
OP_6326_3D_FIRE_TSARGBc
|
||||
};
|
||||
|
||||
static const GLuint hw_prim_mmio_shade[OP_3D_TRIANGLE_DRAW+1] = {
|
||||
SHADE_FLAT_VertexA,
|
||||
|
|
@ -142,6 +148,25 @@ do { \
|
|||
MMIO(REG_3D_TSARGBa+(i)*0x30, __color); \
|
||||
} while (0)
|
||||
|
||||
#define SIS6326_MMIO_WRITE_VERTEX(_v, i, lastvert) \
|
||||
do { \
|
||||
GLuint __color, __i = 0; \
|
||||
MMIO(REG_6326_3D_TSXa+(i)*0x20, _v->ui[__i++]); \
|
||||
MMIO(REG_6326_3D_TSYa+(i)*0x20, _v->ui[__i++]); \
|
||||
MMIO(REG_6326_3D_TSZa+(i)*0x20, _v->ui[__i++]); \
|
||||
if (SIS_STATES & VERT_W) \
|
||||
MMIO(REG_6326_3D_TSWa+(i)*0x20, _v->ui[__i++]); \
|
||||
__color = _v->ui[__i++]; \
|
||||
if (SIS_STATES & VERT_SPEC) \
|
||||
MMIO(REG_6326_3D_TSFSa+(i)*0x20, _v->ui[__i++]); \
|
||||
if (SIS_STATES & VERT_UV0) { \
|
||||
MMIO(REG_6326_3D_TSUa+(i)*0x20, _v->ui[__i++]); \
|
||||
MMIO(REG_6326_3D_TSVa+(i)*0x20, _v->ui[__i++]); \
|
||||
} \
|
||||
if (lastvert || (SIS_STATES & VERT_SMOOTH)) \
|
||||
MMIO(REG_6326_3D_TSARGBa+(i)*0x30, __color); \
|
||||
} while (0)
|
||||
|
||||
#define MMIO_VERT_REG_COUNT 10
|
||||
|
||||
#define VERT_SMOOTH 0x01
|
||||
|
|
@ -149,11 +174,12 @@ do { \
|
|||
#define VERT_SPEC 0x04
|
||||
#define VERT_UV0 0x08
|
||||
#define VERT_UV1 0x10
|
||||
#define VERT_6326 0x20 /* Right after UV1, but won't have a UV1 set */
|
||||
|
||||
typedef void (*mmio_draw_func)(sisContextPtr smesa, char *verts);
|
||||
static mmio_draw_func sis_tri_func_mmio[32];
|
||||
static mmio_draw_func sis_line_func_mmio[32];
|
||||
static mmio_draw_func sis_point_func_mmio[32];
|
||||
static mmio_draw_func sis_tri_func_mmio[48];
|
||||
static mmio_draw_func sis_line_func_mmio[48];
|
||||
static mmio_draw_func sis_point_func_mmio[48];
|
||||
|
||||
#define SIS_STATES (0)
|
||||
#define TAG(x) x##_none
|
||||
|
|
@ -754,17 +780,30 @@ static void sisRasterPrimitive( GLcontext *ctx, GLuint hwprim )
|
|||
if (smesa->hw_primitive != hwprim) {
|
||||
SIS_FIREVERTICES(smesa);
|
||||
smesa->hw_primitive = hwprim;
|
||||
|
||||
smesa->AGPParseSet &= ~(MASK_PsDataType | MASK_PsShadingMode);
|
||||
smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand |
|
||||
MASK_SetFirePosition | MASK_ShadingMode);
|
||||
smesa->AGPParseSet |= hw_prim_agp_type[hwprim];
|
||||
smesa->dwPrimitiveSet |= hwprim | hw_prim_mmio_fire[hwprim];
|
||||
|
||||
if (smesa->is6326) {
|
||||
smesa->dwPrimitiveSet &= ~(MASK_6326_DrawPrimitiveCommand |
|
||||
MASK_6326_SetFirePosition | MASK_6326_ShadingMode);
|
||||
smesa->dwPrimitiveSet |= hwprim | hw_prim_6326_mmio_fire[hwprim];
|
||||
} else {
|
||||
smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand |
|
||||
MASK_SetFirePosition | MASK_ShadingMode);
|
||||
smesa->dwPrimitiveSet |= hwprim | hw_prim_mmio_fire[hwprim];
|
||||
}
|
||||
|
||||
if (ctx->Light.ShadeModel == GL_FLAT) {
|
||||
smesa->AGPParseSet |= hw_prim_agp_shade[hwprim];
|
||||
smesa->dwPrimitiveSet |= hw_prim_mmio_shade[hwprim];
|
||||
} else {
|
||||
smesa->AGPParseSet |= MASK_PsShadingSmooth;
|
||||
smesa->dwPrimitiveSet |= SHADE_GOURAUD;
|
||||
if (smesa->is6326) {
|
||||
smesa->dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_GOURAUD;
|
||||
} else {
|
||||
smesa->dwPrimitiveSet |= SHADE_GOURAUD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -867,6 +906,7 @@ static void sisRenderStart( GLcontext *ctx )
|
|||
EMIT_ATTR(_TNL_ATTRIB_TEX0, EMIT_2F);
|
||||
AGPParseSet |= SiS_PS_HAS_UV0;
|
||||
}
|
||||
/* Will only hit tex1 on SiS300 */
|
||||
if (index & _TNL_BIT_TEX(1)) {
|
||||
if (VB->TexCoordPtr[1]->size > 2)
|
||||
tex_fallback = GL_TRUE;
|
||||
|
|
@ -900,7 +940,10 @@ sisFlushPrimsLocked(sisContextPtr smesa)
|
|||
if (smesa->vb_cur == smesa->vb_last)
|
||||
return;
|
||||
|
||||
sisUpdateHWState(smesa->glCtx);
|
||||
if (smesa->is6326)
|
||||
sis6326UpdateHWState(smesa->glCtx);
|
||||
else
|
||||
sisUpdateHWState(smesa->glCtx);
|
||||
|
||||
if (smesa->using_agp) {
|
||||
mWait3DCmdQueue(8);
|
||||
|
|
@ -926,6 +969,8 @@ sisFlushPrimsLocked(sisContextPtr smesa)
|
|||
mmio_index |= VERT_UV0;
|
||||
if (smesa->AGPParseSet & SiS_PS_HAS_UV1)
|
||||
mmio_index |= VERT_UV1;
|
||||
if (smesa->is6326)
|
||||
mmio_index |= VERT_6326;
|
||||
|
||||
switch (smesa->AGPParseSet & MASK_PsDataType) {
|
||||
case MASK_PsPointList:
|
||||
|
|
@ -941,9 +986,11 @@ sisFlushPrimsLocked(sisContextPtr smesa)
|
|||
sis_emit_func = sis_tri_func_mmio[mmio_index];
|
||||
break;
|
||||
}
|
||||
|
||||
mWait3DCmdQueue(1);
|
||||
MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet);
|
||||
|
||||
if (!smesa->is6326) {
|
||||
mWait3DCmdQueue(1);
|
||||
MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet);
|
||||
}
|
||||
while (smesa->vb_last < smesa->vb_cur) {
|
||||
sis_emit_func(smesa, smesa->vb_last);
|
||||
smesa->vb_last += incr;
|
||||
|
|
@ -976,6 +1023,7 @@ static const char * const fallbackStrings[] = {
|
|||
"Texture 1 env", /* Note: unused */
|
||||
"glDrawBuffer(GL_FRONT_AND_BACK)",
|
||||
"glEnable(GL_STENCIL) without hw stencil buffer",
|
||||
"write mask",
|
||||
"no_rast",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
/* $XFree86*/ /* -*- c-basic-offset: 3 -*- */
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 2003 Eric Anholt
|
||||
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
|
||||
on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
license, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
ERIC ANHOLT 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright 2005 Eric Anholt
|
||||
* 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, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <anholt@FreeBSD.org>
|
||||
* Eric Anholt <anholt@FreeBSD.org>
|
||||
* Jim Duchek <jim@linuxpimps.com> -- Utah GLX 6326 code
|
||||
* Alan Cox <alan@redhat.com> -- 6326 Debugging
|
||||
*
|
||||
*/
|
||||
|
||||
static void TAG(sis_draw_tri_mmio)(sisContextPtr smesa, char *verts)
|
||||
|
|
@ -59,11 +59,191 @@ static void TAG(sis_draw_point_mmio)(sisContextPtr smesa, char *verts)
|
|||
SIS_MMIO_WRITE_VERTEX(v0, 1, 1);
|
||||
}
|
||||
|
||||
#if !(SIS_STATES & VERT_UV1)
|
||||
static void TAG(sis6326_draw_tri_mmio)(sisContextPtr smesa, char *verts)
|
||||
{
|
||||
sisVertexPtr v0 = (sisVertexPtr)verts;
|
||||
sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4);
|
||||
sisVertexPtr v2 = (sisVertexPtr)(verts + smesa->vertex_size * 4 * 2);
|
||||
GLfloat x0, x1, x2;
|
||||
GLfloat y0, y1, y2;
|
||||
GLfloat delt02, diffx02, diffy02, diffy12;
|
||||
GLint dwPrimitiveSet = smesa->dwPrimitiveSet;
|
||||
sisVertex tv0, tv1, tv2;
|
||||
|
||||
/* XXX Culling? */
|
||||
|
||||
tv0 = *v0;
|
||||
tv1 = *v1;
|
||||
tv2 = *v2;
|
||||
tv0.v.y = Y_FLIP(tv0.v.y);
|
||||
tv1.v.y = Y_FLIP(tv1.v.y);
|
||||
tv2.v.y = Y_FLIP(tv2.v.y);
|
||||
v0 = &tv0;
|
||||
v1 = &tv1;
|
||||
v2 = &tv2;
|
||||
|
||||
/* Cull polygons we won't draw. The hardware draws funky things if it
|
||||
is fed these */
|
||||
if((((v1->v.x - v0->v.x) * (v0->v.y - v2->v.y)) +
|
||||
((v1->v.y - v0->v.y) * (v2->v.x - v0->v.x))) < 0)
|
||||
return;
|
||||
y0 = v0->v.y;
|
||||
y1 = v1->v.y;
|
||||
y2 = v2->v.y;
|
||||
|
||||
|
||||
if (y0 > y1) {
|
||||
if (y1 > y2) {
|
||||
x0 = v0->v.x;
|
||||
x1 = v1->v.x;
|
||||
x2 = v2->v.x;
|
||||
dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_BMID | OP_6326_3D_CBOT;
|
||||
if ((SIS_STATES & VERT_SMOOTH) == 0)
|
||||
dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_BOT;
|
||||
} else {
|
||||
if (y0 > y2) {
|
||||
x0 = v0->v.x;
|
||||
x1 = v2->v.x;
|
||||
y1 = v2->v.y;
|
||||
dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_CMID |
|
||||
OP_6326_3D_BBOT;
|
||||
if ((SIS_STATES & VERT_SMOOTH) == 0)
|
||||
dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_MID;
|
||||
} else {
|
||||
x0 = v2->v.x;
|
||||
y0 = v2->v.y;
|
||||
x1 = v0->v.x;
|
||||
y1 = v0->v.y;
|
||||
dwPrimitiveSet |= OP_6326_3D_CTOP | OP_6326_3D_AMID |
|
||||
OP_6326_3D_BBOT;
|
||||
if ((SIS_STATES & VERT_SMOOTH) == 0)
|
||||
dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_TOP;
|
||||
}
|
||||
x2 = v1->v.x;
|
||||
y2 = v1->v.y;
|
||||
}
|
||||
} else {
|
||||
if (y0 > y2) {
|
||||
x0 = v1->v.x;
|
||||
y0 = v1->v.y;
|
||||
x1 = v0->v.x;
|
||||
y1 = v0->v.y;
|
||||
x2 = v2->v.x;
|
||||
dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_AMID | OP_6326_3D_CBOT;
|
||||
if ((SIS_STATES & VERT_SMOOTH) == 0)
|
||||
dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_BOT;
|
||||
} else {
|
||||
if (y1 > y2) {
|
||||
x0 = v1->v.x;
|
||||
y0 = v1->v.y;
|
||||
x1 = v2->v.x;
|
||||
y1 = v2->v.y;
|
||||
dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_CMID |
|
||||
OP_6326_3D_ABOT;
|
||||
if ((SIS_STATES & VERT_SMOOTH) == 0)
|
||||
dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_MID;
|
||||
} else {
|
||||
x0 = v2->v.x;
|
||||
y0 = v2->v.y;
|
||||
x1 = v1->v.x;
|
||||
dwPrimitiveSet |= OP_6326_3D_CTOP | OP_6326_3D_BMID |
|
||||
OP_6326_3D_ABOT;
|
||||
if ((SIS_STATES & VERT_SMOOTH) == 0)
|
||||
dwPrimitiveSet |= OP_6326_3D_SHADE_FLAT_TOP;
|
||||
}
|
||||
x2 = v0->v.x;
|
||||
y2 = v0->v.y;
|
||||
}
|
||||
}
|
||||
|
||||
if (x1 <= x0 && x1 <= x2) {
|
||||
dwPrimitiveSet |= OP_3D_DIRECTION_LEFT;
|
||||
} else if (x1 < x0 || x1 < x2) {
|
||||
GLfloat tmp;
|
||||
|
||||
diffx02 = x0 - x2;
|
||||
diffy02 = y0 - y2;
|
||||
diffy12 = y1 - y2;
|
||||
|
||||
delt02 = diffx02 / diffy02;
|
||||
tmp = x1 - (diffy12 * delt02 + x2);
|
||||
|
||||
if (tmp <= 0.0)
|
||||
dwPrimitiveSet |= OP_3D_DIRECTION_LEFT;
|
||||
}
|
||||
|
||||
tv0 = *v0;
|
||||
tv1 = *v1;
|
||||
tv2 = *v2;
|
||||
tv0.v.y = Y_FLIP(tv0.v.y);
|
||||
tv1.v.y = Y_FLIP(tv1.v.y);
|
||||
tv2.v.y = Y_FLIP(tv2.v.y);
|
||||
v0 = &tv0;
|
||||
v1 = &tv1;
|
||||
v2 = &tv2;
|
||||
|
||||
y0 = v0->v.y;
|
||||
y1 = v1->v.y;
|
||||
y2 = v2->v.y;
|
||||
|
||||
/* fprintf(stderr, "Vertex0 %f %f %f\n", v0->v.x, v0->v.y, v0->v.z);
|
||||
fprintf(stderr, "Vertex1 %f %f %f\n", v1->v.x, v1->v.y, v1->v.z);
|
||||
fprintf(stderr, "Vertex2 %f %f %f\n", v2->v.x, v2->v.y, v2->v.z);*/
|
||||
mWait3DCmdQueue(MMIO_VERT_REG_COUNT * 3 + 1);
|
||||
MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet);
|
||||
SIS_MMIO_WRITE_VERTEX(v0, 0, 0);
|
||||
SIS_MMIO_WRITE_VERTEX(v1, 1, 0);
|
||||
SIS_MMIO_WRITE_VERTEX(v2, 2, 1);
|
||||
mEndPrimitive();
|
||||
}
|
||||
|
||||
static void TAG(sis6326_draw_line_mmio)(sisContextPtr smesa, char *verts)
|
||||
{
|
||||
sisVertexPtr v0 = (sisVertexPtr)verts;
|
||||
sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4);
|
||||
GLint dwPrimitiveSet = smesa->dwPrimitiveSet;
|
||||
|
||||
if (abs(v0->v.y - v1->v.y) > abs(v0->v.x - v1->v.x))
|
||||
{
|
||||
dwPrimitiveSet |= OP_3D_DIRECTION_VERTICAL;
|
||||
if (v0->v.y > v1->v.y)
|
||||
dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_BBOT;
|
||||
else
|
||||
dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_ABOT;
|
||||
} else {
|
||||
if (v0->v.y > v1->v.y)
|
||||
dwPrimitiveSet |= OP_6326_3D_BTOP | OP_6326_3D_ABOT;
|
||||
else
|
||||
dwPrimitiveSet |= OP_6326_3D_ATOP | OP_6326_3D_BBOT;
|
||||
}
|
||||
|
||||
mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2 + 1);
|
||||
MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet);
|
||||
SIS_MMIO_WRITE_VERTEX(v0, 0, 0);
|
||||
SIS_MMIO_WRITE_VERTEX(v1, 1, 1);
|
||||
}
|
||||
|
||||
static void TAG(sis6326_draw_point_mmio)(sisContextPtr smesa, char *verts)
|
||||
{
|
||||
sisVertexPtr v0 = (sisVertexPtr)verts;
|
||||
|
||||
mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1 + 1);
|
||||
MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet | OP_6326_3D_ATOP);
|
||||
SIS_MMIO_WRITE_VERTEX(v0, 1, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline void TAG(sis_vert_init)( void )
|
||||
{
|
||||
sis_tri_func_mmio[SIS_STATES] = TAG(sis_draw_tri_mmio);
|
||||
sis_line_func_mmio[SIS_STATES] = TAG(sis_draw_line_mmio);
|
||||
sis_point_func_mmio[SIS_STATES] = TAG(sis_draw_point_mmio);
|
||||
#if !(SIS_STATES & VERT_UV1)
|
||||
sis_tri_func_mmio[SIS_STATES | VERT_6326] = TAG(sis6326_draw_tri_mmio);
|
||||
sis_line_func_mmio[SIS_STATES | VERT_6326] = TAG(sis6326_draw_line_mmio);
|
||||
sis_point_func_mmio[SIS_STATES | VERT_6326] = TAG(sis6326_draw_point_mmio);
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef TAG
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue