Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 1 | // |
| 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 Madill | 20e005b | 2017-04-07 14:19:22 -0400 | [diff] [blame^] | 12 | #include "common/bitset_utils.h" |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 13 | #include "common/debug.h" |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 14 | #include "libANGLE/Program.h" |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 15 | #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" |
| 20 | #include "libANGLE/renderer/vulkan/FenceSyncVk.h" |
| 21 | #include "libANGLE/renderer/vulkan/FramebufferVk.h" |
| 22 | #include "libANGLE/renderer/vulkan/ImageVk.h" |
| 23 | #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" |
| 29 | #include "libANGLE/renderer/vulkan/TextureVk.h" |
| 30 | #include "libANGLE/renderer/vulkan/TransformFeedbackVk.h" |
| 31 | #include "libANGLE/renderer/vulkan/VertexArrayVk.h" |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 32 | #include "libANGLE/renderer/vulkan/formatutilsvk.h" |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 33 | |
| 34 | namespace rx |
| 35 | { |
| 36 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 37 | ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer) |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 38 | : ContextImpl(state), mRenderer(renderer), mCurrentDrawMode(GL_NONE) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 39 | { |
| 40 | } |
| 41 | |
| 42 | ContextVk::~ContextVk() |
| 43 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 44 | invalidateCurrentPipeline(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | gl::Error ContextVk::initialize() |
| 48 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 49 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | gl::Error ContextVk::flush() |
| 53 | { |
| 54 | UNIMPLEMENTED(); |
| 55 | return gl::Error(GL_INVALID_OPERATION); |
| 56 | } |
| 57 | |
| 58 | gl::Error ContextVk::finish() |
| 59 | { |
| 60 | UNIMPLEMENTED(); |
| 61 | return gl::Error(GL_INVALID_OPERATION); |
| 62 | } |
| 63 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 64 | gl::Error ContextVk::initPipeline() |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 65 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 66 | ASSERT(!mCurrentPipeline.valid()); |
| 67 | |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 68 | 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-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 73 | const auto &bindings = vao->getVertexBindings(); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 74 | 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 Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 101 | |
| 102 | for (auto attribIndex : angle::IterateBitSet(programGL->getActiveAttribLocationsMask())) |
| 103 | { |
| 104 | const auto &attrib = attribs[attribIndex]; |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 105 | const auto &binding = bindings[attrib.bindingIndex]; |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 106 | 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)); |
| 111 | bindingDesc.inputRate = |
Jiawei-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 112 | (binding.divisor > 0 ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 113 | |
| 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-Shao | 2597fb6 | 2016-12-09 16:38:02 +0800 | [diff] [blame] | 120 | attribDesc.offset = |
| 121 | static_cast<uint32_t>(ComputeVertexAttributeOffset(attrib, binding)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 122 | |
| 123 | vertexBindings.push_back(bindingDesc); |
| 124 | vertexAttribs.push_back(attribDesc); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 125 | } |
| 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 Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 146 | inputAssemblyState.topology = gl_vk::GetPrimitiveTopology(mCurrentDrawMode); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 147 | 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 Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 195 | multisampleState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 196 | multisampleState.sampleShadingEnable = VK_FALSE; |
| 197 | multisampleState.minSampleShading = 0.0f; |
| 198 | multisampleState.pSampleMask = nullptr; |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 199 | 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; |
| 231 | ANGLE_TRY_RESULT(vkFBO->getRenderPass(device), renderPass); |
| 232 | 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 Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 259 | vk::Pipeline newPipeline; |
| 260 | ANGLE_TRY(newPipeline.initGraphics(device, pipelineInfo)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 261 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 262 | mCurrentPipeline.retain(device, std::move(newPipeline)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 263 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 264 | return gl::NoError(); |
| 265 | } |
| 266 | |
| 267 | gl::Error ContextVk::drawArrays(GLenum mode, GLint first, GLsizei count) |
| 268 | { |
| 269 | if (mode != mCurrentDrawMode) |
| 270 | { |
| 271 | invalidateCurrentPipeline(); |
| 272 | mCurrentDrawMode = mode; |
| 273 | } |
| 274 | |
| 275 | if (!mCurrentPipeline.valid()) |
| 276 | { |
| 277 | ANGLE_TRY(initPipeline()); |
| 278 | 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 | |
| 296 | for (auto attribIndex : angle::IterateBitSet(programGL->getActiveAttribLocationsMask())) |
| 297 | { |
| 298 | const auto &attrib = attribs[attribIndex]; |
| 299 | const auto &binding = bindings[attrib.bindingIndex]; |
| 300 | if (attrib.enabled) |
| 301 | { |
| 302 | // TODO(jmadill): Offset handling. |
| 303 | gl::Buffer *bufferGL = binding.buffer.get(); |
| 304 | 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 Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 317 | vk::CommandBuffer *commandBuffer = mRenderer->getCommandBuffer(); |
Jamie Madill | 4c26fc2 | 2017-02-24 11:04:10 -0500 | [diff] [blame] | 318 | ANGLE_TRY(vkFBO->beginRenderPass(device, commandBuffer, queueSerial, state)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 319 | |
| 320 | commandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, mCurrentPipeline); |
| 321 | commandBuffer->bindVertexBuffers(0, vertexHandles, vertexOffsets); |
| 322 | commandBuffer->draw(count, 1, first, 0); |
| 323 | commandBuffer->endRenderPass(); |
| 324 | ANGLE_TRY(commandBuffer->end()); |
| 325 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 326 | ANGLE_TRY(submitCommands(*commandBuffer)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 327 | |
| 328 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | gl::Error ContextVk::drawArraysInstanced(GLenum mode, |
| 332 | GLint first, |
| 333 | GLsizei count, |
| 334 | GLsizei instanceCount) |
| 335 | { |
| 336 | UNIMPLEMENTED(); |
| 337 | return gl::Error(GL_INVALID_OPERATION); |
| 338 | } |
| 339 | |
| 340 | gl::Error ContextVk::drawElements(GLenum mode, |
| 341 | GLsizei count, |
| 342 | GLenum type, |
| 343 | const GLvoid *indices, |
| 344 | const gl::IndexRange &indexRange) |
| 345 | { |
| 346 | UNIMPLEMENTED(); |
| 347 | return gl::Error(GL_INVALID_OPERATION); |
| 348 | } |
| 349 | |
| 350 | gl::Error ContextVk::drawElementsInstanced(GLenum mode, |
| 351 | GLsizei count, |
| 352 | GLenum type, |
| 353 | const GLvoid *indices, |
| 354 | GLsizei instances, |
| 355 | const gl::IndexRange &indexRange) |
| 356 | { |
| 357 | UNIMPLEMENTED(); |
| 358 | return gl::Error(GL_INVALID_OPERATION); |
| 359 | } |
| 360 | |
| 361 | gl::Error ContextVk::drawRangeElements(GLenum mode, |
| 362 | GLuint start, |
| 363 | GLuint end, |
| 364 | GLsizei count, |
| 365 | GLenum type, |
| 366 | const GLvoid *indices, |
| 367 | const gl::IndexRange &indexRange) |
| 368 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 369 | return gl::NoError(); |
| 370 | } |
| 371 | |
| 372 | VkDevice ContextVk::getDevice() const |
| 373 | { |
| 374 | return mRenderer->getDevice(); |
| 375 | } |
| 376 | |
| 377 | vk::CommandBuffer *ContextVk::getCommandBuffer() |
| 378 | { |
| 379 | return mRenderer->getCommandBuffer(); |
| 380 | } |
| 381 | |
| 382 | vk::Error ContextVk::submitCommands(const vk::CommandBuffer &commandBuffer) |
| 383 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 384 | setQueueSerial(mRenderer->getCurrentQueueSerial()); |
Jamie Madill | f651c77 | 2017-02-21 15:03:51 -0500 | [diff] [blame] | 385 | ANGLE_TRY(mRenderer->submitCommandBuffer(commandBuffer)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 386 | return vk::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 387 | } |
| 388 | |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 389 | gl::Error ContextVk::drawArraysIndirect(GLenum mode, const GLvoid *indirect) |
| 390 | { |
| 391 | UNIMPLEMENTED(); |
| 392 | return gl::InternalError() << "DrawArraysIndirect hasn't been implemented for vulkan backend."; |
| 393 | } |
| 394 | |
| 395 | gl::Error ContextVk::drawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect) |
| 396 | { |
| 397 | UNIMPLEMENTED(); |
| 398 | return gl::InternalError() |
| 399 | << "DrawElementsIndirect hasn't been implemented for vulkan backend."; |
| 400 | } |
| 401 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 402 | GLenum ContextVk::getResetStatus() |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 403 | { |
| 404 | UNIMPLEMENTED(); |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 405 | return GL_NO_ERROR; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | std::string ContextVk::getVendorString() const |
| 409 | { |
| 410 | UNIMPLEMENTED(); |
| 411 | return std::string(); |
| 412 | } |
| 413 | |
| 414 | std::string ContextVk::getRendererDescription() const |
| 415 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 416 | return mRenderer->getRendererDescription(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | void ContextVk::insertEventMarker(GLsizei length, const char *marker) |
| 420 | { |
| 421 | UNIMPLEMENTED(); |
| 422 | } |
| 423 | |
| 424 | void ContextVk::pushGroupMarker(GLsizei length, const char *marker) |
| 425 | { |
| 426 | UNIMPLEMENTED(); |
| 427 | } |
| 428 | |
| 429 | void ContextVk::popGroupMarker() |
| 430 | { |
| 431 | UNIMPLEMENTED(); |
| 432 | } |
| 433 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 434 | void ContextVk::syncState(const gl::State::DirtyBits &dirtyBits) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 435 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 436 | // TODO(jmadill): Vulkan dirty bits. |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 437 | if (dirtyBits.any()) |
| 438 | { |
| 439 | invalidateCurrentPipeline(); |
| 440 | } |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | GLint ContextVk::getGPUDisjoint() |
| 444 | { |
| 445 | UNIMPLEMENTED(); |
| 446 | return GLint(); |
| 447 | } |
| 448 | |
| 449 | GLint64 ContextVk::getTimestamp() |
| 450 | { |
| 451 | UNIMPLEMENTED(); |
| 452 | return GLint64(); |
| 453 | } |
| 454 | |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 455 | void ContextVk::onMakeCurrent(const gl::ContextState & /*data*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 456 | { |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | const gl::Caps &ContextVk::getNativeCaps() const |
| 460 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 461 | return mRenderer->getNativeCaps(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | const gl::TextureCapsMap &ContextVk::getNativeTextureCaps() const |
| 465 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 466 | return mRenderer->getNativeTextureCaps(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | const gl::Extensions &ContextVk::getNativeExtensions() const |
| 470 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 471 | return mRenderer->getNativeExtensions(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | const gl::Limitations &ContextVk::getNativeLimitations() const |
| 475 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 476 | return mRenderer->getNativeLimitations(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | CompilerImpl *ContextVk::createCompiler() |
| 480 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 481 | return new CompilerVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 482 | } |
| 483 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 484 | ShaderImpl *ContextVk::createShader(const gl::ShaderState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 485 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 486 | return new ShaderVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 487 | } |
| 488 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 489 | ProgramImpl *ContextVk::createProgram(const gl::ProgramState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 490 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 491 | return new ProgramVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 492 | } |
| 493 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 494 | FramebufferImpl *ContextVk::createFramebuffer(const gl::FramebufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 495 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 496 | return FramebufferVk::CreateUserFBO(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | TextureImpl *ContextVk::createTexture(const gl::TextureState &state) |
| 500 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 501 | return new TextureVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | RenderbufferImpl *ContextVk::createRenderbuffer() |
| 505 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 506 | return new RenderbufferVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 507 | } |
| 508 | |
Jamie Madill | 8f77560 | 2016-11-03 16:45:34 -0400 | [diff] [blame] | 509 | BufferImpl *ContextVk::createBuffer(const gl::BufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 510 | { |
Jamie Madill | 8f77560 | 2016-11-03 16:45:34 -0400 | [diff] [blame] | 511 | return new BufferVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 512 | } |
| 513 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 514 | VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 515 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 516 | return new VertexArrayVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | QueryImpl *ContextVk::createQuery(GLenum type) |
| 520 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 521 | return new QueryVk(type); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | FenceNVImpl *ContextVk::createFenceNV() |
| 525 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 526 | return new FenceNVVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | FenceSyncImpl *ContextVk::createFenceSync() |
| 530 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 531 | return new FenceSyncVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 532 | } |
| 533 | |
Geoff Lang | 73bd218 | 2016-07-15 13:01:24 -0400 | [diff] [blame] | 534 | TransformFeedbackImpl *ContextVk::createTransformFeedback(const gl::TransformFeedbackState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 535 | { |
Geoff Lang | 73bd218 | 2016-07-15 13:01:24 -0400 | [diff] [blame] | 536 | return new TransformFeedbackVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | SamplerImpl *ContextVk::createSampler() |
| 540 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 541 | return new SamplerVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 542 | } |
| 543 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 544 | std::vector<PathImpl *> ContextVk::createPaths(GLsizei) |
| 545 | { |
| 546 | return std::vector<PathImpl *>(); |
| 547 | } |
| 548 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 549 | // TODO(jmadill): Use pipeline cache. |
| 550 | void ContextVk::invalidateCurrentPipeline() |
| 551 | { |
| 552 | mRenderer->enqueueGarbageOrDeleteNow(*this, mCurrentPipeline); |
| 553 | } |
| 554 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 555 | } // namespace rx |