blob: f2fe557f76e86622067c076108de889fced88638 [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 Madillc564c072017-06-01 12:45:42 -040013#include "libANGLE/Context.h"
Jamie Madill8ecf7f92017-01-13 17:29:52 -050014#include "libANGLE/renderer/vulkan/ContextVk.h"
15#include "libANGLE/renderer/vulkan/GlslangWrapper.h"
16#include "libANGLE/renderer/vulkan/RendererVk.h"
Jamie Madill9e54b5a2016-05-25 12:57:39 -040017
18namespace rx
19{
20
21ProgramVk::ProgramVk(const gl::ProgramState &state) : ProgramImpl(state)
22{
23}
24
25ProgramVk::~ProgramVk()
26{
27}
28
Jamie Madillc564c072017-06-01 12:45:42 -040029void ProgramVk::destroy(const gl::Context *contextImpl)
Jamie Madill5deea722017-02-16 10:44:46 -050030{
Jamie Madillc564c072017-06-01 12:45:42 -040031 VkDevice device = GetImplAs<ContextVk>(contextImpl)->getDevice();
Jamie Madill5deea722017-02-16 10:44:46 -050032
33 mLinkedFragmentModule.destroy(device);
34 mLinkedVertexModule.destroy(device);
35 mPipelineLayout.destroy(device);
36}
37
Jamie Madill9cf9e872017-06-05 12:59:25 -040038gl::LinkResult ProgramVk::load(const gl::Context *contextImpl,
39 gl::InfoLog &infoLog,
40 gl::BinaryInputStream *stream)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040041{
42 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -050043 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040044}
45
Jamie Madill27a60632017-06-30 15:12:01 -040046void ProgramVk::save(const gl::Context *context, gl::BinaryOutputStream *stream)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040047{
48 UNIMPLEMENTED();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040049}
50
51void ProgramVk::setBinaryRetrievableHint(bool retrievable)
52{
53 UNIMPLEMENTED();
54}
55
Yunchao He61afff12017-03-14 15:34:03 +080056void ProgramVk::setSeparable(bool separable)
57{
58 UNIMPLEMENTED();
59}
60
Jamie Madill9cf9e872017-06-05 12:59:25 -040061gl::LinkResult ProgramVk::link(const gl::Context *glContext,
62 const gl::VaryingPacking &packing,
63 gl::InfoLog &infoLog)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040064{
Jamie Madillc564c072017-06-01 12:45:42 -040065 ContextVk *context = GetImplAs<ContextVk>(glContext);
Jamie Madill8ecf7f92017-01-13 17:29:52 -050066 RendererVk *renderer = context->getRenderer();
67 GlslangWrapper *glslangWrapper = renderer->getGlslangWrapper();
68
Jamie Madill8ecf7f92017-01-13 17:29:52 -050069 std::vector<uint32_t> vertexCode;
70 std::vector<uint32_t> fragmentCode;
71 bool linkSuccess = false;
Jamie Madill2a9e1072017-09-22 11:31:57 -040072 ANGLE_TRY_RESULT(glslangWrapper->linkProgram(glContext, mState, &vertexCode, &fragmentCode),
73 linkSuccess);
Jamie Madill8ecf7f92017-01-13 17:29:52 -050074 if (!linkSuccess)
75 {
76 return false;
77 }
78
Jamie Madill5deea722017-02-16 10:44:46 -050079 vk::ShaderModule vertexModule;
80 vk::ShaderModule fragmentModule;
81 VkDevice device = renderer->getDevice();
Jamie Madill8ecf7f92017-01-13 17:29:52 -050082
83 {
84 VkShaderModuleCreateInfo vertexShaderInfo;
85 vertexShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
86 vertexShaderInfo.pNext = nullptr;
87 vertexShaderInfo.flags = 0;
88 vertexShaderInfo.codeSize = vertexCode.size() * sizeof(uint32_t);
89 vertexShaderInfo.pCode = vertexCode.data();
Jamie Madill5deea722017-02-16 10:44:46 -050090 ANGLE_TRY(vertexModule.init(device, vertexShaderInfo));
Jamie Madill8ecf7f92017-01-13 17:29:52 -050091 }
92
93 {
94 VkShaderModuleCreateInfo fragmentShaderInfo;
95 fragmentShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
96 fragmentShaderInfo.pNext = nullptr;
97 fragmentShaderInfo.flags = 0;
98 fragmentShaderInfo.codeSize = fragmentCode.size() * sizeof(uint32_t);
99 fragmentShaderInfo.pCode = fragmentCode.data();
100
Jamie Madill5deea722017-02-16 10:44:46 -0500101 ANGLE_TRY(fragmentModule.init(device, fragmentShaderInfo));
Jamie Madill8ecf7f92017-01-13 17:29:52 -0500102 }
103
Jamie Madill5deea722017-02-16 10:44:46 -0500104 mLinkedVertexModule.retain(device, std::move(vertexModule));
105 mLinkedFragmentModule.retain(device, std::move(fragmentModule));
Jamie Madill8ecf7f92017-01-13 17:29:52 -0500106
Jamie Madill72106562017-03-24 14:18:50 -0400107 // TODO(jmadill): Use pipeline cache.
108 context->invalidateCurrentPipeline();
109
Jamie Madill8ecf7f92017-01-13 17:29:52 -0500110 return true;
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400111}
112
113GLboolean ProgramVk::validate(const gl::Caps &caps, gl::InfoLog *infoLog)
114{
115 UNIMPLEMENTED();
116 return GLboolean();
117}
118
119void ProgramVk::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
120{
121 UNIMPLEMENTED();
122}
123
124void ProgramVk::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
125{
126 UNIMPLEMENTED();
127}
128
129void ProgramVk::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
130{
131 UNIMPLEMENTED();
132}
133
134void ProgramVk::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
135{
136 UNIMPLEMENTED();
137}
138
139void ProgramVk::setUniform1iv(GLint location, GLsizei count, const GLint *v)
140{
141 UNIMPLEMENTED();
142}
143
144void ProgramVk::setUniform2iv(GLint location, GLsizei count, const GLint *v)
145{
146 UNIMPLEMENTED();
147}
148
149void ProgramVk::setUniform3iv(GLint location, GLsizei count, const GLint *v)
150{
151 UNIMPLEMENTED();
152}
153
154void ProgramVk::setUniform4iv(GLint location, GLsizei count, const GLint *v)
155{
156 UNIMPLEMENTED();
157}
158
159void ProgramVk::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
160{
161 UNIMPLEMENTED();
162}
163
164void ProgramVk::setUniform2uiv(GLint location, GLsizei count, const GLuint *v)
165{
166 UNIMPLEMENTED();
167}
168
169void ProgramVk::setUniform3uiv(GLint location, GLsizei count, const GLuint *v)
170{
171 UNIMPLEMENTED();
172}
173
174void ProgramVk::setUniform4uiv(GLint location, GLsizei count, const GLuint *v)
175{
176 UNIMPLEMENTED();
177}
178
179void ProgramVk::setUniformMatrix2fv(GLint location,
180 GLsizei count,
181 GLboolean transpose,
182 const GLfloat *value)
183{
184 UNIMPLEMENTED();
185}
186
187void ProgramVk::setUniformMatrix3fv(GLint location,
188 GLsizei count,
189 GLboolean transpose,
190 const GLfloat *value)
191{
192 UNIMPLEMENTED();
193}
194
195void ProgramVk::setUniformMatrix4fv(GLint location,
196 GLsizei count,
197 GLboolean transpose,
198 const GLfloat *value)
199{
200 UNIMPLEMENTED();
201}
202
203void ProgramVk::setUniformMatrix2x3fv(GLint location,
204 GLsizei count,
205 GLboolean transpose,
206 const GLfloat *value)
207{
208 UNIMPLEMENTED();
209}
210
211void ProgramVk::setUniformMatrix3x2fv(GLint location,
212 GLsizei count,
213 GLboolean transpose,
214 const GLfloat *value)
215{
216 UNIMPLEMENTED();
217}
218
219void ProgramVk::setUniformMatrix2x4fv(GLint location,
220 GLsizei count,
221 GLboolean transpose,
222 const GLfloat *value)
223{
224 UNIMPLEMENTED();
225}
226
227void ProgramVk::setUniformMatrix4x2fv(GLint location,
228 GLsizei count,
229 GLboolean transpose,
230 const GLfloat *value)
231{
232 UNIMPLEMENTED();
233}
234
235void ProgramVk::setUniformMatrix3x4fv(GLint location,
236 GLsizei count,
237 GLboolean transpose,
238 const GLfloat *value)
239{
240 UNIMPLEMENTED();
241}
242
243void ProgramVk::setUniformMatrix4x3fv(GLint location,
244 GLsizei count,
245 GLboolean transpose,
246 const GLfloat *value)
247{
248 UNIMPLEMENTED();
249}
250
251void ProgramVk::setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding)
252{
253 UNIMPLEMENTED();
254}
255
Olli Etuaho855d9642017-05-17 14:05:06 +0300256bool ProgramVk::getUniformBlockSize(const std::string &blockName,
257 const std::string &blockMappedName,
258 size_t *sizeOut) const
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400259{
260 UNIMPLEMENTED();
261 return bool();
262}
263
264bool ProgramVk::getUniformBlockMemberInfo(const std::string &memberUniformName,
Olli Etuaho855d9642017-05-17 14:05:06 +0300265 const std::string &memberUniformMappedName,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400266 sh::BlockMemberInfo *memberInfoOut) const
267{
268 UNIMPLEMENTED();
269 return bool();
270}
271
Sami Väisänen46eaa942016-06-29 10:26:37 +0300272void ProgramVk::setPathFragmentInputGen(const std::string &inputName,
273 GLenum genMode,
274 GLint components,
275 const GLfloat *coeffs)
276{
277 UNIMPLEMENTED();
278}
279
Jamie Madill8ecf7f92017-01-13 17:29:52 -0500280const vk::ShaderModule &ProgramVk::getLinkedVertexModule() const
281{
282 ASSERT(mLinkedVertexModule.getHandle() != VK_NULL_HANDLE);
283 return mLinkedVertexModule;
284}
285
286const vk::ShaderModule &ProgramVk::getLinkedFragmentModule() const
287{
288 ASSERT(mLinkedFragmentModule.getHandle() != VK_NULL_HANDLE);
289 return mLinkedFragmentModule;
290}
291
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500292gl::ErrorOrResult<vk::PipelineLayout *> ProgramVk::getPipelineLayout(VkDevice device)
293{
Jamie Madill5deea722017-02-16 10:44:46 -0500294 vk::PipelineLayout newLayout;
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500295
296 // TODO(jmadill): Descriptor sets.
297 VkPipelineLayoutCreateInfo createInfo;
298 createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
299 createInfo.pNext = nullptr;
300 createInfo.flags = 0;
301 createInfo.setLayoutCount = 0;
302 createInfo.pSetLayouts = nullptr;
303 createInfo.pushConstantRangeCount = 0;
304 createInfo.pPushConstantRanges = nullptr;
305
Jamie Madill5deea722017-02-16 10:44:46 -0500306 ANGLE_TRY(newLayout.init(device, createInfo));
307 mPipelineLayout.retain(device, std::move(newLayout));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500308
309 return &mPipelineLayout;
310}
311
Jamie Madill54164b02017-08-28 15:17:37 -0400312void ProgramVk::getUniformfv(const gl::Context *context, GLint location, GLfloat *params) const
313{
314 UNIMPLEMENTED();
315}
316
317void ProgramVk::getUniformiv(const gl::Context *context, GLint location, GLint *params) const
318{
319 UNIMPLEMENTED();
320}
321
322void ProgramVk::getUniformuiv(const gl::Context *context, GLint location, GLuint *params) const
323{
324 UNIMPLEMENTED();
325}
326
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400327} // namespace rx