blob: f0e448a15a1ef95c12864d7dcf81eba971d8630f [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"
22#include "libANGLE/renderer/vulkan/ProgramVk.h"
23#include "libANGLE/renderer/vulkan/QueryVk.h"
24#include "libANGLE/renderer/vulkan/RenderbufferVk.h"
25#include "libANGLE/renderer/vulkan/RendererVk.h"
26#include "libANGLE/renderer/vulkan/SamplerVk.h"
27#include "libANGLE/renderer/vulkan/ShaderVk.h"
Jamie Madill70b5bb02017-08-28 13:32:37 -040028#include "libANGLE/renderer/vulkan/SyncVk.h"
Jamie Madillacccc6c2016-05-03 17:22:10 -040029#include "libANGLE/renderer/vulkan/TextureVk.h"
30#include "libANGLE/renderer/vulkan/TransformFeedbackVk.h"
31#include "libANGLE/renderer/vulkan/VertexArrayVk.h"
Jamie Madilldf68a6f2017-01-13 17:29:53 -050032#include "libANGLE/renderer/vulkan/formatutilsvk.h"
Jamie Madill9e54b5a2016-05-25 12:57:39 -040033
34namespace rx
35{
36
Jamie Madillacccc6c2016-05-03 17:22:10 -040037ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer)
Jamie Madill72106562017-03-24 14:18:50 -040038 : ContextImpl(state), mRenderer(renderer), mCurrentDrawMode(GL_NONE)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040039{
40}
41
42ContextVk::~ContextVk()
43{
Jamie Madill72106562017-03-24 14:18:50 -040044 invalidateCurrentPipeline();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040045}
46
47gl::Error ContextVk::initialize()
48{
Jamie Madille09bd5d2016-11-29 16:20:35 -050049 return gl::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040050}
51
52gl::Error ContextVk::flush()
53{
54 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -050055 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040056}
57
58gl::Error ContextVk::finish()
59{
60 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -050061 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -040062}
63
Jamie Madill4928b7c2017-06-20 12:57:39 -040064gl::Error ContextVk::initPipeline(const gl::Context *context)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040065{
Jamie Madill72106562017-03-24 14:18:50 -040066 ASSERT(!mCurrentPipeline.valid());
67
Jamie Madilldf68a6f2017-01-13 17:29:53 -050068 VkDevice device = mRenderer->getDevice();
69 const auto &state = mState.getState();
70 const auto &programGL = state.getProgram();
71 const auto &vao = state.getVertexArray();
72 const auto &attribs = vao->getVertexAttributes();
Jiawei-Shao2597fb62016-12-09 16:38:02 +080073 const auto &bindings = vao->getVertexBindings();
Jamie Madilldf68a6f2017-01-13 17:29:53 -050074 const auto &programVk = GetImplAs<ProgramVk>(programGL);
75 const auto *drawFBO = state.getDrawFramebuffer();
76 FramebufferVk *vkFBO = GetImplAs<FramebufferVk>(drawFBO);
77
78 // { vertex, fragment }
79 VkPipelineShaderStageCreateInfo shaderStages[2];
80
81 shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
82 shaderStages[0].pNext = nullptr;
83 shaderStages[0].flags = 0;
84 shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
85 shaderStages[0].module = programVk->getLinkedVertexModule().getHandle();
86 shaderStages[0].pName = "main";
87 shaderStages[0].pSpecializationInfo = nullptr;
88
89 shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
90 shaderStages[1].pNext = nullptr;
91 shaderStages[1].flags = 0;
92 shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
93 shaderStages[1].module = programVk->getLinkedFragmentModule().getHandle();
94 shaderStages[1].pName = "main";
95 shaderStages[1].pSpecializationInfo = nullptr;
96
97 // Process vertex attributes
98 // TODO(jmadill): Caching with dirty bits.
99 std::vector<VkVertexInputBindingDescription> vertexBindings;
100 std::vector<VkVertexInputAttributeDescription> vertexAttribs;
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500101
Jamie Madill6de51852017-04-12 09:53:01 -0400102 for (auto attribIndex : programGL->getActiveAttribLocationsMask())
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500103 {
Jamie Madill231c7f52017-04-26 13:45:37 -0400104 const auto &attrib = attribs[attribIndex];
Jiawei-Shao2597fb62016-12-09 16:38:02 +0800105 const auto &binding = bindings[attrib.bindingIndex];
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500106 if (attrib.enabled)
107 {
108 VkVertexInputBindingDescription bindingDesc;
109 bindingDesc.binding = static_cast<uint32_t>(vertexBindings.size());
110 bindingDesc.stride = static_cast<uint32_t>(gl::ComputeVertexAttributeTypeSize(attrib));
Martin Radevdd5f27e2017-06-07 10:17:09 +0300111 bindingDesc.inputRate = (binding.getDivisor() > 0 ? VK_VERTEX_INPUT_RATE_INSTANCE
112 : VK_VERTEX_INPUT_RATE_VERTEX);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500113
114 gl::VertexFormatType vertexFormatType = gl::GetVertexFormatType(attrib);
115
116 VkVertexInputAttributeDescription attribDesc;
117 attribDesc.binding = bindingDesc.binding;
118 attribDesc.format = vk::GetNativeVertexFormat(vertexFormatType);
119 attribDesc.location = static_cast<uint32_t>(attribIndex);
Jiawei-Shao2597fb62016-12-09 16:38:02 +0800120 attribDesc.offset =
121 static_cast<uint32_t>(ComputeVertexAttributeOffset(attrib, binding));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500122
123 vertexBindings.push_back(bindingDesc);
124 vertexAttribs.push_back(attribDesc);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500125 }
126 else
127 {
128 UNIMPLEMENTED();
129 }
130 }
131
132 // TODO(jmadill): Validate with ASSERT against physical device limits/caps?
133 VkPipelineVertexInputStateCreateInfo vertexInputState;
134 vertexInputState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
135 vertexInputState.pNext = nullptr;
136 vertexInputState.flags = 0;
137 vertexInputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertexBindings.size());
138 vertexInputState.pVertexBindingDescriptions = vertexBindings.data();
139 vertexInputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertexAttribs.size());
140 vertexInputState.pVertexAttributeDescriptions = vertexAttribs.data();
141
142 VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
143 inputAssemblyState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
144 inputAssemblyState.pNext = nullptr;
145 inputAssemblyState.flags = 0;
Jamie Madill72106562017-03-24 14:18:50 -0400146 inputAssemblyState.topology = gl_vk::GetPrimitiveTopology(mCurrentDrawMode);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500147 inputAssemblyState.primitiveRestartEnable = VK_FALSE;
148
149 const gl::Rectangle &viewportGL = state.getViewport();
150 VkViewport viewportVk;
151 viewportVk.x = static_cast<float>(viewportGL.x);
152 viewportVk.y = static_cast<float>(viewportGL.y);
153 viewportVk.width = static_cast<float>(viewportGL.width);
154 viewportVk.height = static_cast<float>(viewportGL.height);
155 viewportVk.minDepth = state.getNearPlane();
156 viewportVk.maxDepth = state.getFarPlane();
157
158 // TODO(jmadill): Scissor.
159 VkRect2D scissorVk;
160 scissorVk.offset.x = viewportGL.x;
161 scissorVk.offset.y = viewportGL.y;
162 scissorVk.extent.width = viewportGL.width;
163 scissorVk.extent.height = viewportGL.height;
164
165 VkPipelineViewportStateCreateInfo viewportState;
166 viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
167 viewportState.pNext = nullptr;
168 viewportState.flags = 0;
169 viewportState.viewportCount = 1;
170 viewportState.pViewports = &viewportVk;
171 viewportState.scissorCount = 1;
172 viewportState.pScissors = &scissorVk;
173
174 // TODO(jmadill): Extra rasterizer state features.
175 VkPipelineRasterizationStateCreateInfo rasterState;
176 rasterState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
177 rasterState.pNext = nullptr;
178 rasterState.flags = 0;
179 rasterState.depthClampEnable = VK_FALSE;
180 rasterState.rasterizerDiscardEnable = VK_FALSE;
181 rasterState.polygonMode = VK_POLYGON_MODE_FILL;
182 rasterState.cullMode = gl_vk::GetCullMode(state.getRasterizerState());
183 rasterState.frontFace = gl_vk::GetFrontFace(state.getRasterizerState().frontFace);
184 rasterState.depthBiasEnable = VK_FALSE;
185 rasterState.depthBiasConstantFactor = 0.0f;
186 rasterState.depthBiasClamp = 0.0f;
187 rasterState.depthBiasSlopeFactor = 0.0f;
188 rasterState.lineWidth = state.getLineWidth();
189
190 // TODO(jmadill): Multisample state.
191 VkPipelineMultisampleStateCreateInfo multisampleState;
192 multisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
193 multisampleState.pNext = nullptr;
194 multisampleState.flags = 0;
Jamie Madill72106562017-03-24 14:18:50 -0400195 multisampleState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
196 multisampleState.sampleShadingEnable = VK_FALSE;
197 multisampleState.minSampleShading = 0.0f;
198 multisampleState.pSampleMask = nullptr;
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500199 multisampleState.alphaToCoverageEnable = VK_FALSE;
200 multisampleState.alphaToOneEnable = VK_FALSE;
201
202 // TODO(jmadill): Depth/stencil state.
203
204 // TODO(jmadill): Blend state/MRT.
205 VkPipelineColorBlendAttachmentState blendAttachmentState;
206 blendAttachmentState.blendEnable = VK_FALSE;
207 blendAttachmentState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
208 blendAttachmentState.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
209 blendAttachmentState.colorBlendOp = VK_BLEND_OP_ADD;
210 blendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
211 blendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
212 blendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
213 blendAttachmentState.colorWriteMask = (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
214 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT);
215
216 VkPipelineColorBlendStateCreateInfo blendState;
217 blendState.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
218 blendState.pNext = 0;
219 blendState.flags = 0;
220 blendState.logicOpEnable = VK_FALSE;
221 blendState.logicOp = VK_LOGIC_OP_CLEAR;
222 blendState.attachmentCount = 1;
223 blendState.pAttachments = &blendAttachmentState;
224 blendState.blendConstants[0] = 0.0f;
225 blendState.blendConstants[1] = 0.0f;
226 blendState.blendConstants[2] = 0.0f;
227 blendState.blendConstants[3] = 0.0f;
228
229 // TODO(jmadill): Dynamic state.
230 vk::RenderPass *renderPass = nullptr;
Jamie Madill4928b7c2017-06-20 12:57:39 -0400231 ANGLE_TRY_RESULT(vkFBO->getRenderPass(context, device), renderPass);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500232 ASSERT(renderPass && renderPass->valid());
233
234 vk::PipelineLayout *pipelineLayout = nullptr;
235 ANGLE_TRY_RESULT(programVk->getPipelineLayout(device), pipelineLayout);
236 ASSERT(pipelineLayout && pipelineLayout->valid());
237
238 VkGraphicsPipelineCreateInfo pipelineInfo;
239 pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
240 pipelineInfo.pNext = nullptr;
241 pipelineInfo.flags = 0;
242 pipelineInfo.stageCount = 2;
243 pipelineInfo.pStages = shaderStages;
244 pipelineInfo.pVertexInputState = &vertexInputState;
245 pipelineInfo.pInputAssemblyState = &inputAssemblyState;
246 pipelineInfo.pTessellationState = nullptr;
247 pipelineInfo.pViewportState = &viewportState;
248 pipelineInfo.pRasterizationState = &rasterState;
249 pipelineInfo.pMultisampleState = &multisampleState;
250 pipelineInfo.pDepthStencilState = nullptr;
251 pipelineInfo.pColorBlendState = &blendState;
252 pipelineInfo.pDynamicState = nullptr;
253 pipelineInfo.layout = pipelineLayout->getHandle();
254 pipelineInfo.renderPass = renderPass->getHandle();
255 pipelineInfo.subpass = 0;
256 pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
257 pipelineInfo.basePipelineIndex = 0;
258
Jamie Madill5deea722017-02-16 10:44:46 -0500259 vk::Pipeline newPipeline;
260 ANGLE_TRY(newPipeline.initGraphics(device, pipelineInfo));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500261
Jamie Madill5deea722017-02-16 10:44:46 -0500262 mCurrentPipeline.retain(device, std::move(newPipeline));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500263
Jamie Madill72106562017-03-24 14:18:50 -0400264 return gl::NoError();
265}
266
Jamie Madillc564c072017-06-01 12:45:42 -0400267gl::Error ContextVk::drawArrays(const gl::Context *context, GLenum mode, GLint first, GLsizei count)
Jamie Madill72106562017-03-24 14:18:50 -0400268{
269 if (mode != mCurrentDrawMode)
270 {
271 invalidateCurrentPipeline();
272 mCurrentDrawMode = mode;
273 }
274
275 if (!mCurrentPipeline.valid())
276 {
Jamie Madill4928b7c2017-06-20 12:57:39 -0400277 ANGLE_TRY(initPipeline(context));
Jamie Madill72106562017-03-24 14:18:50 -0400278 ASSERT(mCurrentPipeline.valid());
279 }
280
281 VkDevice device = mRenderer->getDevice();
282 const auto &state = mState.getState();
283 const auto &programGL = state.getProgram();
284 const auto &vao = state.getVertexArray();
285 const auto &attribs = vao->getVertexAttributes();
286 const auto &bindings = vao->getVertexBindings();
287 const auto *drawFBO = state.getDrawFramebuffer();
288 FramebufferVk *vkFBO = GetImplAs<FramebufferVk>(drawFBO);
289 Serial queueSerial = mRenderer->getCurrentQueueSerial();
290
291 // Process vertex attributes
292 // TODO(jmadill): Caching with dirty bits.
293 std::vector<VkBuffer> vertexHandles;
294 std::vector<VkDeviceSize> vertexOffsets;
295
Jamie Madill6de51852017-04-12 09:53:01 -0400296 for (auto attribIndex : programGL->getActiveAttribLocationsMask())
Jamie Madill72106562017-03-24 14:18:50 -0400297 {
298 const auto &attrib = attribs[attribIndex];
299 const auto &binding = bindings[attrib.bindingIndex];
300 if (attrib.enabled)
301 {
302 // TODO(jmadill): Offset handling.
Martin Radevdd5f27e2017-06-07 10:17:09 +0300303 gl::Buffer *bufferGL = binding.getBuffer().get();
Jamie Madill72106562017-03-24 14:18:50 -0400304 ASSERT(bufferGL);
305 BufferVk *bufferVk = GetImplAs<BufferVk>(bufferGL);
306 vertexHandles.push_back(bufferVk->getVkBuffer().getHandle());
307 vertexOffsets.push_back(0);
308
309 bufferVk->setQueueSerial(queueSerial);
310 }
311 else
312 {
313 UNIMPLEMENTED();
314 }
315 }
316
Jamie Madill0c0dc342017-03-24 14:18:51 -0400317 vk::CommandBuffer *commandBuffer = nullptr;
318 ANGLE_TRY(mRenderer->getStartedCommandBuffer(&commandBuffer));
Jamie Madill4928b7c2017-06-20 12:57:39 -0400319 ANGLE_TRY(vkFBO->beginRenderPass(context, device, commandBuffer, queueSerial, state));
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500320
321 commandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, mCurrentPipeline);
322 commandBuffer->bindVertexBuffers(0, vertexHandles, vertexOffsets);
323 commandBuffer->draw(count, 1, first, 0);
324 commandBuffer->endRenderPass();
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500325
326 return gl::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400327}
328
Jamie Madillc564c072017-06-01 12:45:42 -0400329gl::Error ContextVk::drawArraysInstanced(const gl::Context *context,
330 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400331 GLint first,
332 GLsizei count,
333 GLsizei instanceCount)
334{
335 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500336 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400337}
338
Jamie Madillc564c072017-06-01 12:45:42 -0400339gl::Error ContextVk::drawElements(const gl::Context *context,
340 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400341 GLsizei count,
342 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800343 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400344{
345 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500346 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400347}
348
Jamie Madillc564c072017-06-01 12:45:42 -0400349gl::Error ContextVk::drawElementsInstanced(const gl::Context *context,
350 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400351 GLsizei count,
352 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400353 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800354 GLsizei instances)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400355{
356 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500357 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400358}
359
Jamie Madillc564c072017-06-01 12:45:42 -0400360gl::Error ContextVk::drawRangeElements(const gl::Context *context,
361 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400362 GLuint start,
363 GLuint end,
364 GLsizei count,
365 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800366 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400367{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500368 return gl::NoError();
369}
370
371VkDevice ContextVk::getDevice() const
372{
373 return mRenderer->getDevice();
374}
375
Jamie Madill0c0dc342017-03-24 14:18:51 -0400376vk::Error ContextVk::getStartedCommandBuffer(vk::CommandBuffer **commandBufferOut)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500377{
Jamie Madill0c0dc342017-03-24 14:18:51 -0400378 return mRenderer->getStartedCommandBuffer(commandBufferOut);
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500379}
380
Jamie Madill0c0dc342017-03-24 14:18:51 -0400381vk::Error ContextVk::submitCommands(vk::CommandBuffer *commandBuffer)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500382{
Jamie Madill72106562017-03-24 14:18:50 -0400383 setQueueSerial(mRenderer->getCurrentQueueSerial());
Jamie Madillf651c772017-02-21 15:03:51 -0500384 ANGLE_TRY(mRenderer->submitCommandBuffer(commandBuffer));
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500385 return vk::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400386}
387
Jamie Madillc564c072017-06-01 12:45:42 -0400388gl::Error ContextVk::drawArraysIndirect(const gl::Context *context,
389 GLenum mode,
390 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800391{
392 UNIMPLEMENTED();
393 return gl::InternalError() << "DrawArraysIndirect hasn't been implemented for vulkan backend.";
394}
395
Jamie Madillc564c072017-06-01 12:45:42 -0400396gl::Error ContextVk::drawElementsIndirect(const gl::Context *context,
397 GLenum mode,
398 GLenum type,
399 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800400{
401 UNIMPLEMENTED();
402 return gl::InternalError()
403 << "DrawElementsIndirect hasn't been implemented for vulkan backend.";
404}
405
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400406GLenum ContextVk::getResetStatus()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400407{
408 UNIMPLEMENTED();
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400409 return GL_NO_ERROR;
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400410}
411
412std::string ContextVk::getVendorString() const
413{
414 UNIMPLEMENTED();
415 return std::string();
416}
417
418std::string ContextVk::getRendererDescription() const
419{
Jamie Madille09bd5d2016-11-29 16:20:35 -0500420 return mRenderer->getRendererDescription();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400421}
422
423void ContextVk::insertEventMarker(GLsizei length, const char *marker)
424{
425 UNIMPLEMENTED();
426}
427
428void ContextVk::pushGroupMarker(GLsizei length, const char *marker)
429{
430 UNIMPLEMENTED();
431}
432
433void ContextVk::popGroupMarker()
434{
435 UNIMPLEMENTED();
436}
437
Jamie Madillfe548342017-06-19 11:13:24 -0400438void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400439{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500440 // TODO(jmadill): Vulkan dirty bits.
Jamie Madill72106562017-03-24 14:18:50 -0400441 if (dirtyBits.any())
442 {
443 invalidateCurrentPipeline();
444 }
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400445}
446
447GLint ContextVk::getGPUDisjoint()
448{
449 UNIMPLEMENTED();
450 return GLint();
451}
452
453GLint64 ContextVk::getTimestamp()
454{
455 UNIMPLEMENTED();
456 return GLint64();
457}
458
Jamie Madill4928b7c2017-06-20 12:57:39 -0400459void ContextVk::onMakeCurrent(const gl::Context * /*context*/)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400460{
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400461}
462
463const gl::Caps &ContextVk::getNativeCaps() const
464{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400465 return mRenderer->getNativeCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400466}
467
468const gl::TextureCapsMap &ContextVk::getNativeTextureCaps() const
469{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400470 return mRenderer->getNativeTextureCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400471}
472
473const gl::Extensions &ContextVk::getNativeExtensions() const
474{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400475 return mRenderer->getNativeExtensions();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400476}
477
478const gl::Limitations &ContextVk::getNativeLimitations() const
479{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400480 return mRenderer->getNativeLimitations();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400481}
482
483CompilerImpl *ContextVk::createCompiler()
484{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400485 return new CompilerVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400486}
487
Jamie Madillacccc6c2016-05-03 17:22:10 -0400488ShaderImpl *ContextVk::createShader(const gl::ShaderState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400489{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400490 return new ShaderVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400491}
492
Jamie Madillacccc6c2016-05-03 17:22:10 -0400493ProgramImpl *ContextVk::createProgram(const gl::ProgramState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400494{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400495 return new ProgramVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400496}
497
Jamie Madillacccc6c2016-05-03 17:22:10 -0400498FramebufferImpl *ContextVk::createFramebuffer(const gl::FramebufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400499{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500500 return FramebufferVk::CreateUserFBO(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400501}
502
503TextureImpl *ContextVk::createTexture(const gl::TextureState &state)
504{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400505 return new TextureVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400506}
507
508RenderbufferImpl *ContextVk::createRenderbuffer()
509{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400510 return new RenderbufferVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400511}
512
Jamie Madill8f775602016-11-03 16:45:34 -0400513BufferImpl *ContextVk::createBuffer(const gl::BufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400514{
Jamie Madill8f775602016-11-03 16:45:34 -0400515 return new BufferVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400516}
517
Jamie Madillacccc6c2016-05-03 17:22:10 -0400518VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400519{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400520 return new VertexArrayVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400521}
522
523QueryImpl *ContextVk::createQuery(GLenum type)
524{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400525 return new QueryVk(type);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400526}
527
528FenceNVImpl *ContextVk::createFenceNV()
529{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400530 return new FenceNVVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400531}
532
Jamie Madill70b5bb02017-08-28 13:32:37 -0400533SyncImpl *ContextVk::createSync()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400534{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400535 return new SyncVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400536}
537
Geoff Lang73bd2182016-07-15 13:01:24 -0400538TransformFeedbackImpl *ContextVk::createTransformFeedback(const gl::TransformFeedbackState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400539{
Geoff Lang73bd2182016-07-15 13:01:24 -0400540 return new TransformFeedbackVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400541}
542
543SamplerImpl *ContextVk::createSampler()
544{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400545 return new SamplerVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400546}
547
Sami Väisänene45e53b2016-05-25 10:36:04 +0300548std::vector<PathImpl *> ContextVk::createPaths(GLsizei)
549{
550 return std::vector<PathImpl *>();
551}
552
Jamie Madill72106562017-03-24 14:18:50 -0400553// TODO(jmadill): Use pipeline cache.
554void ContextVk::invalidateCurrentPipeline()
555{
556 mRenderer->enqueueGarbageOrDeleteNow(*this, mCurrentPipeline);
557}
558
Jamie Madillfe548342017-06-19 11:13:24 -0400559gl::Error ContextVk::dispatchCompute(const gl::Context *context,
560 GLuint numGroupsX,
561 GLuint numGroupsY,
562 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800563{
564 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500565 return gl::InternalError();
Xinghua Cao2b396592017-03-29 15:36:04 +0800566}
567
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400568} // namespace rx