void ProgramSeparateDsa::setUniform4fv(handle uniformHandle, const float *value) { if (static_cast<OpenGLRenderer&>(getRenderer()).getExtensions().isGL_ARB_direct_state_access()) { glProgramUniform4fv(mVertexShaderSeparate->getOpenGLShaderProgram(), static_cast<GLint>(uniformHandle), 1, value); } else { glProgramUniform4fvEXT(mVertexShaderSeparate->getOpenGLShaderProgram(), static_cast<GLint>(uniformHandle), 1, value); } }
void ProgramMonolithicDsa::setUniform4fv(handle uniformHandle, const float *value) { if (static_cast<OpenGLRenderer&>(getRenderer()).getExtensions().isGL_ARB_direct_state_access()) { glProgramUniform4fv(mOpenGLProgram, static_cast<GLint>(uniformHandle), 1, value); } else { glProgramUniform4fvEXT(mOpenGLProgram, static_cast<GLint>(uniformHandle), 1, value); } }
//----------------------------------------------------------------------- void GLSLESProgramPipeline::updateUniforms(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) { // Iterate through uniform reference list and update uniform values GLUniformReferenceIterator currentUniform = mGLUniformReferences.begin(); GLUniformReferenceIterator endUniform = mGLUniformReferences.end(); #if OGRE_PLATFORM != OGRE_PLATFORM_NACL GLuint progID = 0; GLUniformCache* uniformCache=0; if(fromProgType == GPT_VERTEX_PROGRAM) { progID = getVertexProgram()->getGLProgramHandle(); uniformCache = getVertexProgram()->getUniformCache(); } else if(fromProgType == GPT_FRAGMENT_PROGRAM) { progID = mFragmentProgram->getGLProgramHandle(); uniformCache = mFragmentProgram->getUniformCache(); } for (;currentUniform != endUniform; ++currentUniform) { // Only pull values from buffer it's supposed to be in (vertex or fragment) // This method will be called twice, once for vertex program params, // and once for fragment program params. if (fromProgType == currentUniform->mSourceProgType) { const GpuConstantDefinition* def = currentUniform->mConstantDef; if (def->variability & mask) { GLsizei glArraySize = (GLsizei)def->arraySize; bool shouldUpdate = true; switch (def->constType) { case GCT_INT1: case GCT_INT2: case GCT_INT3: case GCT_INT4: case GCT_SAMPLER1D: case GCT_SAMPLER1DSHADOW: case GCT_SAMPLER2D: case GCT_SAMPLER2DSHADOW: case GCT_SAMPLER3D: case GCT_SAMPLERCUBE: #if OGRE_NO_GLES3_SUPPORT == 0 case GCT_SAMPLER2DARRAY: #endif shouldUpdate = uniformCache->updateUniform(currentUniform->mLocation, params->getIntPointer(def->physicalIndex), static_cast<GLsizei>(def->elementSize * def->arraySize * sizeof(int))); break; default: shouldUpdate = uniformCache->updateUniform(currentUniform->mLocation, params->getFloatPointer(def->physicalIndex), static_cast<GLsizei>(def->elementSize * def->arraySize * sizeof(float))); break; } if(!shouldUpdate) continue; // Get the index in the parameter real list switch (def->constType) { case GCT_FLOAT1: OGRE_CHECK_GL_ERROR(glProgramUniform1fvEXT(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_FLOAT2: OGRE_CHECK_GL_ERROR(glProgramUniform2fvEXT(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_FLOAT3: OGRE_CHECK_GL_ERROR(glProgramUniform3fvEXT(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_FLOAT4: OGRE_CHECK_GL_ERROR(glProgramUniform4fvEXT(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_2X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_3X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_4X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_INT1: OGRE_CHECK_GL_ERROR(glProgramUniform1ivEXT(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_INT2: OGRE_CHECK_GL_ERROR(glProgramUniform2ivEXT(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_INT3: OGRE_CHECK_GL_ERROR(glProgramUniform3ivEXT(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_INT4: OGRE_CHECK_GL_ERROR(glProgramUniform4ivEXT(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_SAMPLER1D: case GCT_SAMPLER1DSHADOW: case GCT_SAMPLER2D: case GCT_SAMPLER2DSHADOW: case GCT_SAMPLER3D: case GCT_SAMPLERCUBE: #if OGRE_NO_GLES3_SUPPORT == 0 case GCT_SAMPLER2DARRAY: #endif // Samplers handled like 1-element ints OGRE_CHECK_GL_ERROR(glProgramUniform1ivEXT(progID, currentUniform->mLocation, 1, params->getIntPointer(def->physicalIndex))); break; #if OGRE_NO_GLES3_SUPPORT == 0 case GCT_MATRIX_2X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2x3fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_2X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2x4fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_3X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3x2fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_3X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3x4fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_4X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4x2fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_4X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4x3fvEXT(progID, currentUniform->mLocation, glArraySize, GL_FALSE, params->getFloatPointer(def->physicalIndex))); break; #else case GCT_MATRIX_2X3: case GCT_MATRIX_2X4: case GCT_MATRIX_3X2: case GCT_MATRIX_3X4: case GCT_MATRIX_4X2: case GCT_MATRIX_4X3: case GCT_SAMPLER2DARRAY: #endif case GCT_UNKNOWN: case GCT_SUBROUTINE: case GCT_DOUBLE1: case GCT_DOUBLE2: case GCT_DOUBLE3: case GCT_DOUBLE4: case GCT_SAMPLERRECT: case GCT_MATRIX_DOUBLE_2X2: case GCT_MATRIX_DOUBLE_2X3: case GCT_MATRIX_DOUBLE_2X4: case GCT_MATRIX_DOUBLE_3X2: case GCT_MATRIX_DOUBLE_3X3: case GCT_MATRIX_DOUBLE_3X4: case GCT_MATRIX_DOUBLE_4X2: case GCT_MATRIX_DOUBLE_4X3: case GCT_MATRIX_DOUBLE_4X4: default: break; } // End switch } // Variability & mask } // fromProgType == currentUniform->mSourceProgType } // End for #endif }
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_EXTSeparateShaderObjects_nglProgramUniform4fvEXT__IIIJ(JNIEnv *__env, jclass clazz, jint program, jint location, jint count, jlong valueAddress) { glProgramUniform4fvEXTPROC glProgramUniform4fvEXT = (glProgramUniform4fvEXTPROC)tlsGetFunction(506); intptr_t value = (intptr_t)valueAddress; UNUSED_PARAM(clazz) glProgramUniform4fvEXT(program, location, count, value); }