mesa: rework texture completeness testing
[mesa.git] / src / mesa / swrast / s_fragprog.c
index 9513b1c46b40536b8a1badb654ab4e91d7640ff5..8d59371c8367c718b4934a1523c8be466654aa2a 100644 (file)
 #include "s_fragprog.h"
 #include "s_span.h"
 
+/**
+ * \brief Should swrast use a fragment program?
+ *
+ * \return true if the current fragment program exists and is not the fixed
+ *         function fragment program
+ */
+GLboolean
+_swrast_use_fragment_program(struct gl_context *ctx)
+{
+   struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+   return fp && !(fp == ctx->FragmentProgram._TexEnvProgram
+                  && fp->Base.NumInstructions == 0);
+}
 
 /**
  * Apply texture object's swizzle (X/Y/Z/W/0/1) to incoming 'texel'
  * and return results in 'colorOut'.
  */
-static INLINE void
+static inline void
 swizzle_texel(const GLfloat texel[4], GLfloat colorOut[4], GLuint swizzle)
 {
    if (swizzle == SWIZZLE_NOOP) {
@@ -237,7 +250,8 @@ run_program(struct gl_context *ctx, SWspan *span, GLuint start, GLuint end)
                else if (depth >= 1.0)
                   span->array->z[i] = ctx->DrawBuffer->_DepthMax;
                else
-                  span->array->z[i] = IROUND(depth * ctx->DrawBuffer->_DepthMaxF);
+                  span->array->z[i] =
+                     (GLuint) (depth * ctx->DrawBuffer->_DepthMaxF + 0.5F);
             }
          }
          else {