static int emit_const( struct svga_context *svga, int unit, int i, const float *value ) { int ret = PIPE_OK; if (memcmp(svga->state.hw_draw.cb[unit][i], value, 4 * sizeof(float)) != 0) { if (SVGA_DEBUG & DEBUG_CONSTS) debug_printf("%s %s %d: %f %f %f %f\n", __FUNCTION__, unit == PIPE_SHADER_VERTEX ? "VERT" : "FRAG", i, value[0], value[1], value[2], value[3]); ret = SVGA3D_SetShaderConst( svga->swc, i, svga_shader_type(unit), SVGA3D_CONST_TYPE_FLOAT, value ); if (ret) return ret; memcpy(svga->state.hw_draw.cb[unit][i], value, 4 * sizeof(float)); } return ret; }
/** * Check and emit one shader constant register. * \param shader PIPE_SHADER_FRAGMENT or PIPE_SHADER_VERTEX * \param i which float[4] constant to change * \param value the new float[4] value */ static enum pipe_error emit_const(struct svga_context *svga, unsigned shader, unsigned i, const float *value) { enum pipe_error ret = PIPE_OK; assert(shader < PIPE_SHADER_TYPES); assert(i < SVGA3D_CONSTREG_MAX); if (memcmp(svga->state.hw_draw.cb[shader][i], value, 4 * sizeof(float)) != 0) { if (SVGA_DEBUG & DEBUG_CONSTS) debug_printf("%s %s %u: %f %f %f %f\n", __FUNCTION__, shader == PIPE_SHADER_VERTEX ? "VERT" : "FRAG", i, value[0], value[1], value[2], value[3]); ret = SVGA3D_SetShaderConst( svga->swc, i, svga_shader_type(shader), SVGA3D_CONST_TYPE_FLOAT, value ); if (ret != PIPE_OK) return ret; memcpy(svga->state.hw_draw.cb[shader][i], value, 4 * sizeof(float)); } return ret; }
void SVGA3DUtil_SetShaderConstMatrix(uint32 cid, // IN uint32 reg, // IN SVGA3dShaderType type, // IN const float *matrix) // IN { int col; for (col = 0; col < 4; col++) { float vector[4]; vector[0] = matrix[col + 0]; vector[1] = matrix[col + 4]; vector[2] = matrix[col + 8]; vector[3] = matrix[col + 12]; SVGA3D_SetShaderConst(cid, reg + col, type, SVGA3D_CONST_TYPE_FLOAT, vector); } }