void GLAPIENTRY _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { struct gl_texture_unit *texUnit; struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGenfv(current unit)"); return; } texUnit = _mesa_get_current_tex_unit(ctx); texgen = get_texgen(texUnit, coord); if (!texgen) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)"); return; } switch (pname) { case GL_TEXTURE_GEN_MODE: params[0] = ENUM_TO_FLOAT(texgen->Mode); break; case GL_OBJECT_PLANE: COPY_4V(params, texgen->ObjectPlane); break; case GL_EYE_PLANE: COPY_4V(params, texgen->EyePlane); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); } }
static void handle_pass_op(struct atifs_machine *machine, struct atifs_instruction *inst, const struct sw_span *span, GLuint column) { GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI; GLuint swizzle = inst->DstReg[0].Swizzle; GLuint pass_tex = inst->SrcReg[0][0].Index; /* if we get here after passing pass one then we are starting pass two - backup the registers */ if (machine->pass == 1) { finish_pass(machine); machine->pass = 2; } if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) { pass_tex -= GL_TEXTURE0_ARB; COPY_4V(machine->Registers[idx], span->array->texcoords[pass_tex][column]); } else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI && machine->pass == 2) { pass_tex -= GL_REG_0_ATI; COPY_4V(machine->Registers[idx], machine->PrevPassRegisters[pass_tex]); } apply_swizzle(machine, idx, swizzle); }
void GLAPIENTRY _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat *params) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target == GL_FRAGMENT_PROGRAM_ARB && ctx->Extensions.ARB_fragment_program) { if (index >= ctx->Const.FragmentProgram.MaxEnvParams) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)"); return; } COPY_4V(params, ctx->FragmentProgram.Parameters[index]); } else if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) { if (index >= ctx->Const.VertexProgram.MaxEnvParams) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)"); return; } COPY_4V(params, ctx->VertexProgram.Parameters[index]); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramEnvParameter(target)"); return; } }
void _mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) { GET_CURRENT_CONTEXT(ctx); const struct gl_convolution_attrib *conv; GLuint c; ASSERT_OUTSIDE_BEGIN_END(ctx); switch (target) { case GL_CONVOLUTION_1D: c = 0; conv = &ctx->Convolution1D; break; case GL_CONVOLUTION_2D: c = 1; conv = &ctx->Convolution2D; break; case GL_SEPARABLE_2D: c = 2; conv = &ctx->Separable2D; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(target)"); return; } switch (pname) { case GL_CONVOLUTION_BORDER_COLOR: COPY_4V(params, ctx->Pixel.ConvolutionBorderColor[c]); break; case GL_CONVOLUTION_BORDER_MODE: *params = (GLfloat) ctx->Pixel.ConvolutionBorderMode[c]; break; case GL_CONVOLUTION_FILTER_SCALE: COPY_4V(params, ctx->Pixel.ConvolutionFilterScale[c]); break; case GL_CONVOLUTION_FILTER_BIAS: COPY_4V(params, ctx->Pixel.ConvolutionFilterBias[c]); break; case GL_CONVOLUTION_FORMAT: *params = (GLfloat) conv->Format; break; case GL_CONVOLUTION_WIDTH: *params = (GLfloat) conv->Width; break; case GL_CONVOLUTION_HEIGHT: *params = (GLfloat) conv->Height; break; case GL_MAX_CONVOLUTION_WIDTH: *params = (GLfloat) ctx->Const.MaxConvolutionWidth; break; case GL_MAX_CONVOLUTION_HEIGHT: *params = (GLfloat) ctx->Const.MaxConvolutionHeight; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(pname)"); return; } }
/** * Run fragment program on the pixels in span from 'start' to 'end' - 1. */ static void run_program(struct gl_context *ctx, SWspan *span, GLuint start, GLuint end) { SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_fragment_program *program = ctx->FragmentProgram._Current; const GLbitfield64 outputsWritten = program->Base.OutputsWritten; struct gl_program_machine *machine = &swrast->FragProgMachine; GLuint i; for (i = start; i < end; i++) { if (span->array->mask[i]) { init_machine(ctx, machine, program, span, i); if (_mesa_execute_program(ctx, &program->Base, machine)) { /* Store result color */ if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) { COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], machine->Outputs[FRAG_RESULT_COLOR]); } else { /* Multiple drawbuffers / render targets * Note that colors beyond 0 and 1 will overwrite other * attributes, such as FOGC, TEX0, TEX1, etc. That's OK. */ GLuint buf; for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) { if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0 + buf)) { COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0 + buf][i], machine->Outputs[FRAG_RESULT_DATA0 + buf]); } } } /* Store result depth/z */ if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { const GLfloat depth = machine->Outputs[FRAG_RESULT_DEPTH][2]; if (depth <= 0.0) span->array->z[i] = 0; else if (depth >= 1.0) span->array->z[i] = ctx->DrawBuffer->_DepthMax; else span->array->z[i] = (GLuint) (depth * ctx->DrawBuffer->_DepthMaxF + 0.5F); } } else { /* killed fragment */ span->array->mask[i] = GL_FALSE; span->writeAll = GL_FALSE; } } } }
void _mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); struct gl_convolution_attrib *conv; GLuint c; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { case GL_CONVOLUTION_1D: c = 0; conv = &ctx->Convolution1D; break; case GL_CONVOLUTION_2D: c = 1; conv = &ctx->Convolution2D; break; case GL_SEPARABLE_2D: c = 2; conv = &ctx->Separable2D; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(target)"); return; } switch (pname) { case GL_CONVOLUTION_BORDER_COLOR: COPY_4V(ctx->Pixel.ConvolutionBorderColor[c], params); break; case GL_CONVOLUTION_BORDER_MODE: if (params[0] == (GLfloat) GL_REDUCE || params[0] == (GLfloat) GL_CONSTANT_BORDER || params[0] == (GLfloat) GL_REPLICATE_BORDER) { ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(params)"); return; } break; case GL_CONVOLUTION_FILTER_SCALE: COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); break; case GL_CONVOLUTION_FILTER_BIAS: COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(pname)"); return; } ctx->NewState |= _NEW_PIXEL; }
/** * Used by glXCopyContext to copy texture state from one context to another. */ void _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) { GLuint u, tex; ASSERT(src); ASSERT(dst); dst->Texture.CurrentUnit = src->Texture.CurrentUnit; dst->Texture._GenFlags = src->Texture._GenFlags; dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; dst->Texture.SharedPalette = src->Texture.SharedPalette; /* per-unit state */ for (u = 0; u < src->Const.MaxTextureImageUnits; u++) { dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; /* GL_EXT_texture_env_combine */ dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; /* GL_ATI_envmap_bumpmap - need this? */ dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); /* * XXX strictly speaking, we should compare texture names/ids and * bind textures in the dest context according to id. For now, only * copy bindings if the contexts share the same pool of textures to * avoid refcounting bugs. */ if (dst->Shared == src->Shared) { /* copy texture object bindings, not contents of texture objects */ _mesa_lock_context_textures(dst); for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], src->Texture.Unit[u].CurrentTex[tex]); } _mesa_unlock_context_textures(dst); } } }
void _mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); GLint l = (GLint) (light - GL_LIGHT0); ASSERT_OUTSIDE_BEGIN_END(ctx); if (l < 0 || l >= (GLint) ctx->Const.MaxLights) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); return; } switch (pname) { case GL_AMBIENT: COPY_4V( params, ctx->Light.Light[l].Ambient ); break; case GL_DIFFUSE: COPY_4V( params, ctx->Light.Light[l].Diffuse ); break; case GL_SPECULAR: COPY_4V( params, ctx->Light.Light[l].Specular ); break; case GL_POSITION: COPY_4V( params, ctx->Light.Light[l].EyePosition ); break; case GL_SPOT_DIRECTION: COPY_3V( params, ctx->Light.Light[l].EyeDirection ); break; case GL_SPOT_EXPONENT: params[0] = ctx->Light.Light[l].SpotExponent; break; case GL_SPOT_CUTOFF: params[0] = ctx->Light.Light[l].SpotCutoff; break; case GL_CONSTANT_ATTENUATION: params[0] = ctx->Light.Light[l].ConstantAttenuation; break; case GL_LINEAR_ATTENUATION: params[0] = ctx->Light.Light[l].LinearAttenuation; break; case GL_QUADRATIC_ATTENUATION: params[0] = ctx->Light.Light[l].QuadraticAttenuation; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" ); break; } }
/** * Execute a vertex state program. * \note Called from the GL API dispatcher. */ void GLAPIENTRY _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) { struct vertex_program *vprog; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target != GL_VERTEX_STATE_PROGRAM_NV) { _mesa_error(ctx, GL_INVALID_ENUM, "glExecuteProgramNV"); return; } FLUSH_VERTICES(ctx, _NEW_PROGRAM); vprog = (struct vertex_program *) _mesa_HashLookup(ctx->Shared->Programs, id); if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) { _mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV"); return; } _mesa_init_vp_per_vertex_registers(ctx); _mesa_init_vp_per_primitive_registers(ctx); COPY_4V(ctx->VertexProgram.Inputs[VERT_ATTRIB_POS], params); _mesa_exec_vertex_program(ctx, vprog); }
static void feedback_vertex( GLcontext *ctx, const SWvertex *v, const SWvertex *pv ) { const GLuint texUnit = 0; /* See section 5.3 of 1.2.1 spec */ GLfloat win[4]; GLfloat color[4]; GLfloat tc[4]; win[0] = v->win[0]; win[1] = v->win[1]; win[2] = v->win[2] / ctx->DepthMaxF; win[3] = 1.0F / v->win[3]; color[0] = CHAN_TO_FLOAT(pv->color[0]); color[1] = CHAN_TO_FLOAT(pv->color[1]); color[2] = CHAN_TO_FLOAT(pv->color[2]); color[3] = CHAN_TO_FLOAT(pv->color[3]); if (v->texcoord[texUnit][3] != 1.0 && v->texcoord[texUnit][3] != 0.0) { GLfloat invq = 1.0F / v->texcoord[texUnit][3]; tc[0] = v->texcoord[texUnit][0] * invq; tc[1] = v->texcoord[texUnit][1] * invq; tc[2] = v->texcoord[texUnit][2] * invq; tc[3] = v->texcoord[texUnit][3]; } else { COPY_4V(tc, v->texcoord[texUnit]); } _mesa_feedback_vertex( ctx, win, color, (GLfloat) v->index, tc ); }
enum pipe_error SVGA3D_vgpu10_ClearRenderTargetView(struct svga_winsys_context *swc, struct pipe_surface *color_surf, const float *rgba) { SVGA3dCmdDXClearRenderTargetView *cmd; struct svga_surface *ss = svga_surface(color_surf); cmd = SVGA3D_FIFOReserve(swc, SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW, sizeof(SVGA3dCmdDXClearRenderTargetView), 1); /* one relocation */ if (!cmd) return PIPE_ERROR_OUT_OF_MEMORY; /* NOTE: The following is pretty tricky. We need to emit a view/surface * relocation and we have to provide a pointer to an ID which lies in * the bounds of the command space which we just allocated. However, * we then need to overwrite it with the original RenderTargetViewId. */ view_relocation(swc, color_surf, &cmd->renderTargetViewId, SVGA_RELOC_WRITE); cmd->renderTargetViewId = ss->view_id; COPY_4V(cmd->rgba.value, rgba); swc->commit(swc); return PIPE_OK; }
/** * Get a vertex (or vertex array) attribute. * \note Not compiled into display lists. * \note Called from the GL API dispatcher. */ void _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (index == 0 || index >= VP_NUM_INPUT_REGS) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); return; } switch (pname) { case GL_ATTRIB_ARRAY_SIZE_NV: params[0] = ctx->Array.VertexAttrib[index].Size; break; case GL_ATTRIB_ARRAY_STRIDE_NV: params[0] = ctx->Array.VertexAttrib[index].Stride; break; case GL_ATTRIB_ARRAY_TYPE_NV: params[0] = ctx->Array.VertexAttrib[index].Type; break; case GL_CURRENT_ATTRIB_NV: FLUSH_CURRENT(ctx, 0); COPY_4V(params, ctx->Current.Attrib[index]); break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); return; } }
/** * Helper function used by the functions below. */ static GLint add_parameter(struct program_parameter_list *paramList, const char *name, const GLfloat values[4], enum parameter_type type) { const GLuint n = paramList->NumParameters; paramList->Parameters = (struct program_parameter *) _mesa_realloc(paramList->Parameters, n * sizeof(struct program_parameter), (n + 1) * sizeof(struct program_parameter)); if (!paramList->Parameters) { /* out of memory */ paramList->NumParameters = 0; return -1; } else { paramList->NumParameters = n + 1; paramList->Parameters[n].Name = _mesa_strdup(name); paramList->Parameters[n].Type = type; if (values) COPY_4V(paramList->Parameters[n].Values, values); return (GLint) n; } }
/** * Parse a floating point constant, or a defined symbol name. * [+/-]N[.N[eN]] * Output: number[0 .. 3] will get the value. */ static GLboolean Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number) { char *end = NULL; *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end); if (end && end > (char *) parseState->pos) { /* got a number */ parseState->pos = (GLubyte *) end; number[1] = *number; number[2] = *number; number[3] = *number; return GL_TRUE; } else { /* should be an identifier */ GLubyte ident[100]; const GLfloat *constant; if (!Parse_Identifier(parseState, ident)) RETURN_ERROR1("Expected an identifier"); constant = _mesa_lookup_parameter_value(parseState->parameters, -1, (const char *) ident); /* XXX Check that it's a constant and not a parameter */ if (!constant) { RETURN_ERROR1("Undefined symbol"); } else { COPY_4V(number, constant); return GL_TRUE; } } }
/** New in GL 3.0 */ void GLAPIENTRY _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) { struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); texObj = get_texobj(ctx, target, GL_TRUE); if (!texObj) return; switch (pname) { case GL_TEXTURE_BORDER_COLOR: COPY_4V(params, texObj->Sampler.BorderColor.i); break; default: { GLint ip[4]; _mesa_GetTexParameteriv(target, pname, ip); params[0] = ip[0]; if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || pname == GL_TEXTURE_CROP_RECT_OES) { params[1] = ip[1]; params[2] = ip[2]; params[3] = ip[3]; } } } }
/** * Get a vertex (or vertex array) attribute. * \note Not compiled into display lists. * \note Called from the GL API dispatcher. */ void GLAPIENTRY _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); return; } switch (pname) { case GL_ATTRIB_ARRAY_SIZE_NV: params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Size; break; case GL_ATTRIB_ARRAY_STRIDE_NV: params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Stride; break; case GL_ATTRIB_ARRAY_TYPE_NV: params[0] = (GLfloat) ctx->Array.ArrayObj->VertexAttrib[index].Type; break; case GL_CURRENT_ATTRIB_NV: if (index == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetVertexAttribfvNV(index == 0)"); return; } FLUSH_CURRENT(ctx, 0); COPY_4V(params, ctx->Current.Attrib[index]); break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); return; } }
/** * Init fragment shader virtual machine state. */ static void init_machine(struct gl_context * ctx, struct atifs_machine *machine, const struct ati_fragment_shader *shader, const SWspan *span, GLuint col) { GLfloat (*inputs)[4] = machine->Inputs; GLint i, j; for (i = 0; i < 6; i++) { for (j = 0; j < 4; j++) machine->Registers[i][j] = 0.0; } COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], span->array->attribs[FRAG_ATTRIB_COL0][col]); COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], span->array->attribs[FRAG_ATTRIB_COL1][col]); }
/** * Get a program parameter register. * \note Not compiled into display lists. * \note Called from the GL API dispatcher. */ void GLAPIENTRY _mesa_GetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble *params) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (target == GL_VERTEX_PROGRAM_NV) { if (pname == GL_PROGRAM_PARAMETER_NV) { if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { COPY_4V(params, ctx->VertexProgram.Parameters[index]); } else { _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramParameterdvNV(index)"); return; } } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(pname)"); return; } } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(target)"); return; } }
/** * Execute the current ATI shader program, operating on the given span. */ void _swrast_exec_fragment_shader(struct gl_context * ctx, SWspan *span) { const struct ati_fragment_shader *shader = ctx->ATIFragmentShader.Current; struct atifs_machine machine; GLuint i; /* incoming colors should be floats */ ASSERT(span->array->ChanType == GL_FLOAT); for (i = 0; i < span->end; i++) { if (span->array->mask[i]) { init_machine(ctx, &machine, shader, span, i); execute_shader(ctx, shader, &machine, span, i); /* store result color */ { const GLfloat *colOut = machine.Registers[0]; /*fprintf(stderr,"outputs %f %f %f %f\n", colOut[0], colOut[1], colOut[2], colOut[3]); */ COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], colOut); } } } }
static void xlate_border_color(const GLfloat *colorIn, GLenum baseFormat, GLfloat *colorOut) { switch (baseFormat) { case GL_RGB: colorOut[0] = colorIn[0]; colorOut[1] = colorIn[1]; colorOut[2] = colorIn[2]; colorOut[3] = 1.0F; break; case GL_ALPHA: colorOut[0] = colorOut[1] = colorOut[2] = 0.0; colorOut[3] = colorIn[3]; break; case GL_LUMINANCE: colorOut[0] = colorOut[1] = colorOut[2] = colorIn[0]; colorOut[3] = 1.0; break; case GL_LUMINANCE_ALPHA: colorOut[0] = colorOut[1] = colorOut[2] = colorIn[0]; colorOut[3] = colorIn[3]; break; case GL_INTENSITY: colorOut[0] = colorOut[1] = colorOut[2] = colorOut[3] = colorIn[0]; break; default: COPY_4V(colorOut, colorIn); } }
/** * Called during state validation when LP_NEW_SAMPLER is set. */ void lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup, unsigned num, struct pipe_sampler_state **samplers) { unsigned i; LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__); assert(num <= PIPE_MAX_SAMPLERS); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { const struct pipe_sampler_state *sampler = i < num ? samplers[i] : NULL; if (sampler) { struct lp_jit_sampler *jit_sam; jit_sam = &setup->fs.current.jit_context.samplers[i]; jit_sam->min_lod = sampler->min_lod; jit_sam->max_lod = sampler->max_lod; jit_sam->lod_bias = sampler->lod_bias; COPY_4V(jit_sam->border_color, sampler->border_color.f); } } setup->dirty |= LP_SETUP_NEW_FS; }
/** * Clear the color buffer when glColorMask is in effect. */ static void clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) { const GLint x = ctx->DrawBuffer->_Xmin; const GLint y = ctx->DrawBuffer->_Ymin; const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; SWspan span; GLint i; ASSERT(ctx->Visual.rgbMode); ASSERT(rb->PutRow); /* Initialize color span with clear color */ /* XXX optimize for clearcolor == black/zero (bzero) */ INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); span.array->ChanType = rb->DataType; if (span.array->ChanType == GL_UNSIGNED_BYTE) { GLubyte clearColor[4]; UNCLAMPED_FLOAT_TO_UBYTE(clearColor[RCOMP], ctx->Color.ClearColor[0]); UNCLAMPED_FLOAT_TO_UBYTE(clearColor[GCOMP], ctx->Color.ClearColor[1]); UNCLAMPED_FLOAT_TO_UBYTE(clearColor[BCOMP], ctx->Color.ClearColor[2]); UNCLAMPED_FLOAT_TO_UBYTE(clearColor[ACOMP], ctx->Color.ClearColor[3]); for (i = 0; i < width; i++) { COPY_4UBV(span.array->rgba[i], clearColor); } } else if (span.array->ChanType == GL_UNSIGNED_SHORT) { GLushort clearColor[4]; UNCLAMPED_FLOAT_TO_USHORT(clearColor[RCOMP], ctx->Color.ClearColor[0]); UNCLAMPED_FLOAT_TO_USHORT(clearColor[GCOMP], ctx->Color.ClearColor[1]); 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); } } else { ASSERT(span.array->ChanType == GL_FLOAT); for (i = 0; i < width; i++) { CLAMPED_FLOAT_TO_CHAN(span.array->rgba[i][0], ctx->Color.ClearColor[0]); CLAMPED_FLOAT_TO_CHAN(span.array->rgba[i][1], ctx->Color.ClearColor[1]); CLAMPED_FLOAT_TO_CHAN(span.array->rgba[i][2], ctx->Color.ClearColor[2]); CLAMPED_FLOAT_TO_CHAN(span.array->rgba[i][3], ctx->Color.ClearColor[3]); } } /* Note that masking will change the color values, but only the * channels for which the write mask is GL_FALSE. The channels * which which are write-enabled won't get modified. */ for (i = 0; i < height; i++) { span.x = x; span.y = y + i; _swrast_mask_rgba_span(ctx, rb, &span); /* write masked row */ rb->PutRow(ctx, rb, width, x, y + i, span.array->rgba, NULL); } }
void GLAPIENTRY _mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble *params) { GLfloat floatParams[4]; _mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams); COPY_4V(params, floatParams); }
/** * Draw size=1, single-pixel point */ static void pixel_point(struct gl_context *ctx, const SWvertex *vert) { SWcontext *swrast = SWRAST_CONTEXT(ctx); /* * Note that unlike the other functions, we put single-pixel points * into a special span array in order to render as many points as * possible with a single _swrast_write_rgba_span() call. */ SWspan *span = &(swrast->PointSpan); GLuint count; CULL_INVALID(vert); /* Span init */ span->interpMask = 0; span->arrayMask = SPAN_XY | SPAN_Z; span->arrayMask |= SPAN_RGBA; /*span->arrayMask |= SPAN_LAMBDA;*/ span->arrayAttribs = swrast->_ActiveAttribMask; /* we'll produce these vals */ /* need these for fragment programs */ span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; /* check if we need to flush */ if (span->end >= MAX_WIDTH || (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT)) || span->facing != swrast->PointLineFacing) { if (span->end > 0) { _swrast_write_rgba_span(ctx, span); span->end = 0; } } count = span->end; span->facing = swrast->PointLineFacing; /* fragment attributes */ span->array->rgba[count][RCOMP] = vert->color[0]; span->array->rgba[count][GCOMP] = vert->color[1]; span->array->rgba[count][BCOMP] = vert->color[2]; span->array->rgba[count][ACOMP] = vert->color[3]; ATTRIB_LOOP_BEGIN COPY_4V(span->array->attribs[attr][count], vert->attrib[attr]); ATTRIB_LOOP_END /* fragment position */ span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0]; span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1]; span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); span->end = count + 1; ASSERT(span->end <= MAX_WIDTH); }
/** * Used by glXCopyContext to copy texture state from one context to another. */ void _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) { GLuint u, tex; ASSERT(src); ASSERT(dst); dst->Texture.CurrentUnit = src->Texture.CurrentUnit; dst->Texture._GenFlags = src->Texture._GenFlags; dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; dst->Texture.SharedPalette = src->Texture.SharedPalette; /* per-unit state */ for (u = 0; u < src->Const.MaxTextureImageUnits; u++) { dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; /* GL_EXT_texture_env_combine */ dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; /* GL_ATI_envmap_bumpmap - need this? */ dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); /* copy texture object bindings, not contents of texture objects */ _mesa_lock_context_textures(dst); for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], src->Texture.Unit[u].CurrentTex[tex]); } _mesa_unlock_context_textures(dst); } }
static unsigned upload_default_color( struct brw_context *brw, const float *color ) { struct brw_sampler_default_color sdc; COPY_4V(sdc.color, color); return brw_cache_data( &brw->cache[BRW_SAMPLER_DEFAULT_COLOR], &sdc ); }
static void finish_pass(struct atifs_machine *machine) { GLint i; for (i = 0; i < 6; i++) { COPY_4V(machine->PrevPassRegisters[i], machine->Registers[i]); } }
static dri_bo *upload_default_color( struct brw_context *brw, const GLfloat *color ) { struct brw_sampler_default_color sdc; COPY_4V(sdc.color, color); return brw_cache_data( &brw->cache, BRW_SAMPLER_DEFAULT_COLOR, &sdc, NULL, 0 ); }
static void handle_pass_op(struct atifs_machine *machine, struct atifs_setupinst *texinst, const SWspan *span, GLuint column, GLuint idx) { GLuint swizzle = texinst->swizzle; GLuint pass_tex = texinst->src; if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) { pass_tex -= GL_TEXTURE0_ARB; COPY_4V(machine->Registers[idx], span->array->attribs[FRAG_ATTRIB_TEX0 + pass_tex][column]); } else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI) { pass_tex -= GL_REG_0_ATI; COPY_4V(machine->Registers[idx], machine->PrevPassRegisters[pass_tex]); } apply_swizzle(machine->Registers[idx], swizzle); }
static void GLAPIENTRY _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) { GLfloat *scale, *bias; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { case GL_COLOR_TABLE_SGI: scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; break; case GL_TEXTURE_COLOR_TABLE_SGI: scale = ctx->Pixel.TextureColorTableScale; bias = ctx->Pixel.TextureColorTableBias; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); return; } if (pname == GL_COLOR_TABLE_SCALE_SGI) { COPY_4V(scale, params); } else if (pname == GL_COLOR_TABLE_BIAS_SGI) { COPY_4V(bias, params); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); return; } ctx->NewState |= _NEW_PIXEL; }