SMeleeTags::SMeleeFragData CMelee::GenerateFragmentData( const SMeleeTags::TTagParamsContainer& tagContainer ) const { const size_t numTags = tagContainer.size(); if( numTags > 0 ) { const size_t tagIndex = rand()*100 % numTags; const SMeleeTags::STagParams& meleeTags = tagContainer[tagIndex]; SMeleeTags::SMeleeFragData fragData( tagIndex, meleeTags ); return fragData; } return SMeleeTags::SMeleeFragData(); }
void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) { // // Insert some special built-in variables that are not in // the built-in header files. // switch (type) { case GL_FRAGMENT_SHADER: symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); { symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); fragData.setArraySize(resources.MaxDrawBuffers); symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); if (resources.EXT_blend_func_extended) { symbolTable.insert( ESSL1_BUILTINS, "GL_EXT_blend_func_extended", new TVariable(NewPoolTString("gl_SecondaryFragColorEXT"), TType(EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4))); TType secondaryFragData(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1, true); secondaryFragData.setArraySize(resources.MaxDualSourceDrawBuffers); symbolTable.insert( ESSL1_BUILTINS, "GL_EXT_blend_func_extended", new TVariable(NewPoolTString("gl_SecondaryFragDataEXT"), secondaryFragData)); } if (resources.EXT_frag_depth) { symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_frag_depth", new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); } if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) { TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); lastFragData.setArraySize(resources.MaxDrawBuffers); if (resources.EXT_shader_framebuffer_fetch) { symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); } else if (resources.NV_shader_framebuffer_fetch) { symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragColor"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); } } else if (resources.ARM_shader_framebuffer_fetch) { symbolTable.insert(ESSL1_BUILTINS, "GL_ARM_shader_framebuffer_fetch", new TVariable(NewPoolTString("gl_LastFragColorARM"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); } } break; case GL_VERTEX_SHADER: symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1))); break; default: assert(false && "Language not supported"); } }
void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) { // // First, insert some special built-in variables that are not in // the built-in header files. // switch(type) { case SH_FRAGMENT_SHADER: symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); // // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. // Instead, css_MixColor and css_ColorMatrix are available. // if (spec != SH_CSS_SHADERS_SPEC) { symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); if (resources.EXT_frag_depth) { symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth"); } } else { symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4))); } break; case SH_VERTEX_SHADER: symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); break; default: assert(false && "Language not supported"); } // // Next, identify which built-ins from the already loaded headers have // a mapping to an operator. Those that are not identified as such are // expected to be resolved through a library of functions, versus as // operations. // symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul); symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual); symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual); symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan); symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan); symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual); symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual); symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians); symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees); symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin); symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos); symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan); symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin); symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos); symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan); symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow); symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2); symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog); symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp); symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2); symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt); symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt); symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs); symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign); symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor); symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil); symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract); symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod); symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin); symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax); symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp); symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix); symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep); symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep); symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength); symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance); symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot); symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross); symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize); symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward); symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect); symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract); symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny); symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll); symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot); // Map language-specific operators. switch(type) { case SH_VERTEX_SHADER: break; case SH_FRAGMENT_SHADER: if (resources.OES_standard_derivatives) { symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx); symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy); symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth); symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives"); symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives"); symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives"); } if (resources.EXT_shader_texture_lod) { symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DLodEXT", "GL_EXT_shader_texture_lod"); symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjLodEXT", "GL_EXT_shader_texture_lod"); symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeLodEXT", "GL_EXT_shader_texture_lod"); } break; default: break; } symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx); symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy); symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth); if (resources.EXT_shader_texture_lod) { symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DGradEXT", "GL_EXT_shader_texture_lod"); symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjGradEXT", "GL_EXT_shader_texture_lod"); symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeGradEXT", "GL_EXT_shader_texture_lod"); } // Finally add resource-specific variables. switch(type) { case SH_FRAGMENT_SHADER: if (spec != SH_CSS_SHADERS_SPEC) { // Set up gl_FragData. The array size. TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); fragData.setArraySize(resources.MaxDrawBuffers); symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData)); } break; default: break; } }