xref: /aosp_15_r20/external/deqp/modules/glshared/glsShaderLibrary.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL (ES) Module
3  * -----------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Compiler test case.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "glsShaderLibrary.hpp"
25 #include "glsShaderLibraryCase.hpp"
26 
27 namespace deqp
28 {
29 namespace gls
30 {
31 
32 namespace
33 {
34 
35 class CaseFactory : public glu::sl::ShaderCaseFactory
36 {
37 public:
CaseFactory(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & contextInfo)38     CaseFactory(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const glu::ContextInfo &contextInfo)
39         : m_testCtx(testCtx)
40         , m_renderCtx(renderCtx)
41         , m_contextInfo(contextInfo)
42     {
43     }
44 
createGroup(const std::string & name,const std::string & description,const std::vector<tcu::TestNode * > & children)45     tcu::TestCaseGroup *createGroup(const std::string &name, const std::string &description,
46                                     const std::vector<tcu::TestNode *> &children)
47     {
48         return new tcu::TestCaseGroup(m_testCtx, name.c_str(), description.c_str(), children);
49     }
50 
createCase(const std::string & name,const std::string & description,const glu::sl::ShaderCaseSpecification & spec)51     tcu::TestCase *createCase(const std::string &name, const std::string &description,
52                               const glu::sl::ShaderCaseSpecification &spec)
53     {
54         return new ShaderLibraryCase(m_testCtx, m_renderCtx, m_contextInfo, name.c_str(), description.c_str(), spec);
55     }
56 
57 private:
58     tcu::TestContext &m_testCtx;
59     glu::RenderContext &m_renderCtx;
60     const glu::ContextInfo &m_contextInfo;
61 };
62 
63 } // namespace
64 
ShaderLibrary(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & contextInfo)65 ShaderLibrary::ShaderLibrary(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
66                              const glu::ContextInfo &contextInfo)
67     : m_testCtx(testCtx)
68     , m_renderCtx(renderCtx)
69     , m_contextInfo(contextInfo)
70 {
71 }
72 
~ShaderLibrary(void)73 ShaderLibrary::~ShaderLibrary(void)
74 {
75 }
76 
loadShaderFile(const char * fileName)77 std::vector<tcu::TestNode *> ShaderLibrary::loadShaderFile(const char *fileName)
78 {
79     CaseFactory caseFactory(m_testCtx, m_renderCtx, m_contextInfo);
80 
81     return glu::sl::parseFile(m_testCtx.getArchive(), fileName, &caseFactory);
82 }
83 
84 } // namespace gls
85 } // namespace deqp
86