projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mesa: Move is_power_of_two() function from brw_context.h to macros.h.
[mesa.git]
/
src
/
mesa
/
tnl
/
t_vertex.c
diff --git
a/src/mesa/tnl/t_vertex.c
b/src/mesa/tnl/t_vertex.c
index d3955873dcdec7a168230a19cc2f71e965507c90..b3deac02491b6081e55f94a31b5793a1c3eaeba5 100644
(file)
--- a/
src/mesa/tnl/t_vertex.c
+++ b/
src/mesa/tnl/t_vertex.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 2003
Tungsten Graphics, i
nc.
+ * Copyright 2003
VMware, I
nc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@
-16,19
+16,19
@@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE 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
- *
TUNGSTEN GRAPHICS
AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ *
VMWARE
AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* 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:
- * Keith Whitwell <keithw@
tungstengraphics
.com>
+ * Keith Whitwell <keithw@
vmware
.com>
*/
#include "main/glheader.h"
#include "main/context.h"
#include "main/colormac.h"
*/
#include "main/glheader.h"
#include "main/context.h"
#include "main/colormac.h"
-
+#include "swrast/s_chan.h"
#include "t_context.h"
#include "t_vertex.h"
#include "t_context.h"
#include "t_vertex.h"
@@
-87,8
+87,8
@@
void _tnl_register_fastpath( struct tnl_clipspace *vtx,
fastpath->attr_count = vtx->attr_count;
fastpath->match_strides = match_strides;
fastpath->func = vtx->emit;
fastpath->attr_count = vtx->attr_count;
fastpath->match_strides = match_strides;
fastpath->func = vtx->emit;
- fastpath->attr =
(struct tnl_attr_type *)
-
_mesa_
malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
+ fastpath->attr =
+ malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
for (i = 0; i < vtx->attr_count; i++) {
fastpath->attr[i].format = vtx->attr[i].format;
for (i = 0; i < vtx->attr_count; i++) {
fastpath->attr[i].format = vtx->attr[i].format;
@@
-106,7
+106,7
@@
void _tnl_register_fastpath( struct tnl_clipspace *vtx,
/***********************************************************************
* Build codegen functions or return generic ones:
*/
/***********************************************************************
* Build codegen functions or return generic ones:
*/
-static void choose_emit_func(
GL
context *ctx, GLuint count, GLubyte *dest)
+static void choose_emit_func(
struct gl_
context *ctx, GLuint count, GLubyte *dest)
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
@@
-150,15
+150,17
@@
static void choose_emit_func( GLcontext *ctx, GLuint count, GLubyte *dest)
-static void choose_interp_func(
GL
context *ctx,
+static void choose_interp_func(
struct gl_
context *ctx,
GLfloat t,
GLuint edst, GLuint eout, GLuint ein,
GLboolean force_boundary )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
GLfloat t,
GLuint edst, GLuint eout, GLuint ein,
GLboolean force_boundary )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL);
+ GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
- if (vtx->need_extras &&
- (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ if (vtx->need_extras && (twosided || unfilled)) {
vtx->interp = _tnl_generic_interp_extras;
} else {
vtx->interp = _tnl_generic_interp;
vtx->interp = _tnl_generic_interp_extras;
} else {
vtx->interp = _tnl_generic_interp;
@@
-168,12
+170,15
@@
static void choose_interp_func( GLcontext *ctx,
}
}
-static void choose_copy_pv_func(
GL
context *ctx, GLuint edst, GLuint esrc )
+static void choose_copy_pv_func(
struct gl_
context *ctx, GLuint edst, GLuint esrc )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL);
+
+ GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
- if (vtx->need_extras &&
- (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ if (vtx->need_extras && (twosided || unfilled)) {
vtx->copy_pv = _tnl_generic_copy_pv_extras;
} else {
vtx->copy_pv = _tnl_generic_copy_pv;
vtx->copy_pv = _tnl_generic_copy_pv_extras;
} else {
vtx->copy_pv = _tnl_generic_copy_pv;
@@
-190,7
+195,7
@@
static void choose_copy_pv_func( GLcontext *ctx, GLuint edst, GLuint esrc )
/* Interpolate between two vertices to produce a third:
*/
/* Interpolate between two vertices to produce a third:
*/
-void _tnl_interp(
GL
context *ctx,
+void _tnl_interp(
struct gl_
context *ctx,
GLfloat t,
GLuint edst, GLuint eout, GLuint ein,
GLboolean force_boundary )
GLfloat t,
GLuint edst, GLuint eout, GLuint ein,
GLboolean force_boundary )
@@
-201,7
+206,7
@@
void _tnl_interp( GLcontext *ctx,
/* Copy colors from one vertex to another:
*/
/* Copy colors from one vertex to another:
*/
-void _tnl_copy_pv(
GL
context *ctx, GLuint edst, GLuint esrc )
+void _tnl_copy_pv(
struct gl_
context *ctx, GLuint edst, GLuint esrc )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
vtx->copy_pv( ctx, edst, esrc );
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
vtx->copy_pv( ctx, edst, esrc );
@@
-212,7
+217,7
@@
void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
* reverse any viewport transformation, swizzling or other conversions
* which may have been applied:
*/
* reverse any viewport transformation, swizzling or other conversions
* which may have been applied:
*/
-void _tnl_get_attr(
GL
context *ctx, const void *vin,
+void _tnl_get_attr(
struct gl_
context *ctx, const void *vin,
GLenum attr, GLfloat *dest )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
GLenum attr, GLfloat *dest )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
@@
-231,19
+236,19
@@
void _tnl_get_attr( GLcontext *ctx, const void *vin,
*/
if (attr == _TNL_ATTRIB_POINTSIZE) {
/* If the hardware vertex doesn't have point size then use size from
*/
if (attr == _TNL_ATTRIB_POINTSIZE) {
/* If the hardware vertex doesn't have point size then use size from
- *
GL
context. XXX this will be wrong if drawing attenuated points!
+ *
struct gl_
context. XXX this will be wrong if drawing attenuated points!
*/
dest[0] = ctx->Point.Size;
}
else {
*/
dest[0] = ctx->Point.Size;
}
else {
-
_mesa_
memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat));
+ memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat));
}
}
/* Complementary operation to the above.
*/
}
}
/* Complementary operation to the above.
*/
-void _tnl_set_attr(
GL
context *ctx, void *vout,
+void _tnl_set_attr(
struct gl_
context *ctx, void *vout,
GLenum attr, const GLfloat *src )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
GLenum attr, const GLfloat *src )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
@@
-260,16
+265,17
@@
void _tnl_set_attr( GLcontext *ctx, void *vout,
}
}
-void *_tnl_get_vertex(
GL
context *ctx, GLuint nr )
+void *_tnl_get_vertex(
struct gl_
context *ctx, GLuint nr )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
return vtx->vertex_buf + nr * vtx->vertex_size;
}
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
return vtx->vertex_buf + nr * vtx->vertex_size;
}
-void _tnl_invalidate_vertex_state(
GL
context *ctx, GLuint new_state )
+void _tnl_invalidate_vertex_state(
struct gl_
context *ctx, GLuint new_state )
{
{
- if (new_state & (_DD_NEW_TRI_LIGHT_TWOSIDE|_DD_NEW_TRI_UNFILLED) ) {
+ /* if two-sided lighting changes or filled/unfilled polygon state changes */
+ if (new_state & (_NEW_LIGHT | _NEW_POLYGON) ) {
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
vtx->new_inputs = ~0;
vtx->interp = choose_interp_func;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
vtx->new_inputs = ~0;
vtx->interp = choose_interp_func;
@@
-285,7
+291,7
@@
static void invalidate_funcs( struct tnl_clipspace *vtx )
vtx->new_inputs = ~0;
}
vtx->new_inputs = ~0;
}
-GLuint _tnl_install_attrs(
GL
context *ctx, const struct tnl_attr_map *map,
+GLuint _tnl_install_attrs(
struct gl_
context *ctx, const struct tnl_attr_map *map,
GLuint nr, const GLfloat *vp,
GLuint unpacked_size )
{
GLuint nr, const GLfloat *vp,
GLuint unpacked_size )
{
@@
-307,8
+313,8
@@
GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map,
const GLuint format = map[i].format;
if (format == EMIT_PAD) {
if (DBG)
const GLuint format = map[i].format;
if (format == EMIT_PAD) {
if (DBG)
-
_mesa_
printf("%d: pad %d, offset %d\n", i,
-
map[i].offset, offset);
+ printf("%d: pad %d, offset %d\n", i,
+ map[i].offset, offset);
offset += map[i].offset;
offset += map[i].offset;
@@
-338,9
+344,9
@@
GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map,
if (DBG)
if (DBG)
-
_mesa_
printf("%d: %s, vp %p, offset %d\n", i,
-
_tnl_format_info[format].name, (void *)vp,
-
vtx->attr[j].vertoffset);
+ printf("%d: %s, vp %p, offset %d\n", i,
+ _tnl_format_info[format].name, (void *)vp,
+ vtx->attr[j].vertoffset);
offset += _tnl_format_info[format].attrsize;
j++;
offset += _tnl_format_info[format].attrsize;
j++;
@@
-360,7
+366,7
@@
GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map,
-void _tnl_invalidate_vertices(
GL
context *ctx, GLuint newinputs )
+void _tnl_invalidate_vertices(
struct gl_
context *ctx, GLuint newinputs )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
vtx->new_inputs |= newinputs;
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
vtx->new_inputs |= newinputs;
@@
-370,14
+376,14
@@
void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs )
/* This event has broader use beyond this file - will move elsewhere
* and probably invoke a driver callback.
*/
/* This event has broader use beyond this file - will move elsewhere
* and probably invoke a driver callback.
*/
-void _tnl_notify_pipeline_output_change(
GL
context *ctx )
+void _tnl_notify_pipeline_output_change(
struct gl_
context *ctx )
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
invalidate_funcs(vtx);
}
{
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
invalidate_funcs(vtx);
}
-static void adjust_input_ptrs(
GL
context *ctx, GLint diff)
+static void adjust_input_ptrs(
struct gl_
context *ctx, GLint diff)
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
@@
-392,7
+398,7
@@
static void adjust_input_ptrs( GLcontext *ctx, GLint diff)
}
}
}
}
-static void update_input_ptrs(
GL
context *ctx, GLuint start )
+static void update_input_ptrs(
struct gl_
context *ctx, GLuint start )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
@@
-424,7
+430,7
@@
static void update_input_ptrs( GLcontext *ctx, GLuint start )
}
}
-void _tnl_build_vertices(
GL
context *ctx,
+void _tnl_build_vertices(
struct gl_
context *ctx,
GLuint start,
GLuint end,
GLuint newinputs )
GLuint start,
GLuint end,
GLuint newinputs )
@@
-439,7
+445,7
@@
void _tnl_build_vertices( GLcontext *ctx,
/* Emit VB vertices start..end to dest. Note that VB vertex at
* postion start will be emitted to dest at position zero.
*/
/* Emit VB vertices start..end to dest. Note that VB vertex at
* postion start will be emitted to dest at position zero.
*/
-void *_tnl_emit_vertices_to_buffer(
GL
context *ctx,
+void *_tnl_emit_vertices_to_buffer(
struct gl_
context *ctx,
GLuint start,
GLuint end,
void *dest )
GLuint start,
GLuint end,
void *dest )
@@
-457,7
+463,7
@@
void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
* postion start will be emitted to dest at position zero.
*/
* postion start will be emitted to dest at position zero.
*/
-void *_tnl_emit_indexed_vertices_to_buffer(
GL
context *ctx,
+void *_tnl_emit_indexed_vertices_to_buffer(
struct gl_
context *ctx,
const GLuint *elts,
GLuint start,
GLuint end,
const GLuint *elts,
GLuint start,
GLuint end,
@@
-482,7
+488,7
@@
void *_tnl_emit_indexed_vertices_to_buffer( GLcontext *ctx,
}
}
-void _tnl_init_vertices(
GL
context *ctx,
+void _tnl_init_vertices(
struct gl_
context *ctx,
GLuint vb_size,
GLuint max_vertex_size )
{
GLuint vb_size,
GLuint max_vertex_size )
{
@@
-494,7
+500,7
@@
void _tnl_init_vertices( GLcontext *ctx,
if (max_vertex_size > vtx->max_vertex_size) {
_tnl_free_vertices( ctx );
vtx->max_vertex_size = max_vertex_size;
if (max_vertex_size > vtx->max_vertex_size) {
_tnl_free_vertices( ctx );
vtx->max_vertex_size = max_vertex_size;
- vtx->vertex_buf =
(GLubyte *)ALIGN_CALLOC
(vb_size * max_vertex_size, 32 );
+ vtx->vertex_buf =
_mesa_align_calloc
(vb_size * max_vertex_size, 32 );
invalidate_funcs(vtx);
}
invalidate_funcs(vtx);
}
@@
-533,21
+539,19
@@
void _tnl_init_vertices( GLcontext *ctx,
}
}
-void _tnl_free_vertices(
GL
context *ctx )
+void _tnl_free_vertices(
struct gl_
context *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
if (tnl) {
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
struct tnl_clipspace_fastpath *fp, *tmp;
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
if (tnl) {
struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
struct tnl_clipspace_fastpath *fp, *tmp;
- if (vtx->vertex_buf) {
- ALIGN_FREE(vtx->vertex_buf);
- vtx->vertex_buf = NULL;
- }
+ _mesa_align_free(vtx->vertex_buf);
+ vtx->vertex_buf = NULL;
for (fp = vtx->fastpath ; fp ; fp = tmp) {
tmp = fp->next;
for (fp = vtx->fastpath ; fp ; fp = tmp) {
tmp = fp->next;
-
FREE
(fp->attr);
+
free
(fp->attr);
/* KW: At the moment, fp->func is constrained to be allocated by
* _mesa_exec_alloc(), as the hardwired fastpaths in
/* KW: At the moment, fp->func is constrained to be allocated by
* _mesa_exec_alloc(), as the hardwired fastpaths in
@@
-556,7
+560,7
@@
void _tnl_free_vertices( GLcontext *ctx )
* module gets another overhaul.
*/
_mesa_exec_free((void *) fp->func);
* module gets another overhaul.
*/
_mesa_exec_free((void *) fp->func);
-
FREE
(fp);
+
free
(fp);
}
vtx->fastpath = NULL;
}
vtx->fastpath = NULL;