blob: c87704d774d3c5e7162942ea01e7c6275f0af76e [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 Madilld4826152017-09-21 11:18:59 -0400320 ANGLE_TRY(vkFBO->ensureInRenderPass(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);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500327
328 return gl::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400329}
330
Jamie Madillc564c072017-06-01 12:45:42 -0400331gl::Error ContextVk::drawArraysInstanced(const gl::Context *context,
332 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400333 GLint first,
334 GLsizei count,
335 GLsizei instanceCount)
336{
337 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500338 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400339}
340
Jamie Madillc564c072017-06-01 12:45:42 -0400341gl::Error ContextVk::drawElements(const gl::Context *context,
342 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400343 GLsizei count,
344 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800345 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400346{
347 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500348 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400349}
350
Jamie Madillc564c072017-06-01 12:45:42 -0400351gl::Error ContextVk::drawElementsInstanced(const gl::Context *context,
352 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400353 GLsizei count,
354 GLenum type,
Jamie Madill876429b2017-04-20 15:46:24 -0400355 const void *indices,
Qin Jiajia1da00652017-06-20 17:16:25 +0800356 GLsizei instances)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400357{
358 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500359 return gl::InternalError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400360}
361
Jamie Madillc564c072017-06-01 12:45:42 -0400362gl::Error ContextVk::drawRangeElements(const gl::Context *context,
363 GLenum mode,
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400364 GLuint start,
365 GLuint end,
366 GLsizei count,
367 GLenum type,
Qin Jiajia1da00652017-06-20 17:16:25 +0800368 const void *indices)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400369{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500370 return gl::NoError();
371}
372
373VkDevice ContextVk::getDevice() const
374{
375 return mRenderer->getDevice();
376}
377
Jamie Madill0c0dc342017-03-24 14:18:51 -0400378vk::Error ContextVk::getStartedCommandBuffer(vk::CommandBuffer **commandBufferOut)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500379{
Jamie Madill0c0dc342017-03-24 14:18:51 -0400380 return mRenderer->getStartedCommandBuffer(commandBufferOut);
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500381}
382
Jamie Madill0c0dc342017-03-24 14:18:51 -0400383vk::Error ContextVk::submitCommands(vk::CommandBuffer *commandBuffer)
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500384{
Jamie Madill72106562017-03-24 14:18:50 -0400385 setQueueSerial(mRenderer->getCurrentQueueSerial());
Jamie Madillf651c772017-02-21 15:03:51 -0500386 ANGLE_TRY(mRenderer->submitCommandBuffer(commandBuffer));
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500387 return vk::NoError();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400388}
389
Jamie Madillc564c072017-06-01 12:45:42 -0400390gl::Error ContextVk::drawArraysIndirect(const gl::Context *context,
391 GLenum mode,
392 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800393{
394 UNIMPLEMENTED();
395 return gl::InternalError() << "DrawArraysIndirect hasn't been implemented for vulkan backend.";
396}
397
Jamie Madillc564c072017-06-01 12:45:42 -0400398gl::Error ContextVk::drawElementsIndirect(const gl::Context *context,
399 GLenum mode,
400 GLenum type,
401 const void *indirect)
Jiajia Qind9671222016-11-29 16:30:31 +0800402{
403 UNIMPLEMENTED();
404 return gl::InternalError()
405 << "DrawElementsIndirect hasn't been implemented for vulkan backend.";
406}
407
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400408GLenum ContextVk::getResetStatus()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400409{
410 UNIMPLEMENTED();
Corentin Wallez87fbe1c2016-08-03 14:41:42 -0400411 return GL_NO_ERROR;
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400412}
413
414std::string ContextVk::getVendorString() const
415{
416 UNIMPLEMENTED();
417 return std::string();
418}
419
420std::string ContextVk::getRendererDescription() const
421{
Jamie Madille09bd5d2016-11-29 16:20:35 -0500422 return mRenderer->getRendererDescription();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400423}
424
425void ContextVk::insertEventMarker(GLsizei length, const char *marker)
426{
427 UNIMPLEMENTED();
428}
429
430void ContextVk::pushGroupMarker(GLsizei length, const char *marker)
431{
432 UNIMPLEMENTED();
433}
434
435void ContextVk::popGroupMarker()
436{
437 UNIMPLEMENTED();
438}
439
Jamie Madillfe548342017-06-19 11:13:24 -0400440void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400441{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500442 // TODO(jmadill): Vulkan dirty bits.
Jamie Madill72106562017-03-24 14:18:50 -0400443 if (dirtyBits.any())
444 {
445 invalidateCurrentPipeline();
446 }
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400447}
448
449GLint ContextVk::getGPUDisjoint()
450{
451 UNIMPLEMENTED();
452 return GLint();
453}
454
455GLint64 ContextVk::getTimestamp()
456{
457 UNIMPLEMENTED();
458 return GLint64();
459}
460
Jamie Madill4928b7c2017-06-20 12:57:39 -0400461void ContextVk::onMakeCurrent(const gl::Context * /*context*/)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400462{
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400463}
464
465const gl::Caps &ContextVk::getNativeCaps() const
466{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400467 return mRenderer->getNativeCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400468}
469
470const gl::TextureCapsMap &ContextVk::getNativeTextureCaps() const
471{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400472 return mRenderer->getNativeTextureCaps();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400473}
474
475const gl::Extensions &ContextVk::getNativeExtensions() const
476{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400477 return mRenderer->getNativeExtensions();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400478}
479
480const gl::Limitations &ContextVk::getNativeLimitations() const
481{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400482 return mRenderer->getNativeLimitations();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400483}
484
485CompilerImpl *ContextVk::createCompiler()
486{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400487 return new CompilerVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400488}
489
Jamie Madillacccc6c2016-05-03 17:22:10 -0400490ShaderImpl *ContextVk::createShader(const gl::ShaderState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400491{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400492 return new ShaderVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400493}
494
Jamie Madillacccc6c2016-05-03 17:22:10 -0400495ProgramImpl *ContextVk::createProgram(const gl::ProgramState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400496{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400497 return new ProgramVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400498}
499
Jamie Madillacccc6c2016-05-03 17:22:10 -0400500FramebufferImpl *ContextVk::createFramebuffer(const gl::FramebufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400501{
Jamie Madill7b57b9d2017-01-13 09:33:38 -0500502 return FramebufferVk::CreateUserFBO(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400503}
504
505TextureImpl *ContextVk::createTexture(const gl::TextureState &state)
506{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400507 return new TextureVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400508}
509
510RenderbufferImpl *ContextVk::createRenderbuffer()
511{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400512 return new RenderbufferVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400513}
514
Jamie Madill8f775602016-11-03 16:45:34 -0400515BufferImpl *ContextVk::createBuffer(const gl::BufferState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400516{
Jamie Madill8f775602016-11-03 16:45:34 -0400517 return new BufferVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400518}
519
Jamie Madillacccc6c2016-05-03 17:22:10 -0400520VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400521{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400522 return new VertexArrayVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400523}
524
525QueryImpl *ContextVk::createQuery(GLenum type)
526{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400527 return new QueryVk(type);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400528}
529
530FenceNVImpl *ContextVk::createFenceNV()
531{
Jamie Madillacccc6c2016-05-03 17:22:10 -0400532 return new FenceNVVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400533}
534
Jamie Madill70b5bb02017-08-28 13:32:37 -0400535SyncImpl *ContextVk::createSync()
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400536{
Jamie Madill70b5bb02017-08-28 13:32:37 -0400537 return new SyncVk();
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400538}
539
Geoff Lang73bd2182016-07-15 13:01:24 -0400540TransformFeedbackImpl *ContextVk::createTransformFeedback(const gl::TransformFeedbackState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400541{
Geoff Lang73bd2182016-07-15 13:01:24 -0400542 return new TransformFeedbackVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400543}
544
Jamie Madill06ef36b2017-09-09 23:32:46 -0400545SamplerImpl *ContextVk::createSampler(const gl::SamplerState &state)
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400546{
Jamie Madill06ef36b2017-09-09 23:32:46 -0400547 return new SamplerVk(state);
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400548}
549
Yunchao Hea336b902017-08-02 16:05:21 +0800550ProgramPipelineImpl *ContextVk::createProgramPipeline(const gl::ProgramPipelineState &state)
551{
552 return new ProgramPipelineVk(state);
553}
554
Sami Väisänene45e53b2016-05-25 10:36:04 +0300555std::vector<PathImpl *> ContextVk::createPaths(GLsizei)
556{
557 return std::vector<PathImpl *>();
558}
559
Jamie Madill72106562017-03-24 14:18:50 -0400560// TODO(jmadill): Use pipeline cache.
561void ContextVk::invalidateCurrentPipeline()
562{
563 mRenderer->enqueueGarbageOrDeleteNow(*this, mCurrentPipeline);
564}
565
Jamie Madillfe548342017-06-19 11:13:24 -0400566gl::Error ContextVk::dispatchCompute(const gl::Context *context,
567 GLuint numGroupsX,
568 GLuint numGroupsY,
569 GLuint numGroupsZ)
Xinghua Cao2b396592017-03-29 15:36:04 +0800570{
571 UNIMPLEMENTED();
Yuly Novikovc4d18aa2017-03-09 18:45:02 -0500572 return gl::InternalError();
Xinghua Cao2b396592017-03-29 15:36:04 +0800573}
574
Jamie Madill9e54b5a2016-05-25 12:57:39 -0400575} // namespace rx