Download third_party/ktx-src/tests/loadtests/glloadtests/shader-based/TextureArray.cpp from kimjunhan/vkgs-sim: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/third_party/ktx-src/tests/loadtests/glloadtests/shader-based/TextureArray.cpp
- Command line
-
hf download hf://kimjunhan/vkgs-sim/third_party/ktx-src/tests/loadtests/glloadtests/shader-based/TextureArray.cpp
-
curl -L -o TextureArray.cpp https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/third_party/ktx-src/tests/loadtests/glloadtests/shader-based/TextureArray.cpp
2.66 kB
| /* -*- tab-width: 4; -*- */ | |
| /* vi: set sw=2 ts=4 expandtab: */ | |
| /* | |
| * Copyright 2018-2020 Mark Callow. | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| /** | |
| * @internal | |
| * @file | |
| * @~English | |
| * | |
| * @brief Definition of test sample for loading and displaying the layers of a 2D array texture. | |
| * | |
| * @author Mark Callow, github.com/MarkCallow. | |
| */ | |
| const GLchar* pszFsArraySamplerDeclaration = | |
| "uniform mediump sampler2DArray uSampler;\n\n"; | |
| const GLchar* pszArrayVsMain = | |
| "void main()\n" | |
| "{\n" | |
| " UVW = vec3(inUV, gl_InstanceID);\n" | |
| " mat4 modelView = ubo.view * ubo.instance[gl_InstanceID].model;\n" | |
| " gl_Position = ubo.projection * modelView * inPos;\n" | |
| "}"; | |
| /* ------------------------------------------------------------------------- */ | |
| LoadTestSample* | |
| TextureArray::create(uint32_t width, uint32_t height, | |
| const char* const szArgs, const std::string sBasePath) | |
| { | |
| return new TextureArray(width, height, szArgs, sBasePath); | |
| } | |
| /** | |
| * @internal | |
| * @class TextureArray | |
| * @~English | |
| * | |
| * @brief Test loading of 2D texture arrays. | |
| */ | |
| TextureArray::TextureArray(uint32_t width, uint32_t height, | |
| const char* const szArgs, | |
| const std::string sBasePath) | |
| : InstancedSampleBase(width, height, szArgs, sBasePath) | |
| { | |
| zoom = -15.0f; | |
| if (texTarget != GL_TEXTURE_2D_ARRAY) { | |
| std::stringstream message; | |
| message << "TextureArray requires an array texture."; | |
| throw std::runtime_error(message.str()); | |
| } | |
| // Checking if KVData contains keys of interest would go here. | |
| instanceCount = textureInfo.numLayers; | |
| InstancedSampleBase::ShaderSource fs; | |
| InstancedSampleBase::ShaderSource vs; | |
| fs.push_back(pszInstancingFsDeclarations); | |
| fs.push_back(pszFsArraySamplerDeclaration); | |
| if (framebufferColorEncoding() == GL_LINEAR) { | |
| fs.push_back(pszSrgbEncodeFunc); | |
| fs.push_back(pszInstancingSrgbEncodeFsMain); | |
| } else { | |
| fs.push_back(pszInstancingFsMain);; | |
| } | |
| vs.push_back(pszInstancingVsDeclarations); | |
| vs.push_back(pszArrayVsMain); | |
| try { | |
| prepare(fs, vs); | |
| } catch (std::exception& e) { | |
| (void)e; // To quiet unused variable warnings from some compilers. | |
| cleanup(); | |
| throw; | |
| } | |
| bInitialized = true; | |
| } | |