svga3d_shaderdefs.h revision 332aaa1da374e694e37fdfe0a00bbe040e670453
/**********************************************************
* Copyright 2007-2009 VMware, 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,
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 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.
*
**********************************************************/
/*
* svga3d_shaderdefs.h --
*
* SVGA3D byte code format and limit definitions.
*
* The format of the byte code directly corresponds to that defined
* by Microsoft DirectX SDK 9.0c (file d3d9types.h). The format can
* also be extended so that different shader formats can be supported
*
*/
#ifndef __SVGA3D_SHADER_DEFS__
#define __SVGA3D_SHADER_DEFS__
/* SVGA3D shader hardware limits. */
#define SVGA3D_INPUTREG_MAX 16
#define SVGA3D_OUTPUTREG_MAX 12
#define SVGA3D_VERTEX_SAMPLERREG_MAX 4
#define SVGA3D_PIXEL_SAMPLERREG_MAX 16
#define SVGA3D_SAMPLERREG_MAX (SVGA3D_PIXEL_SAMPLERREG_MAX+\
#define SVGA3D_TEMPREG_MAX 32
#define SVGA3D_CONSTREG_MAX 256
#define SVGA3D_CONSTINTREG_MAX 16
#define SVGA3D_CONSTBOOLREG_MAX 16
#define SVGA3D_ADDRREG_MAX 1
#define SVGA3D_PREDREG_MAX 1
/* SVGA3D byte code specific limits */
#define SVGA3D_MAX_SRC_REGS 4
#define SVGA3D_MAX_NESTING_LEVEL 32
/* SVGA3D version information. */
#define SVGA3D_VS_TYPE 0xFFFE
#define SVGA3D_PS_TYPE 0xFFFF
typedef struct {
union {
struct {
} s;
};
/* The *_ENABLED are for backwards compatibility with old drivers */
typedef enum {
SVGA3DPSVERSION_NONE = 0,
SVGA3DPSVERSION_11 = 3,
SVGA3DPSVERSION_12 = 5,
SVGA3DPSVERSION_13 = 7,
SVGA3DPSVERSION_14 = 9,
SVGA3DPSVERSION_20 = 11,
SVGA3DPSVERSION_30 = 13,
SVGA3DPSVERSION_40 = 15,
typedef enum {
SVGA3DVSVERSION_NONE = 0,
SVGA3DVSVERSION_11 = 3,
SVGA3DVSVERSION_20 = 5,
SVGA3DVSVERSION_30 = 7,
SVGA3DVSVERSION_40 = 9,
/* SVGA3D instruction op codes. */
typedef enum {
SVGA3DOP_NOP = 0,
SVGA3DOP_TEXCOORD = 64,
SVGA3DOP_TEXREG2GB = 70,
SVGA3DOP_CND = 80,
SVGA3DOP_DP2ADD = 90,
SVGA3DOP_BREAKP = 96,
SVGA3DOP_PHASE = 0xFFFD,
SVGA3DOP_COMMENT = 0xFFFE,
SVGA3DOP_END = 0xFFFF
/* SVGA3D operation control/comparison function types */
typedef enum {
SVGA3DOPCONT_PROJECT, /* Projective texturing */
SVGA3DOPCONT_BIAS /* Texturing with a LOD bias */
typedef enum {
/* SVGA3D register types */
typedef enum {
SVGA3DREG_TEMP = 0, /* Temporary register file */
SVGA3DREG_INPUT, /* Input register file */
SVGA3DREG_CONST, /* Constant register file */
SVGA3DREG_ADDR, /* Address register for VS */
SVGA3DREG_RASTOUT, /* Rasterizer register file */
SVGA3DREG_ATTROUT, /* Attribute output register file */
SVGA3DREG_TEXCRDOUT, /* Texture coordinate output register file */
SVGA3DREG_CONSTINT, /* Constant integer vector register file */
SVGA3DREG_COLOROUT, /* Color output register file */
SVGA3DREG_DEPTHOUT, /* Depth output register file */
SVGA3DREG_SAMPLER, /* Sampler state register file */
SVGA3DREG_CONST2, /* Constant register file 2048 - 4095 */
SVGA3DREG_CONST3, /* Constant register file 4096 - 6143 */
SVGA3DREG_CONST4, /* Constant register file 6144 - 8191 */
SVGA3DREG_CONSTBOOL, /* Constant boolean register file */
SVGA3DREG_LOOP, /* Loop counter register file */
SVGA3DREG_TEMPFLOAT16, /* 16-bit float temp register file */
SVGA3DREG_MISCTYPE, /* Miscellaneous (single) registers */
SVGA3DREG_LABEL, /* Label */
SVGA3DREG_PREDICATE /* Predicate register */
/* SVGA3D rasterizer output register types */
typedef enum {
/* SVGA3D miscellaneous register types */
typedef enum {
SVGA3DMISCREG_POSITION = 0, /* Input position x,y,z,rhw (PS) */
SVGA3DMISCREG_FACE /* Floating point primitive area (PS) */
/* SVGA3D sampler types */
typedef enum {
SVGA3DSAMP_UNKNOWN = 0, /* Uninitialized value */
SVGA3DSAMP_CUBE, /* dcl_cube s# (for declaring a cube texture) */
SVGA3DSAMP_VOLUME /* dcl_volume s# (for declaring a volume texture) */
/* SVGA3D sampler format classes */
typedef enum {
SVGA3DSAMPFORMAT_ARGB, /* ARGB formats */
SVGA3DSAMPFORMAT_V8U8, /* Sign and normalize (SNORM) V & U */
SVGA3DSAMPFORMAT_Q8W8V8U8, /* SNORM all */
SVGA3DSAMPFORMAT_CxV8U8, /* SNORM V & U, C=SQRT(1-U^2-V^2) */
SVGA3DSAMPFORMAT_X8L8V8U8, /* SNORM V & U */
SVGA3DSAMPFORMAT_A2W10V10U10, /* SNORM W, V & U */
SVGA3DSAMPFORMAT_DXT_PMA, /* DXT pre-multiplied alpha */
SVGA3DSAMPFORMAT_YUV, /* YUV video format */
SVGA3DSAMPFORMAT_UYVY, /* UYVY video format */
SVGA3DSAMPFORMAT_Rx, /* R16F/32F */
SVGA3DSAMPFORMAT_RxGx, /* R16FG16F, R32FG32F */
SVGA3DSAMPFORMAT_V16U16 /* SNORM all */
/* SVGA3D write mask */
/* SVGA3D destination modifiers */
#define SVGA3DDSTMOD_NONE 0 /* nop */
/*
* Relevant to multisampling only:
* When the pixel center is not covered, sample
* using multisample "centroid" location.
* "Centroid" is some location within the covered
* region of the pixel.
*/
#define SVGA3DDSTMOD_MSAMPCENTROID 4
/* SVGA3D source swizzle */
#define SVGA3DSWIZZLE_REPLICATEX 0x00
#define SVGA3DSWIZZLE_REPLICATEY 0x55
#define SVGA3DSWIZZLE_REPLICATEZ 0xAA
#define SVGA3DSWIZZLE_REPLICATEW 0xFF
#define SVGA3DSWIZZLE_NONE 0xE4
#define SVGA3DSWIZZLE_YZXW 0xC9
#define SVGA3DSWIZZLE_ZXYW 0xD2
#define SVGA3DSWIZZLE_WXYZ 0x1B
/* SVGA3D source modifiers */
typedef enum {
SVGA3DSRCMOD_NONE = 0, /* nop */
SVGA3DSRCMOD_NEG, /* negate */
SVGA3DSRCMOD_BIAS, /* bias */
SVGA3DSRCMOD_BIASNEG, /* bias and negate */
SVGA3DSRCMOD_SIGN, /* sign */
SVGA3DSRCMOD_SIGNNEG, /* sign and negate */
SVGA3DSRCMOD_COMP, /* complement */
SVGA3DSRCMOD_X2, /* x2 */
SVGA3DSRCMOD_X2NEG, /* x2 and negate */
SVGA3DSRCMOD_DZ, /* divide through by z component */
SVGA3DSRCMOD_DW, /* divide through by w component */
SVGA3DSRCMOD_ABS, /* abs() */
SVGA3DSRCMOD_ABSNEG, /* -abs() */
SVGA3DSRCMOD_NOT /* ! (for predicate register) */
/* SVGA3D instruction token */
typedef struct {
union {
struct {
} s;
struct {
} s1;
};
/* SVGA3D destination parameter token */
typedef struct {
union {
struct {
} s;
};
/* SVGA3D source parameter token */
typedef struct {
union {
struct {
} s;
};
/* SVGA3DOP_DCL parameter tokens */
typedef struct {
union {
struct {
union {
struct {
} s; /* input / output declaration */
struct {
} s1; /* sampler declaration */
};
} s2;
};
/* SVGA3DOP_DEF parameter tokens */
typedef struct {
union {
struct {
union {
float constValues[4];
int constIValues[4];
bool constBValue;
};
} s;
};
/* SVGA3D shader token */
typedef union {
/* SVGA3D shader program */
typedef struct {
/* SVGA3dShaderToken stream */
#if 0
/* SVGA3D version specific register assignments */
static const uint32_t SVGA3D_INPUT_REG_POSITION_VS11 = 0;
static const uint32_t SVGA3D_INPUT_REG_COLOR_BASE_PS11 = 0;
static const uint32_t SVGA3D_OUTPUT_REG_DEPTH_PS11 = 0;
static const uint32_t SVGA3D_INPUT_REG_COLOR_BASE_PS20 = 0;
static const uint32_t SVGA3D_OUTPUT_REG_DEPTH_BASE_PS20 = 0;
/*
*----------------------------------------------------------------------
*
* SVGA3dShaderGetRegType --
*
* As the register type is split into two non sequential fields,
* this function provides an useful way of accessing the actual
* register type without having to manually concatenate the
* type_upper and type_lower fields.
*
* Results:
* Returns the register type.
*
*----------------------------------------------------------------------
*/
static INLINE SVGA3dShaderRegType
{
}
#endif
#endif /* __SVGA3D_SHADER_DEFS__ */