blob: fcdf6bb164a839a35551fa02442383ff2fb6996c [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// ContextVk.cpp:
7// Implements the class methods for ContextVk.
8//
9
10#include "libANGLE/renderer/vulkan/ContextVk.h"
11
Jamie Madill20e005b2017-04-07 14:19:22 -040012#include "common/bitset_utils.h"
Jamie Madill9e54b5a2016-05-25 12:57:39 -040013#include "common/debug.h"
Jamie Madilldf68a6f2017-01-13 17:29:53 -050014#include "libANGLE/Program.h"
Jamie Madillacccc6c2016-05-03 17:22:10 -040015#include "libANGLE/renderer/vulkan/BufferVk.h"
16#include "libANGLE/renderer/vulkan/CompilerVk.h"
17#include "libANGLE/renderer/vulkan/ContextVk.h"
18#include "libANGLE/renderer/vulkan/DeviceVk.h"
19#include "libANGLE/renderer/vulkan/FenceNVVk.h"
Jamie Madillacccc6c2016-05-03 17:22:10 -040020#include "libANGLE/renderer/vulkan/FramebufferVk.h"
21#include "libANGLE/renderer/vulkan/ImageVk.h"
Yunchao Hea336b902017-08-02 16:05:21 +080022#include "libANGLE/renderer/vulkan/ProgramPipelineVk.h"
Jamie Madillacccc6c2016-05-03 17:22:10 -040023#include "libANGLE/renderer/vulkan/ProgramVk.h"
24#include "libANGLE/renderer/vulkan/QueryVk.h"
25#include "libANGLE/renderer/vulkan/RenderbufferVk.h"
26#include "libANGLE/renderer/vulkan/RendererVk.h"
27#include "libANGLE/renderer/vulkan/SamplerVk.h"
28#include "libANGLE/renderer/vulkan/ShaderVk.h"
Jamie Madill70b5bb02017-08-28 13:32:37 -040029#include "libANGLE/renderer/vulkan/SyncVk.h"
Jamie Madillacccc6c2016-05-03 17:22:10 -040030#include "libANGLE/renderer/vulkan/TextureVk.h"
31#include "libANGLE/renderer/vulkan/TransformFeedbackVk.h"
32#include "libANGLE/renderer/vulkan/VertexArrayVk.h"
Jamie Madilldf68a6f2017-01-13 17:29:53 -050033#include "libANGLE/renderer/vulkan/formatutilsvk.h"
Jamie Madill9e54b5a2016-05-25 12:57:39 -040034
35namespace rx
36{
37
Jamie Madillacccc6c2016-05-03 17:22:10 -040038ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer)
Jamie Madill72106562017-03-24 14:18:50 -040039 : ContextImpl(state), mRenderer(renderer), mCurrentDrawMode(GL_NONE)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040040{
41}
42
43ContextVk::~ContextVk()
44{
Jamie Madill72106562017-03-24 14:18:50 -040045 invalidateCurrentPipeline();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040046}
47
48gl::Error ContextVk::initialize()
49{
Jamie Madille09bd5d2016-11-29 16:20:35 -050050 return gl::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040051}
52
53gl::Error ContextVk::flush()
54{
55 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -050056 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040057}
58
59gl::Error ContextVk::finish()
60{
61 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -050062 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040063}
64
Jamie Madill4928b7c2017-06-20 12:57:39 -040065gl::Error ContextVk::initPipeline(const gl::Context *context)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040066{
Jamie Madill72106562017-03-24 14:18:50 -040067 ASSERT(!mCurrentPipeline.valid());
68
Jamie Madilldf68a6f2017-01-13 17:29:53 -050069 VkDevice device = mRenderer->getDevice();
70 const auto &state = mState.getState();
71 const auto &programGL = state.getProgram();
72 const auto &vao = state.getVertexArray();
73 const auto &attribs = vao->getVertexAttributes();
Jiawei-Shao2597fb62016-12-09 16:38:02 +080074 const auto &bindings = vao->getVertexBindings();
Jamie Madilldf68a6f2017-01-13 17:29:53 -050075 const auto &programVk = GetImplAs<ProgramVk>(programGL);
76 const auto *drawFBO = state.getDrawFramebuffer();
77 FramebufferVk *vkFBO = GetImplAs<FramebufferVk>(drawFBO);
78
79 // { vertex, fragment }
80 VkPipelineShaderStageCreateInfo shaderStages[2];
81
82 shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
83 shaderStages[0].pNext = nullptr;
84 shaderStages[0].flags = 0;
85 shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
86 shaderStages[0].module = programVk->getLinkedVertexModule().getHandle();
87 shaderStages[0].pName = "main";
88 shaderStages[0].pSpecializationInfo = nullptr;
89
90 shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
91 shaderStages[1].pNext = nullptr;
92 shaderStages[1].flags = 0;
93 shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
94 shaderStages[1].module = programVk->getLinkedFragmentModule().getHandle();
95 shaderStages[1].pName = "main";
96 shaderStages[1].pSpecializationInfo = nullptr;
97
98 // Process vertex attributes
99 // TODO(jmadill): Caching with dirty bits.
100 std::vector<VkVertexInputBindingDescription> vertexBindings;
101 std::vector<VkVertexInputAttributeDescription> vertexAttribs;
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500102
Jamie Madill6de51852017-04-12 09:53:01 -0400103 for (auto attribIndex : programGL->getActiveAttribLocationsMask())
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500104 {
Jamie Madill231c7f52017-04-26 13:45:37 -0400105 const auto &attrib = attribs[attribIndex];
Jiawei-Shao2597fb62016-12-09 16:38:02 +0800106 const auto &binding = bindings[attrib.bindingIndex];
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500107 if (attrib.enabled)
108 {
109 VkVertexInputBindingDescription bindingDesc;
110 bindingDesc.binding = static_cast<uint32_t>(vertexBindings.size());
111 bindingDesc.stride = static_cast<uint32_t>(gl::ComputeVertexAttributeTypeSize(attrib));
Martin Radevdd5f27e2017-06-07 10:17:09 +0300112 bindingDesc.inputRate = (binding.getDivisor() > 0 ? VK_VERTEX_INPUT_RATE_INSTANCE
113 : VK_VERTEX_INPUT_RATE_VERTEX);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500114
115 gl::VertexFormatType vertexFormatType = gl::GetVertexFormatType(attrib);
116
117 VkVertexInputAttributeDescription attribDesc;
118 attribDesc.binding = bindingDesc.binding;
119 attribDesc.format = vk::GetNativeVertexFormat(vertexFormatType);
120 attribDesc.location = static_cast<uint32_t>(attribIndex);
Jiawei-Shao2597fb62016-12-09 16:38:02 +0800121 attribDesc.offset =
122 static_cast<uint32_t>(ComputeVertexAttributeOffset(attrib, binding));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500123
124 vertexBindings.push_back(bindingDesc);
125 vertexAttribs.push_back(attribDesc);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500126 }
127 else
128 {
129 UNIMPLEMENTED();
130 }
131 }
132
133 // TODO(jmadill): Validate with ASSERT against physical device limits/caps?
134 VkPipelineVertexInputStateCreateInfo vertexInputState;
135 vertexInputState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
136 vertexInputState.pNext = nullptr;
137 vertexInputState.flags = 0;
138 vertexInputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertexBindings.size());
139 vertexInputState.pVertexBindingDescriptions = vertexBindings.data();
140 vertexInputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertexAttribs.size());
141 vertexInputState.pVertexAttributeDescriptions = vertexAttribs.data();
142
143 VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
144 inputAssemblyState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
145 inputAssemblyState.pNext = nullptr;
146 inputAssemblyState.flags = 0;
Jamie Madill72106562017-03-24 14:18:50 -0400147 inputAssemblyState.topology = gl_vk::GetPrimitiveTopology(mCurrentDrawMode);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500148 inputAssemblyState.primitiveRestartEnable = VK_FALSE;
149
150 const gl::Rectangle &viewportGL = state.getViewport();
151 VkViewport viewportVk;
152 viewportVk.x = static_cast<float>(viewportGL.x);
153 viewportVk.y = static_cast<float>(viewportGL.y);
154 viewportVk.width = static_cast<float>(viewportGL.width);
155 viewportVk.height = static_cast<float>(viewportGL.height);
156 viewportVk.minDepth = state.getNearPlane();
157 viewportVk.maxDepth = state.getFarPlane();
158
159 // TODO(jmadill): Scissor.
160 VkRect2D scissorVk;
161 scissorVk.offset.x = viewportGL.x;
162 scissorVk.offset.y = viewportGL.y;
163 scissorVk.extent.width = viewportGL.width;
164 scissorVk.extent.height = viewportGL.height;
165
166 VkPipelineViewportStateCreateInfo viewportState;
167 viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
168 viewportState.pNext = nullptr;
169 viewportState.flags = 0;
170 viewportState.viewportCount = 1;
171 viewportState.pViewports = &viewportVk;
172 viewportState.scissorCount = 1;
173 viewportState.pScissors = &scissorVk;
174
175 // TODO(jmadill): Extra rasterizer state features.
176 VkPipelineRasterizationStateCreateInfo rasterState;
177 rasterState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
178 rasterState.pNext = nullptr;
179 rasterState.flags = 0;
180 rasterState.depthClampEnable = VK_FALSE;
181 rasterState.rasterizerDiscardEnable = VK_FALSE;
182 rasterState.polygonMode = VK_POLYGON_MODE_FILL;
183 rasterState.cullMode = gl_vk::GetCullMode(state.getRasterizerState());
184 rasterState.frontFace = gl_vk::GetFrontFace(state.getRasterizerState().frontFace);
185 rasterState.depthBiasEnable = VK_FALSE;
186 rasterState.depthBiasConstantFactor = 0.0f;
187 rasterState.depthBiasClamp = 0.0f;
188 rasterState.depthBiasSlopeFactor = 0.0f;
189 rasterState.lineWidth = state.getLineWidth();
190
191 // TODO(jmadill): Multisample state.
192 VkPipelineMultisampleStateCreateInfo multisampleState;
193 multisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
194 multisampleState.pNext = nullptr;
195 multisampleState.flags = 0;
Jamie Madill72106562017-03-24 14:18:50 -0400196 multisampleState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
197 multisampleState.sampleShadingEnable = VK_FALSE;
198 multisampleState.minSampleShading = 0.0f;
199 multisampleState.pSampleMask = nullptr;
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500200 multisampleState.alphaToCoverageEnable = VK_FALSE;
201 multisampleState.alphaToOneEnable = VK_FALSE;
202
203 // TODO(jmadill): Depth/stencil state.
204
205 // TODO(jmadill): Blend state/MRT.
206 VkPipelineColorBlendAttachmentState blendAttachmentState;
207 blendAttachmentState.blendEnable = VK_FALSE;
208 blendAttachmentState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
209 blendAttachmentState.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
210 blendAttachmentState.colorBlendOp = VK_BLEND_OP_ADD;
211 blendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
212 blendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
213 blendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
214 blendAttachmentState.colorWriteMask = (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
215 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT);
216
217 VkPipelineColorBlendStateCreateInfo blendState;
218 blendState.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
219 blendState.pNext = 0;
220 blendState.flags = 0;
221 blendState.logicOpEnable = VK_FALSE;
222 blendState.logicOp = VK_LOGIC_OP_CLEAR;
223 blendState.attachmentCount = 1;
224 blendState.pAttachments = &blendAttachmentState;
225 blendState.blendConstants[0] = 0.0f;
226 blendState.blendConstants[1] = 0.0f;
227 blendState.blendConstants[2] = 0.0f;
228 blendState.blendConstants[3] = 0.0f;
229
230 // TODO(jmadill): Dynamic state.
231 vk::RenderPass *renderPass = nullptr;
Jamie Madill4928b7c2017-06-20 12:57:39 -0400232 ANGLE_TRY_RESULT(vkFBO->getRenderPass(context, device), renderPass);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500233 ASSERT(renderPass && renderPass->valid());
234
235 vk::PipelineLayout *pipelineLayout = nullptr;
236 ANGLE_TRY_RESULT(programVk->getPipelineLayout(device), pipelineLayout);
237 ASSERT(pipelineLayout && pipelineLayout->valid());
238
239 VkGraphicsPipelineCreateInfo pipelineInfo;
240 pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
241 pipelineInfo.pNext = nullptr;
242 pipelineInfo.flags = 0;
243 pipelineInfo.stageCount = 2;
244 pipelineInfo.pStages = shaderStages;
245 pipelineInfo.pVertexInputState = &vertexInputState;
246 pipelineInfo.pInputAssemblyState = &inputAssemblyState;
247 pipelineInfo.pTessellationState = nullptr;
248 pipelineInfo.pViewportState = &viewportState;
249 pipelineInfo.pRasterizationState = &rasterState;
250 pipelineInfo.pMultisampleState = &multisampleState;
251 pipelineInfo.pDepthStencilState = nullptr;
252 pipelineInfo.pColorBlendState = &blendState;
253 pipelineInfo.pDynamicState = nullptr;
254 pipelineInfo.layout = pipelineLayout->getHandle();
255 pipelineInfo.renderPass = renderPass->getHandle();
256 pipelineInfo.subpass = 0;
257 pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
258 pipelineInfo.basePipelineIndex = 0;
259
Jamie Madill5deea722017-02-16 10:44:46 -0500260 vk::Pipeline newPipeline;
261 ANGLE_TRY(newPipeline.initGraphics(device, pipelineInfo));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500262
Jamie Madill5deea722017-02-16 10:44:46 -0500263 mCurrentPipeline.retain(device, std::move(newPipeline));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500264
Jamie Madill72106562017-03-24 14:18:50 -0400265 return gl::NoError();
266}
267
Jamie Madillc564c072017-06-01 12:45:42 -0400268gl::Error ContextVk::drawArrays(const gl::Context *context, GLenum mode, GLint first, GLsizei count)
Jamie Madill72106562017-03-24 14:18:50 -0400269{
270 if (mode != mCurrentDrawMode)
271 {
272 invalidateCurrentPipeline();
273 mCurrentDrawMode = mode;
274 }
275
276 if (!mCurrentPipeline.valid())
277 {
Jamie Madill4928b7c2017-06-20 12:57:39 -0400278 ANGLE_TRY(initPipeline(context));
Jamie Madill72106562017-03-24 14:18:50 -0400279 ASSERT(mCurrentPipeline.valid());
280 }
281
282 VkDevice device = mRenderer->getDevice();
283 const auto &state = mState.getState();
284 const auto &programGL = state.getProgram();
285 const auto &vao = state.getVertexArray();
286 const auto &attribs = vao->getVertexAttributes();
287 const auto &bindings = vao->getVertexBindings();
288 const auto *drawFBO = state.getDrawFramebuffer();
289 FramebufferVk *vkFBO = GetImplAs<FramebufferVk>(drawFBO);
290 Serial queueSerial = mRenderer->getCurrentQueueSerial();
291
292 // Process vertex attributes
293 // TODO(jmadill): Caching with dirty bits.
294 std::vector<VkBuffer> vertexHandles;
295 std::vector<VkDeviceSize> vertexOffsets;
296
Jamie Madill6de51852017-04-12 09:53:01 -0400297 for (auto attribIndex : programGL->getActiveAttribLocationsMask())
Jamie Madill72106562017-03-24 14:18:50 -0400298 {
299 const auto &attrib = attribs[attribIndex];
300 const auto &binding = bindings[attrib.bindingIndex];
301 if (attrib.enabled)
302 {
303 // TODO(jmadill): Offset handling.
Martin Radevdd5f27e2017-06-07 10:17:09 +0300304 gl::Buffer *bufferGL = binding.getBuffer().get();
Jamie Madill72106562017-03-24 14:18:50 -0400305 ASSERT(bufferGL);
306 BufferVk *bufferVk = GetImplAs<BufferVk>(bufferGL);
307 vertexHandles.push_back(bufferVk->getVkBuffer().getHandle());
308 vertexOffsets.push_back(0);
309
310 bufferVk->setQueueSerial(queueSerial);
311 }
312 else
313 {
314 UNIMPLEMENTED();
315 }
316 }
317
Jamie Madill0c0dc342017-03-24 14:18:51 -0400318 vk::CommandBuffer *commandBuffer = nullptr;
319 ANGLE_TRY(mRenderer->getStartedCommandBuffer(&commandBuffer));
Jamie Madill4928b7c2017-06-20 12:57:39 -0400320 ANGLE_TRY(vkFBO->beginRenderPass(context, device, commandBuffer, queueSerial, state));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500321
322 commandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, mCurrentPipeline);
Jamie Madillabd31352017-09-19 00:24:58 -0400323 // TODO(jmadill): the queue serial should be bound to the pipeline.
324 setQueueSerial(queueSerial);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500325 commandBuffer->bindVertexBuffers(0, vertexHandles, vertexOffsets);
326 commandBuffer->draw(count, 1, first, 0);
327 commandBuffer->endRenderPass();
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500328
329 return gl::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400330}
331
Jamie Madillc564c072017-06-01 12:45:42 -0400332gl::Error ContextVk::drawArraysInstanced(const gl::Context *context,
333 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400334 GLint first,
335 GLsizei count,
336 GLsizei instanceCount)
337{
338 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500339 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400340}
341
Jamie Madillc564c072017-06-01 12:45:42 -0400342gl::Error ContextVk::drawElements(const gl::Context *context,
343 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400344 GLsizei count,
345 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800346 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400347{
348 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500349 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400350}
351
Jamie Madillc564c072017-06-01 12:45:42 -0400352gl::Error ContextVk::drawElementsInstanced(const gl::Context *context,
353 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400354 GLsizei count,
355 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400356 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800357 GLsizei instances)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400358{
359 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500360 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400361}
362
Jamie Madillc564c072017-06-01 12:45:42 -0400363gl::Error ContextVk::drawRangeElements(const gl::Context *context,
364 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400365 GLuint start,
366 GLuint end,
367 GLsizei count,
368 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800369 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400370{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500371 return gl::NoError();
372}
373
374VkDevice ContextVk::getDevice() const
375{
376 return mRenderer->getDevice();
377}
378
Jamie Madill0c0dc342017-03-24 14:18:51 -0400379vk::Error ContextVk::getStartedCommandBuffer(vk::CommandBuffer **commandBufferOut)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500380{
Jamie Madill0c0dc342017-03-24 14:18:51 -0400381 return mRenderer->getStartedCommandBuffer(commandBufferOut);
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500382}
383
Jamie Madill0c0dc342017-03-24 14:18:51 -0400384vk::Error ContextVk::submitCommands(vk::CommandBuffer *commandBuffer)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500385{
Jamie Madill72106562017-03-24 14:18:50 -0400386 setQueueSerial(mRenderer->getCurrentQueueSerial());
Jamie Madillf651c772017-02-21 15:03:51 -0500387 ANGLE_TRY(mRenderer->submitCommandBuffer(commandBuffer));
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500388 return vk::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400389}
390
Jamie Madillc564c072017-06-01 12:45:42 -0400391gl::Error ContextVk::drawArraysIndirect(const gl::Context *context,
392 GLenum mode,
393 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800394{
395 UNIMPLEMENTED();
396 return gl::InternalError() << "DrawArraysIndirect hasn't been implemented for vulkan backend.";
397}
398
Jamie Madillc564c072017-06-01 12:45:42 -0400399gl::Error ContextVk::drawElementsIndirect(const gl::Context *context,
400 GLenum mode,
401 GLenum type,
402 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800403{
404 UNIMPLEMENTED();
405 return gl::InternalError()
406 << "DrawElementsIndirect hasn't been implemented for vulkan backend.";
407}
408
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400409GLenum ContextVk::getResetStatus()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400410{
411 UNIMPLEMENTED();
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400412 return GL_NO_ERROR;
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400413}
414
415std::string ContextVk::getVendorString() const
416{
417 UNIMPLEMENTED();
418 return std::string();
419}
420
421std::string ContextVk::getRendererDescription() const
422{
Jamie Madille09bd5d2016-11-29 16:20:35 -0500423 return mRenderer->getRendererDescription();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400424}
425
426void ContextVk::insertEventMarker(GLsizei length, const char *marker)
427{
428 UNIMPLEMENTED();
429}
430
431void ContextVk::pushGroupMarker(GLsizei length, const char *marker)
432{
433 UNIMPLEMENTED();
434}
435
436void ContextVk::popGroupMarker()
437{
438 UNIMPLEMENTED();
439}
440
Jamie Madillfe548342017-06-19 11:13:24 -0400441void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400442{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500443 // TODO(jmadill): Vulkan dirty bits.
Jamie Madill72106562017-03-24 14:18:50 -0400444 if (dirtyBits.any())
445 {
446 invalidateCurrentPipeline();
447 }
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400448}
449
450GLint ContextVk::getGPUDisjoint()
451{
452 UNIMPLEMENTED();
453 return GLint();
454}
455
456GLint64 ContextVk::getTimestamp()
457{
458 UNIMPLEMENTED();
459 return GLint64();
460}
461
Jamie Madill4928b7c2017-06-20 12:57:39 -0400462void ContextVk::onMakeCurrent(const gl::Context * /*context*/)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400463{
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400464}
465
466const gl::Caps &ContextVk::getNativeCaps() const
467{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400468 return mRenderer->getNativeCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400469}
470
471const gl::TextureCapsMap &ContextVk::getNativeTextureCaps() const
472{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400473 return mRenderer->getNativeTextureCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400474}
475
476const gl::Extensions &ContextVk::getNativeExtensions() const
477{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400478 return mRenderer->getNativeExtensions();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400479}
480
481const gl::Limitations &ContextVk::getNativeLimitations() const
482{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400483 return mRenderer->getNativeLimitations();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400484}
485
486CompilerImpl *ContextVk::createCompiler()
487{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400488 return new CompilerVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400489}
490
Jamie Madillacccc6c2016-05-03 17:22:10 -0400491ShaderImpl *ContextVk::createShader(const gl::ShaderState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400492{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400493 return new ShaderVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400494}
495
Jamie Madillacccc6c2016-05-03 17:22:10 -0400496ProgramImpl *ContextVk::createProgram(const gl::ProgramState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400497{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400498 return new ProgramVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400499}
500
Jamie Madillacccc6c2016-05-03 17:22:10 -0400501FramebufferImpl *ContextVk::createFramebuffer(const gl::FramebufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400502{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500503 return FramebufferVk::CreateUserFBO(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400504}
505
506TextureImpl *ContextVk::createTexture(const gl::TextureState &state)
507{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400508 return new TextureVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400509}
510
511RenderbufferImpl *ContextVk::createRenderbuffer()
512{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400513 return new RenderbufferVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400514}
515
Jamie Madill8f775602016-11-03 16:45:34 -0400516BufferImpl *ContextVk::createBuffer(const gl::BufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400517{
Jamie Madill8f775602016-11-03 16:45:34 -0400518 return new BufferVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400519}
520
Jamie Madillacccc6c2016-05-03 17:22:10 -0400521VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400522{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400523 return new VertexArrayVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400524}
525
526QueryImpl *ContextVk::createQuery(GLenum type)
527{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400528 return new QueryVk(type);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400529}
530
531FenceNVImpl *ContextVk::createFenceNV()
532{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400533 return new FenceNVVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400534}
535
Jamie Madill70b5bb02017-08-28 13:32:37 -0400536SyncImpl *ContextVk::createSync()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400537{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400538 return new SyncVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400539}
540
Geoff Lang73bd2182016-07-15 13:01:24 -0400541TransformFeedbackImpl *ContextVk::createTransformFeedback(const gl::TransformFeedbackState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400542{
Geoff Lang73bd2182016-07-15 13:01:24 -0400543 return new TransformFeedbackVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400544}
545
Jamie Madill06ef36b2017-09-09 23:32:46 -0400546SamplerImpl *ContextVk::createSampler(const gl::SamplerState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400547{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400548 return new SamplerVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400549}
550
Yunchao Hea336b902017-08-02 16:05:21 +0800551ProgramPipelineImpl *ContextVk::createProgramPipeline(const gl::ProgramPipelineState &state)
552{
553 return new ProgramPipelineVk(state);
554}
555
Sami Väisänene45e53b2016-05-25 10:36:04 +0300556std::vector<PathImpl *> ContextVk::createPaths(GLsizei)
557{
558 return std::vector<PathImpl *>();
559}
560
Jamie Madill72106562017-03-24 14:18:50 -0400561// TODO(jmadill): Use pipeline cache.
562void ContextVk::invalidateCurrentPipeline()
563{
564 mRenderer->enqueueGarbageOrDeleteNow(*this, mCurrentPipeline);
565}
566
Jamie Madillfe548342017-06-19 11:13:24 -0400567gl::Error ContextVk::dispatchCompute(const gl::Context *context,
568 GLuint numGroupsX,
569 GLuint numGroupsY,
570 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800571{
572 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500573 return gl::InternalError();
Xinghua Cao2b396592017-03-29 15:36:04 +0800574}
575
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400576} // namespace rx