blob: 92868c8d9459bcccf4a64330c5681ce25736537d [file] [log] [blame]
Jamie Madill9e54b5a2016-05-25 12:57:39 -04001//
2// Copyright 2016 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6// ProgramVk.cpp:
7// Implements the class methods for ProgramVk.
8//
9
10#include "libANGLE/renderer/vulkan/ProgramVk.h"
11
12#include "common/debug.h"
Jamie Madill8ecf7f92017-01-13 17:29:52 -050013#include "libANGLE/renderer/vulkan/ContextVk.h"
14#include "libANGLE/renderer/vulkan/GlslangWrapper.h"
15#include "libANGLE/renderer/vulkan/RendererVk.h"
Jamie Madill9e54b5a2016-05-25 12:57:39 -040016
17namespace rx
18{
19
20ProgramVk::ProgramVk(const gl::ProgramState &state) : ProgramImpl(state)
21{
22}
23
24ProgramVk::~ProgramVk()
25{
26}
27
Jamie Madilla7d12dc2016-12-13 15:08:19 -050028LinkResult ProgramVk::load(const ContextImpl *contextImpl,
29 gl::InfoLog &infoLog,
30 gl::BinaryInputStream *stream)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040031{
32 UNIMPLEMENTED();
Jamie Madillb0a838b2016-11-13 20:02:12 -050033 return gl::Error(GL_INVALID_OPERATION);
Jamie Madill9e54b5a2016-05-25 12:57:39 -040034}
35
36gl::Error ProgramVk::save(gl::BinaryOutputStream *stream)
37{
38 UNIMPLEMENTED();
39 return gl::Error(GL_INVALID_OPERATION);
40}
41
42void ProgramVk::setBinaryRetrievableHint(bool retrievable)
43{
44 UNIMPLEMENTED();
45}
46
Jamie Madill8ecf7f92017-01-13 17:29:52 -050047LinkResult ProgramVk::link(ContextImpl *contextImpl,
Jamie Madill192745a2016-12-22 15:58:21 -050048 const gl::VaryingPacking &packing,
49 gl::InfoLog &infoLog)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040050{
Jamie Madill8ecf7f92017-01-13 17:29:52 -050051 ContextVk *context = GetAs<ContextVk>(contextImpl);
52 RendererVk *renderer = context->getRenderer();
53 GlslangWrapper *glslangWrapper = renderer->getGlslangWrapper();
54
55 const std::string &vertexSource = mState.getAttachedVertexShader()->getTranslatedSource();
56 const std::string &fragmentSource = mState.getAttachedFragmentShader()->getTranslatedSource();
57
58 std::vector<uint32_t> vertexCode;
59 std::vector<uint32_t> fragmentCode;
60 bool linkSuccess = false;
61 ANGLE_TRY_RESULT(
62 glslangWrapper->linkProgram(vertexSource, fragmentSource, &vertexCode, &fragmentCode),
63 linkSuccess);
64 if (!linkSuccess)
65 {
66 return false;
67 }
68
69 vk::ShaderModule vertexModule(renderer->getDevice());
70 vk::ShaderModule fragmentModule(renderer->getDevice());
71
72 {
73 VkShaderModuleCreateInfo vertexShaderInfo;
74 vertexShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
75 vertexShaderInfo.pNext = nullptr;
76 vertexShaderInfo.flags = 0;
77 vertexShaderInfo.codeSize = vertexCode.size() * sizeof(uint32_t);
78 vertexShaderInfo.pCode = vertexCode.data();
79 ANGLE_TRY(vertexModule.init(vertexShaderInfo));
80 }
81
82 {
83 VkShaderModuleCreateInfo fragmentShaderInfo;
84 fragmentShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
85 fragmentShaderInfo.pNext = nullptr;
86 fragmentShaderInfo.flags = 0;
87 fragmentShaderInfo.codeSize = fragmentCode.size() * sizeof(uint32_t);
88 fragmentShaderInfo.pCode = fragmentCode.data();
89
90 ANGLE_TRY(fragmentModule.init(fragmentShaderInfo));
91 }
92
93 mLinkedVertexModule = std::move(vertexModule);
94 mLinkedFragmentModule = std::move(fragmentModule);
95
96 return true;
Jamie Madill9e54b5a2016-05-25 12:57:39 -040097}
98
99GLboolean ProgramVk::validate(const gl::Caps &caps, gl::InfoLog *infoLog)
100{
101 UNIMPLEMENTED();
102 return GLboolean();
103}
104
105void ProgramVk::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
106{
107 UNIMPLEMENTED();
108}
109
110void ProgramVk::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
111{
112 UNIMPLEMENTED();
113}
114
115void ProgramVk::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
116{
117 UNIMPLEMENTED();
118}
119
120void ProgramVk::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
121{
122 UNIMPLEMENTED();
123}
124
125void ProgramVk::setUniform1iv(GLint location, GLsizei count, const GLint *v)
126{
127 UNIMPLEMENTED();
128}
129
130void ProgramVk::setUniform2iv(GLint location, GLsizei count, const GLint *v)
131{
132 UNIMPLEMENTED();
133}
134
135void ProgramVk::setUniform3iv(GLint location, GLsizei count, const GLint *v)
136{
137 UNIMPLEMENTED();
138}
139
140void ProgramVk::setUniform4iv(GLint location, GLsizei count, const GLint *v)
141{
142 UNIMPLEMENTED();
143}
144
145void ProgramVk::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
146{
147 UNIMPLEMENTED();
148}
149
150void ProgramVk::setUniform2uiv(GLint location, GLsizei count, const GLuint *v)
151{
152 UNIMPLEMENTED();
153}
154
155void ProgramVk::setUniform3uiv(GLint location, GLsizei count, const GLuint *v)
156{
157 UNIMPLEMENTED();
158}
159
160void ProgramVk::setUniform4uiv(GLint location, GLsizei count, const GLuint *v)
161{
162 UNIMPLEMENTED();
163}
164
165void ProgramVk::setUniformMatrix2fv(GLint location,
166 GLsizei count,
167 GLboolean transpose,
168 const GLfloat *value)
169{
170 UNIMPLEMENTED();
171}
172
173void ProgramVk::setUniformMatrix3fv(GLint location,
174 GLsizei count,
175 GLboolean transpose,
176 const GLfloat *value)
177{
178 UNIMPLEMENTED();
179}
180
181void ProgramVk::setUniformMatrix4fv(GLint location,
182 GLsizei count,
183 GLboolean transpose,
184 const GLfloat *value)
185{
186 UNIMPLEMENTED();
187}
188
189void ProgramVk::setUniformMatrix2x3fv(GLint location,
190 GLsizei count,
191 GLboolean transpose,
192 const GLfloat *value)
193{
194 UNIMPLEMENTED();
195}
196
197void ProgramVk::setUniformMatrix3x2fv(GLint location,
198 GLsizei count,
199 GLboolean transpose,
200 const GLfloat *value)
201{
202 UNIMPLEMENTED();
203}
204
205void ProgramVk::setUniformMatrix2x4fv(GLint location,
206 GLsizei count,
207 GLboolean transpose,
208 const GLfloat *value)
209{
210 UNIMPLEMENTED();
211}
212
213void ProgramVk::setUniformMatrix4x2fv(GLint location,
214 GLsizei count,
215 GLboolean transpose,
216 const GLfloat *value)
217{
218 UNIMPLEMENTED();
219}
220
221void ProgramVk::setUniformMatrix3x4fv(GLint location,
222 GLsizei count,
223 GLboolean transpose,
224 const GLfloat *value)
225{
226 UNIMPLEMENTED();
227}
228
229void ProgramVk::setUniformMatrix4x3fv(GLint location,
230 GLsizei count,
231 GLboolean transpose,
232 const GLfloat *value)
233{
234 UNIMPLEMENTED();
235}
236
237void ProgramVk::setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding)
238{
239 UNIMPLEMENTED();
240}
241
242bool ProgramVk::getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const
243{
244 UNIMPLEMENTED();
245 return bool();
246}
247
248bool ProgramVk::getUniformBlockMemberInfo(const std::string &memberUniformName,
249 sh::BlockMemberInfo *memberInfoOut) const
250{
251 UNIMPLEMENTED();
252 return bool();
253}
254
Sami Väisänen46eaa942016-06-29 10:26:37 +0300255void ProgramVk::setPathFragmentInputGen(const std::string &inputName,
256 GLenum genMode,
257 GLint components,
258 const GLfloat *coeffs)
259{
260 UNIMPLEMENTED();
261}
262
Jamie Madill8ecf7f92017-01-13 17:29:52 -0500263const vk::ShaderModule &ProgramVk::getLinkedVertexModule() const
264{
265 ASSERT(mLinkedVertexModule.getHandle() != VK_NULL_HANDLE);
266 return mLinkedVertexModule;
267}
268
269const vk::ShaderModule &ProgramVk::getLinkedFragmentModule() const
270{
271 ASSERT(mLinkedFragmentModule.getHandle() != VK_NULL_HANDLE);
272 return mLinkedFragmentModule;
273}
274
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400275} // namespace rx