mesa: Fix compiler warnings
Add explicit casts, fix constant types, fix variable types. Fixes about 340 warnings in MSFT Visual Studio.
This commit is contained in:
@@ -236,7 +236,7 @@ make_color_buffer_mask(GLcontext *ctx, GLint drawbuffer)
|
||||
mask |= BUFFER_BIT_BACK_RIGHT;
|
||||
break;
|
||||
default:
|
||||
if (drawbuffer < 0 || drawbuffer >= ctx->Const.MaxDrawBuffers) {
|
||||
if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) {
|
||||
mask = INVALID_MASK;
|
||||
}
|
||||
else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) {
|
||||
@@ -306,11 +306,11 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
|
||||
* floating point state var. This will not always work. We'll
|
||||
* need a new ctx->Driver.ClearBuffer() hook....
|
||||
*/
|
||||
GLfloat clearSave[4];
|
||||
GLclampf clearSave[4];
|
||||
/* save color */
|
||||
COPY_4V(clearSave, ctx->Color.ClearColor);
|
||||
/* set color */
|
||||
COPY_4V(ctx->Color.ClearColor, value);
|
||||
COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf);
|
||||
if (ctx->Driver.ClearColor)
|
||||
ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
|
||||
/* clear buffer(s) */
|
||||
@@ -365,11 +365,11 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
|
||||
* floating point state var. This will not always work. We'll
|
||||
* need a new ctx->Driver.ClearBuffer() hook....
|
||||
*/
|
||||
GLfloat clearSave[4];
|
||||
GLclampf clearSave[4];
|
||||
/* save color */
|
||||
COPY_4V(clearSave, ctx->Color.ClearColor);
|
||||
/* set color */
|
||||
COPY_4V(ctx->Color.ClearColor, value);
|
||||
COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf);
|
||||
if (ctx->Driver.ClearColor)
|
||||
ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
|
||||
/* clear buffer(s) */
|
||||
@@ -423,7 +423,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
|
||||
* XXX in the future we may have a new ctx->Driver.ClearBuffer()
|
||||
* hook instead.
|
||||
*/
|
||||
const GLfloat clearSave = ctx->Depth.Clear;
|
||||
const GLclampd clearSave = ctx->Depth.Clear;
|
||||
ctx->Depth.Clear = *value;
|
||||
if (ctx->Driver.ClearDepth)
|
||||
ctx->Driver.ClearDepth(ctx, *value);
|
||||
@@ -443,11 +443,11 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
|
||||
return;
|
||||
}
|
||||
else if (mask) {
|
||||
GLfloat clearSave[4];
|
||||
GLclampf clearSave[4];
|
||||
/* save color */
|
||||
COPY_4V(clearSave, ctx->Color.ClearColor);
|
||||
/* set color */
|
||||
COPY_4V(ctx->Color.ClearColor, value);
|
||||
COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf);
|
||||
if (ctx->Driver.ClearColor)
|
||||
ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor);
|
||||
/* clear buffer(s) */
|
||||
@@ -503,7 +503,7 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
|
||||
|
||||
{
|
||||
/* save current clear values */
|
||||
const GLfloat clearDepthSave = ctx->Depth.Clear;
|
||||
const GLclampd clearDepthSave = ctx->Depth.Clear;
|
||||
const GLuint clearStencilSave = ctx->Stencil.Clear;
|
||||
|
||||
/* set new clear values */
|
||||
|
||||
@@ -5662,7 +5662,7 @@ clip_right_or_top(GLint *srcX0, GLint *srcX1,
|
||||
/* chop off [t, 1] part */
|
||||
ASSERT(t >= 0.0 && t <= 1.0);
|
||||
*dstX1 = maxValue;
|
||||
bias = (*srcX0 < *srcX1) ? 0.5 : -0.5;
|
||||
bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
|
||||
*srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
|
||||
}
|
||||
else if (*dstX0 > maxValue) {
|
||||
@@ -5672,7 +5672,7 @@ clip_right_or_top(GLint *srcX0, GLint *srcX1,
|
||||
/* chop off [t, 1] part */
|
||||
ASSERT(t >= 0.0 && t <= 1.0);
|
||||
*dstX0 = maxValue;
|
||||
bias = (*srcX0 < *srcX1) ? -0.5 : 0.5;
|
||||
bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F;
|
||||
*srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
|
||||
}
|
||||
}
|
||||
@@ -5695,7 +5695,7 @@ clip_left_or_bottom(GLint *srcX0, GLint *srcX1,
|
||||
/* chop off [0, t] part */
|
||||
ASSERT(t >= 0.0 && t <= 1.0);
|
||||
*dstX0 = minValue;
|
||||
bias = (*srcX0 < *srcX1) ? 0.5 : -0.5; /* flipped??? */
|
||||
bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; /* flipped??? */
|
||||
*srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
|
||||
}
|
||||
else if (*dstX1 < minValue) {
|
||||
@@ -5705,7 +5705,7 @@ clip_left_or_bottom(GLint *srcX0, GLint *srcX1,
|
||||
/* chop off [0, t] part */
|
||||
ASSERT(t >= 0.0 && t <= 1.0);
|
||||
*dstX1 = minValue;
|
||||
bias = (*srcX0 < *srcX1) ? 0.5 : -0.5;
|
||||
bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
|
||||
*srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
|
||||
|
||||
|
||||
/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */
|
||||
#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0))
|
||||
#define UINT_TO_FLOAT(U) ((GLfloat) ((U) * (1.0F / 4294967295.0)))
|
||||
|
||||
/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
|
||||
#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
|
||||
|
||||
|
||||
/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
|
||||
#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0))
|
||||
#define INT_TO_FLOAT(I) ((GLfloat) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0)))
|
||||
|
||||
/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */
|
||||
/* causes overflow:
|
||||
|
||||
@@ -590,7 +590,7 @@ getteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
|
||||
{
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
const GLuint maxLevels = _mesa_max_texture_levels(ctx, target);
|
||||
const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
|
||||
GLenum baseFormat;
|
||||
|
||||
if (maxLevels == 0) {
|
||||
@@ -776,7 +776,7 @@ getcompressedteximage_error_check(GLcontext *ctx, GLenum target, GLint level,
|
||||
{
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
const GLuint maxLevels = _mesa_max_texture_levels(ctx, target);
|
||||
const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
|
||||
|
||||
if (maxLevels == 0) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)",
|
||||
|
||||
@@ -570,15 +570,15 @@ _mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program)
|
||||
inst->DstReg.Index + 1);
|
||||
}
|
||||
if (inst->SrcReg[0].File == PROGRAM_TEMPORARY) {
|
||||
program->NumTemporaries = MAX2(program->NumTemporaries,
|
||||
program->NumTemporaries = MAX2((GLint)program->NumTemporaries,
|
||||
inst->SrcReg[0].Index + 1);
|
||||
}
|
||||
if (inst->SrcReg[1].File == PROGRAM_TEMPORARY) {
|
||||
program->NumTemporaries = MAX2(program->NumTemporaries,
|
||||
program->NumTemporaries = MAX2((GLint)program->NumTemporaries,
|
||||
inst->SrcReg[1].Index + 1);
|
||||
}
|
||||
if (inst->SrcReg[2].File == PROGRAM_TEMPORARY) {
|
||||
program->NumTemporaries = MAX2(program->NumTemporaries,
|
||||
program->NumTemporaries = MAX2((GLint)program->NumTemporaries,
|
||||
inst->SrcReg[2].Index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,13 +599,13 @@ store_vector4ui(const struct prog_instruction *inst,
|
||||
|
||||
if (inst->CondUpdate) {
|
||||
if (writeMask & WRITEMASK_X)
|
||||
machine->CondCodes[0] = generate_cc(value[0]);
|
||||
machine->CondCodes[0] = generate_cc((float)value[0]);
|
||||
if (writeMask & WRITEMASK_Y)
|
||||
machine->CondCodes[1] = generate_cc(value[1]);
|
||||
machine->CondCodes[1] = generate_cc((float)value[1]);
|
||||
if (writeMask & WRITEMASK_Z)
|
||||
machine->CondCodes[2] = generate_cc(value[2]);
|
||||
machine->CondCodes[2] = generate_cc((float)value[2]);
|
||||
if (writeMask & WRITEMASK_W)
|
||||
machine->CondCodes[3] = generate_cc(value[3]);
|
||||
machine->CondCodes[3] = generate_cc((float)value[3]);
|
||||
#if DEBUG_PROG
|
||||
printf("CondCodes=(%s,%s,%s,%s) for:\n",
|
||||
_mesa_condcode_string(machine->CondCodes[0]),
|
||||
@@ -1000,7 +1000,7 @@ _mesa_execute_program(GLcontext * ctx,
|
||||
val = -FLT_MAX;
|
||||
}
|
||||
else {
|
||||
val = log(a[0]) * 1.442695F;
|
||||
val = (float)(log(a[0]) * 1.442695F);
|
||||
}
|
||||
result[0] = result[1] = result[2] = result[3] = val;
|
||||
store_vector4(inst, machine, result);
|
||||
@@ -1065,7 +1065,7 @@ _mesa_execute_program(GLcontext * ctx,
|
||||
/* The fast LOG2 macro doesn't meet the precision
|
||||
* requirements.
|
||||
*/
|
||||
q[2] = (log(t[0]) * 1.442695F);
|
||||
q[2] = (float)(log(t[0]) * 1.442695F);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -209,7 +209,7 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
|
||||
{
|
||||
/* first check if this is a duplicate constant */
|
||||
GLint pos;
|
||||
for (pos = 0; pos < paramList->NumParameters; pos++) {
|
||||
for (pos = 0; pos < (GLint)paramList->NumParameters; pos++) {
|
||||
const GLfloat *pvals = paramList->ParameterValues[pos];
|
||||
if (pvals[0] == values[0] &&
|
||||
pvals[1] == values[1] &&
|
||||
|
||||
@@ -3117,7 +3117,7 @@ _slang_can_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
|
||||
if (start >= end)
|
||||
return GL_FALSE; /* degenerate case */
|
||||
|
||||
if (end - start > MAX_FOR_LOOP_UNROLL_ITERATIONS) {
|
||||
if ((GLuint)(end - start) > MAX_FOR_LOOP_UNROLL_ITERATIONS) {
|
||||
slang_info_log_print(A->log,
|
||||
"Note: 'for (%s=%d; %s<%d; ++%s)' is too"
|
||||
" many iterations to unroll",
|
||||
|
||||
@@ -239,7 +239,7 @@ parse_general_number(slang_parse_ctx *ctx, float *number)
|
||||
}
|
||||
|
||||
parse_identifier_str(ctx, &flt);
|
||||
flt = strdup(flt);
|
||||
flt = _mesa_strdup(flt);
|
||||
if (!flt) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -328,11 +328,11 @@
|
||||
|
||||
#if defined(DO_ATTRIBS)
|
||||
/* compute attributes at left-most fragment */
|
||||
span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5, iy + 0.5F, wPlane);
|
||||
span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5F, iy + 0.5F, wPlane);
|
||||
ATTRIB_LOOP_BEGIN
|
||||
GLuint c;
|
||||
for (c = 0; c < 4; c++) {
|
||||
span.attrStart[attr][c] = solve_plane(ix + 1.5, iy + 0.5F, attrPlane[attr][c]);
|
||||
span.attrStart[attr][c] = solve_plane(ix + 1.5F, iy + 0.5F, attrPlane[attr][c]);
|
||||
}
|
||||
ATTRIB_LOOP_END
|
||||
#endif
|
||||
|
||||
@@ -86,7 +86,7 @@ apply_swizzle(GLfloat values[4], GLuint swizzle)
|
||||
q = 0.000000001F;
|
||||
values[0] = s / q;
|
||||
values[1] = t / q;
|
||||
values[2] = 1.0 / q;
|
||||
values[2] = 1.0F / q;
|
||||
break;
|
||||
}
|
||||
values[3] = 0.0;
|
||||
@@ -138,7 +138,7 @@ apply_src_mod(GLint optype, GLuint mod, GLfloat * val)
|
||||
val[i] = 1 - val[i];
|
||||
|
||||
if (mod & GL_BIAS_BIT_ATI)
|
||||
val[i] = val[i] - 0.5;
|
||||
val[i] = val[i] - 0.5F;
|
||||
|
||||
if (mod & GL_2X_BIT_ATI)
|
||||
val[i] = 2 * val[i];
|
||||
|
||||
@@ -77,7 +77,7 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
UNCLAMPED_FLOAT_TO_USHORT(clearColor[BCOMP], ctx->Color.ClearColor[2]);
|
||||
UNCLAMPED_FLOAT_TO_USHORT(clearColor[ACOMP], ctx->Color.ClearColor[3]);
|
||||
for (i = 0; i < width; i++) {
|
||||
COPY_4V(span.array->rgba[i], clearColor);
|
||||
COPY_4V_CAST(span.array->rgba[i], clearColor, GLchan);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -368,7 +368,7 @@ texture_combine( GLcontext *ctx, GLuint unit, GLuint n,
|
||||
(arg0[i][GCOMP] - 0.5F) * (arg1[i][GCOMP] - 0.5F) +
|
||||
(arg0[i][BCOMP] - 0.5F) * (arg1[i][BCOMP] - 0.5F))
|
||||
* 4.0F * scaleRGB;
|
||||
dot = CLAMP(dot, 0.0, 1.0F);
|
||||
dot = CLAMP(dot, 0.0F, 1.0F);
|
||||
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = dot;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -122,7 +122,7 @@ setup_vertex_format(GLcontext *ctx)
|
||||
swsetup->last_index_bitset)) {
|
||||
DECLARE_RENDERINPUTS(index_bitset);
|
||||
struct tnl_attr_map map[_TNL_ATTRIB_MAX];
|
||||
int i, e = 0;
|
||||
unsigned int i, e = 0;
|
||||
|
||||
swsetup->intColors = intColors;
|
||||
|
||||
|
||||
@@ -132,9 +132,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
|
||||
saved_index[1] = v[1]->attrib[FRAG_ATTRIB_CI][0];
|
||||
saved_index[2] = v[2]->attrib[FRAG_ATTRIB_CI][0];
|
||||
|
||||
SS_IND(v[0]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e0]);
|
||||
SS_IND(v[1]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e1]);
|
||||
SS_IND(v[2]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e2]);
|
||||
SS_IND(v[0]->attrib[FRAG_ATTRIB_CI][0], vbindex[e0]);
|
||||
SS_IND(v[1]->attrib[FRAG_ATTRIB_CI][0], vbindex[e1]);
|
||||
SS_IND(v[2]->attrib[FRAG_ATTRIB_CI][0], vbindex[e2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,9 +159,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
|
||||
offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
|
||||
}
|
||||
/* new Z values */
|
||||
oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
|
||||
oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
|
||||
oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
|
||||
oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
|
||||
oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
|
||||
oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ void _tnl_draw_prims( GLcontext *ctx,
|
||||
_tnl_vbo_draw_prims );
|
||||
return;
|
||||
}
|
||||
else if (max_index + max_basevertex > max) {
|
||||
else if ((GLint)max_index + max_basevertex > max) {
|
||||
/* The software TNL pipeline has a fixed amount of storage for
|
||||
* vertices and it is necessary to split incoming drawing commands
|
||||
* if they exceed that limit.
|
||||
|
||||
Reference in New Issue
Block a user