blob: 622c6a2cb28c7e86bf8940a8e47d406d7b10e11d [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);
323 commandBuffer->bindVertexBuffers(0, vertexHandles, vertexOffsets);
324 commandBuffer->draw(count, 1, first, 0);
325 commandBuffer->endRenderPass();
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500326
327 return gl::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400328}
329
Jamie Madillc564c072017-06-01 12:45:42 -0400330gl::Error ContextVk::drawArraysInstanced(const gl::Context *context,
331 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400332 GLint first,
333 GLsizei count,
334 GLsizei instanceCount)
335{
336 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500337 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400338}
339
Jamie Madillc564c072017-06-01 12:45:42 -0400340gl::Error ContextVk::drawElements(const gl::Context *context,
341 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400342 GLsizei count,
343 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800344 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400345{
346 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500347 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400348}
349
Jamie Madillc564c072017-06-01 12:45:42 -0400350gl::Error ContextVk::drawElementsInstanced(const gl::Context *context,
351 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400352 GLsizei count,
353 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400354 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800355 GLsizei instances)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400356{
357 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500358 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400359}
360
Jamie Madillc564c072017-06-01 12:45:42 -0400361gl::Error ContextVk::drawRangeElements(const gl::Context *context,
362 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400363 GLuint start,
364 GLuint end,
365 GLsizei count,
366 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800367 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400368{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500369 return gl::NoError();
370}
371
372VkDevice ContextVk::getDevice() const
373{
374 return mRenderer->getDevice();
375}
376
Jamie Madill0c0dc342017-03-24 14:18:51 -0400377vk::Error ContextVk::getStartedCommandBuffer(vk::CommandBuffer **commandBufferOut)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500378{
Jamie Madill0c0dc342017-03-24 14:18:51 -0400379 return mRenderer->getStartedCommandBuffer(commandBufferOut);
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500380}
381
Jamie Madill0c0dc342017-03-24 14:18:51 -0400382vk::Error ContextVk::submitCommands(vk::CommandBuffer *commandBuffer)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500383{
Jamie Madill72106562017-03-24 14:18:50 -0400384 setQueueSerial(mRenderer->getCurrentQueueSerial());
Jamie Madillf651c772017-02-21 15:03:51 -0500385 ANGLE_TRY(mRenderer->submitCommandBuffer(commandBuffer));
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500386 return vk::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400387}
388
Jamie Madillc564c072017-06-01 12:45:42 -0400389gl::Error ContextVk::drawArraysIndirect(const gl::Context *context,
390 GLenum mode,
391 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800392{
393 UNIMPLEMENTED();
394 return gl::InternalError() << "DrawArraysIndirect hasn't been implemented for vulkan backend.";
395}
396
Jamie Madillc564c072017-06-01 12:45:42 -0400397gl::Error ContextVk::drawElementsIndirect(const gl::Context *context,
398 GLenum mode,
399 GLenum type,
400 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800401{
402 UNIMPLEMENTED();
403 return gl::InternalError()
404 << "DrawElementsIndirect hasn't been implemented for vulkan backend.";
405}
406
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400407GLenum ContextVk::getResetStatus()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400408{
409 UNIMPLEMENTED();
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400410 return GL_NO_ERROR;
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400411}
412
413std::string ContextVk::getVendorString() const
414{
415 UNIMPLEMENTED();
416 return std::string();
417}
418
419std::string ContextVk::getRendererDescription() const
420{
Jamie Madille09bd5d2016-11-29 16:20:35 -0500421 return mRenderer->getRendererDescription();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400422}
423
424void ContextVk::insertEventMarker(GLsizei length, const char *marker)
425{
426 UNIMPLEMENTED();
427}
428
429void ContextVk::pushGroupMarker(GLsizei length, const char *marker)
430{
431 UNIMPLEMENTED();
432}
433
434void ContextVk::popGroupMarker()
435{
436 UNIMPLEMENTED();
437}
438
Jamie Madillfe548342017-06-19 11:13:24 -0400439void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400440{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500441 // TODO(jmadill): Vulkan dirty bits.
Jamie Madill72106562017-03-24 14:18:50 -0400442 if (dirtyBits.any())
443 {
444 invalidateCurrentPipeline();
445 }
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400446}
447
448GLint ContextVk::getGPUDisjoint()
449{
450 UNIMPLEMENTED();
451 return GLint();
452}
453
454GLint64 ContextVk::getTimestamp()
455{
456 UNIMPLEMENTED();
457 return GLint64();
458}
459
Jamie Madill4928b7c2017-06-20 12:57:39 -0400460void ContextVk::onMakeCurrent(const gl::Context * /*context*/)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400461{
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400462}
463
464const gl::Caps &ContextVk::getNativeCaps() const
465{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400466 return mRenderer->getNativeCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400467}
468
469const gl::TextureCapsMap &ContextVk::getNativeTextureCaps() const
470{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400471 return mRenderer->getNativeTextureCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400472}
473
474const gl::Extensions &ContextVk::getNativeExtensions() const
475{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400476 return mRenderer->getNativeExtensions();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400477}
478
479const gl::Limitations &ContextVk::getNativeLimitations() const
480{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400481 return mRenderer->getNativeLimitations();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400482}
483
484CompilerImpl *ContextVk::createCompiler()
485{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400486 return new CompilerVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400487}
488
Jamie Madillacccc6c2016-05-03 17:22:10 -0400489ShaderImpl *ContextVk::createShader(const gl::ShaderState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400490{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400491 return new ShaderVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400492}
493
Jamie Madillacccc6c2016-05-03 17:22:10 -0400494ProgramImpl *ContextVk::createProgram(const gl::ProgramState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400495{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400496 return new ProgramVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400497}
498
Jamie Madillacccc6c2016-05-03 17:22:10 -0400499FramebufferImpl *ContextVk::createFramebuffer(const gl::FramebufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400500{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500501 return FramebufferVk::CreateUserFBO(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400502}
503
504TextureImpl *ContextVk::createTexture(const gl::TextureState &state)
505{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400506 return new TextureVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400507}
508
509RenderbufferImpl *ContextVk::createRenderbuffer()
510{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400511 return new RenderbufferVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400512}
513
Jamie Madill8f775602016-11-03 16:45:34 -0400514BufferImpl *ContextVk::createBuffer(const gl::BufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400515{
Jamie Madill8f775602016-11-03 16:45:34 -0400516 return new BufferVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400517}
518
Jamie Madillacccc6c2016-05-03 17:22:10 -0400519VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400520{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400521 return new VertexArrayVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400522}
523
524QueryImpl *ContextVk::createQuery(GLenum type)
525{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400526 return new QueryVk(type);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400527}
528
529FenceNVImpl *ContextVk::createFenceNV()
530{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400531 return new FenceNVVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400532}
533
Jamie Madill70b5bb02017-08-28 13:32:37 -0400534SyncImpl *ContextVk::createSync()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400535{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400536 return new SyncVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400537}
538
Geoff Lang73bd2182016-07-15 13:01:24 -0400539TransformFeedbackImpl *ContextVk::createTransformFeedback(const gl::TransformFeedbackState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400540{
Geoff Lang73bd2182016-07-15 13:01:24 -0400541 return new TransformFeedbackVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400542}
543
Jamie Madill06ef36b2017-09-09 23:32:46 -0400544SamplerImpl *ContextVk::createSampler(const gl::SamplerState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400545{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400546 return new SamplerVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400547}
548
Yunchao Hea336b902017-08-02 16:05:21 +0800549ProgramPipelineImpl *ContextVk::createProgramPipeline(const gl::ProgramPipelineState &state)
550{
551 return new ProgramPipelineVk(state);
552}
553
Sami Väisänene45e53b2016-05-25 10:36:04 +0300554std::vector<PathImpl *> ContextVk::createPaths(GLsizei)
555{
556 return std::vector<PathImpl *>();
557}
558
Jamie Madill72106562017-03-24 14:18:50 -0400559// TODO(jmadill): Use pipeline cache.
560void ContextVk::invalidateCurrentPipeline()
561{
562 mRenderer->enqueueGarbageOrDeleteNow(*this, mCurrentPipeline);
563}
564
Jamie Madillfe548342017-06-19 11:13:24 -0400565gl::Error ContextVk::dispatchCompute(const gl::Context *context,
566 GLuint numGroupsX,
567 GLuint numGroupsY,
568 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800569{
570 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500571 return gl::InternalError();
Xinghua Cao2b396592017-03-29 15:36:04 +0800572}
573
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400574} // namespace rx