<commit_before>/*-------------------------------------------------------------------------
 * drawElements Quality Program OpenGL ES Utilities
 * ------------------------------------------------
 *
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief Shader utilities.
 *//*--------------------------------------------------------------------*/

#include "gluShaderUtil.hpp"
#include "glwEnums.hpp"
#include "deArrayUtil.hpp"

namespace glu
{

// ShadingLanguageVersion

const char* getGLSLVersionName (GLSLVersion version)
{
	static const char* s_names[] =
	{
		"GLSL ES 1.0",
		"GLSL ES 3.0",
		"GLSL ES 3.1",
		"GLSL ES 3.2",
		"GLSL 1.3",
		"GLSL 1.4",
		"GLSL 1.5",
		"GLSL 3.3",
		"GLSL 4.0",
		"GLSL 4.1",
		"GLSL 4.2",
		"GLSL 4.3",
		"GLSL 4.4",
		"GLSL 4.5",
		"GLSL 4.6",
	};

	return de::getSizedArrayElement<GLSL_VERSION_LAST>(s_names, version);
}

const char* getGLSLVersionDeclaration (GLSLVersion version)
{
	static const char* s_decl[] =
	{
		"#version 100",
		"#version 300 es",
		"#version 310 es",
		"#version 320 es",
		"#version 130",
		"#version 140",
		"#version 150",
		"#version 330",
		"#version 400",
		"#version 410",
		"#version 420",
		"#version 430",
		"#version 440",
		"#version 450",
		"#version 460",
	};

	return de::getSizedArrayElement<GLSL_VERSION_LAST>(s_decl, version);
}

bool glslVersionUsesInOutQualifiers (GLSLVersion version)
{
	return de::inRange<int>(version, GLSL_VERSION_300_ES, GLSL_VERSION_320_ES) || de::inRange<int>(version, GLSL_VERSION_330, GLSL_VERSION_460);
}

bool glslVersionIsES (GLSLVersion version)
{
	DE_STATIC_ASSERT(GLSL_VERSION_LAST == 15);
	DE_ASSERT(version != GLSL_VERSION_LAST);

	if (version == GLSL_VERSION_100_ES	||
		version == GLSL_VERSION_300_ES	||
		version == GLSL_VERSION_310_ES	||
		version == GLSL_VERSION_320_ES)
		return true;
	else
		return false;
}

// \todo [2014-10-06 pyry] Export this.
static ApiType getMinAPIForGLSLVersion (GLSLVersion version)
{
	static const ApiType s_minApi[] =
	{
		ApiType::es(2,0),
		ApiType::es(3,0),
		ApiType::es(3,1),
		ApiType::es(3,2),
		ApiType::core(3,0),
		ApiType::core(3,1),
		ApiType::core(3,2),
		ApiType::core(3,3),
		ApiType::core(4,0),
		ApiType::core(4,1),
		ApiType::core(4,2),
		ApiType::core(4,3),
		ApiType::core(4,4),
		ApiType::core(4,5),
		ApiType::core(4,6),
	};

	return de::getSizedArrayElement<GLSL_VERSION_LAST>(s_minApi, version);
}

bool isGLSLVersionSupported (ContextType type, GLSLVersion version)
{
	return contextSupports(type, getMinAPIForGLSLVersion(version));
}

GLSLVersion getContextTypeGLSLVersion (ContextType type)
{
	// \note From newer to older
	for (int version = GLSL_VERSION_LAST-1; version >= 0; version--)
	{
		if (isGLSLVersionSupported(type, GLSLVersion(version)))
			return GLSLVersion(version);
	}

	DE_ASSERT(false);
	return GLSL_VERSION_LAST;
}

// ShaderType

const char* getShaderTypeName (ShaderType shaderType)
{
	static const char* s_names[] =
	{
		"vertex",
		"fragment",
		"geometry",
		"tess_control",
		"tess_eval",
		"compute",
		"unused for GL",
		"unused for GL",
		"unused for GL",
		"unused for GL",
		"unused for GL",
		"unused for GL",
	};

	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_names) == SHADERTYPE_LAST);
	DE_ASSERT(deInBounds32((int)shaderType, 0, SHADERTYPE_LAST));
	return s_names[(int)shaderType];
}
<commit_msg>Fix false shader cache hits for ray tracing shaders<commit_after>/*-------------------------------------------------------------------------
 * drawElements Quality Program OpenGL ES Utilities
 * ------------------------------------------------
 *
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief Shader utilities.
 *//*--------------------------------------------------------------------*/

#include "gluShaderUtil.hpp"
#include "glwEnums.hpp"
#include "deArrayUtil.hpp"

namespace glu
{

// ShadingLanguageVersion

const char* getGLSLVersionName (GLSLVersion version)
{
	static const char* s_names[] =
	{
		"GLSL ES 1.0",
		"GLSL ES 3.0",
		"GLSL ES 3.1",
		"GLSL ES 3.2",
		"GLSL 1.3",
		"GLSL 1.4",
		"GLSL 1.5",
		"GLSL 3.3",
		"GLSL 4.0",
		"GLSL 4.1",
		"GLSL 4.2",
		"GLSL 4.3",
		"GLSL 4.4",
		"GLSL 4.5",
		"GLSL 4.6",
	};

	return de::getSizedArrayElement<GLSL_VERSION_LAST>(s_names, version);
}

const char* getGLSLVersionDeclaration (GLSLVersion version)
{
	static const char* s_decl[] =
	{
		"#version 100",
		"#version 300 es",
		"#version 310 es",
		"#version 320 es",
		"#version 130",
		"#version 140",
		"#version 150",
		"#version 330",
		"#version 400",
		"#version 410",
		"#version 420",
		"#version 430",
		"#version 440",
		"#version 450",
		"#version 460",
	};

	return de::getSizedArrayElement<GLSL_VERSION_LAST>(s_decl, version);
}

bool glslVersionUsesInOutQualifiers (GLSLVersion version)
{
	return de::inRange<int>(version, GLSL_VERSION_300_ES, GLSL_VERSION_320_ES) || de::inRange<int>(version, GLSL_VERSION_330, GLSL_VERSION_460);
}

bool glslVersionIsES (GLSLVersion version)
{
	DE_STATIC_ASSERT(GLSL_VERSION_LAST == 15);
	DE_ASSERT(version != GLSL_VERSION_LAST);

	if (version == GLSL_VERSION_100_ES	||
		version == GLSL_VERSION_300_ES	||
		version == GLSL_VERSION_310_ES	||
		version == GLSL_VERSION_320_ES)
		return true;
	else
		return false;
}

// \todo [2014-10-06 pyry] Export this.
static ApiType getMinAPIForGLSLVersion (GLSLVersion version)
{
	static const ApiType s_minApi[] =
	{
		ApiType::es(2,0),
		ApiType::es(3,0),
		ApiType::es(3,1),
		ApiType::es(3,2),
		ApiType::core(3,0),
		ApiType::core(3,1),
		ApiType::core(3,2),
		ApiType::core(3,3),
		ApiType::core(4,0),
		ApiType::core(4,1),
		ApiType::core(4,2),
		ApiType::core(4,3),
		ApiType::core(4,4),
		ApiType::core(4,5),
		ApiType::core(4,6),
	};

	return de::getSizedArrayElement<GLSL_VERSION_LAST>(s_minApi, version);
}

bool isGLSLVersionSupported (ContextType type, GLSLVersion version)
{
	return contextSupports(type, getMinAPIForGLSLVersion(version));
}

GLSLVersion getContextTypeGLSLVersion (ContextType type)
{
	// \note From newer to older
	for (int version = GLSL_VERSION_LAST-1; version >= 0; version--)
	{
		if (isGLSLVersionSupported(type, GLSLVersion(version)))
			return GLSLVersion(version);
	}

	DE_ASSERT(false);
	return GLSL_VERSION_LAST;
}

// ShaderType

const char* getShaderTypeName (ShaderType shaderType)
{
	static const char* s_names[] =
	{
		"vertex",
		"fragment",
		"geometry",
		"tess_control",
		"tess_eval",
		"compute",
		"ray_gen",
		"any_hit",
		"closest_hit",
		"miss",
		"intersection",
		"callable",
	};

	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_names) == SHADERTYPE_LAST);
	DE_ASSERT(deInBounds32((int)shaderType, 0, SHADERTYPE_LAST));
	return s_names[(int)shaderType];
}

{'fraction_non_alphanumeric': 0.18268120590121872, 'fraction_numerical': 0.03899935856318153, 'mean_word_length': 3.5831863609641386, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7039132', 'n_tokens_mistral': 3094, 'n_tokens_neox': 2772, 'n_words': 666}