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 | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 14 | #include "libANGLE/Context.h" |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 15 | #include "libANGLE/Program.h" |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 16 | #include "libANGLE/renderer/vulkan/BufferVk.h" |
| 17 | #include "libANGLE/renderer/vulkan/CompilerVk.h" |
| 18 | #include "libANGLE/renderer/vulkan/ContextVk.h" |
| 19 | #include "libANGLE/renderer/vulkan/DeviceVk.h" |
| 20 | #include "libANGLE/renderer/vulkan/FenceNVVk.h" |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 21 | #include "libANGLE/renderer/vulkan/FramebufferVk.h" |
| 22 | #include "libANGLE/renderer/vulkan/ImageVk.h" |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 23 | #include "libANGLE/renderer/vulkan/ProgramPipelineVk.h" |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 24 | #include "libANGLE/renderer/vulkan/ProgramVk.h" |
| 25 | #include "libANGLE/renderer/vulkan/QueryVk.h" |
| 26 | #include "libANGLE/renderer/vulkan/RenderbufferVk.h" |
| 27 | #include "libANGLE/renderer/vulkan/RendererVk.h" |
| 28 | #include "libANGLE/renderer/vulkan/SamplerVk.h" |
| 29 | #include "libANGLE/renderer/vulkan/ShaderVk.h" |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 30 | #include "libANGLE/renderer/vulkan/SyncVk.h" |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 31 | #include "libANGLE/renderer/vulkan/TextureVk.h" |
| 32 | #include "libANGLE/renderer/vulkan/TransformFeedbackVk.h" |
| 33 | #include "libANGLE/renderer/vulkan/VertexArrayVk.h" |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 34 | #include "libANGLE/renderer/vulkan/formatutilsvk.h" |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 35 | |
| 36 | namespace rx |
| 37 | { |
| 38 | |
Jamie Madill | d03a849 | 2017-10-03 15:46:06 -0400 | [diff] [blame] | 39 | namespace |
| 40 | { |
| 41 | |
| 42 | VkIndexType GetVkIndexType(GLenum glIndexType) |
| 43 | { |
| 44 | switch (glIndexType) |
| 45 | { |
| 46 | case GL_UNSIGNED_SHORT: |
| 47 | return VK_INDEX_TYPE_UINT16; |
| 48 | case GL_UNSIGNED_INT: |
| 49 | return VK_INDEX_TYPE_UINT32; |
| 50 | default: |
| 51 | UNREACHABLE(); |
| 52 | return VK_INDEX_TYPE_MAX_ENUM; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | } // anonymous namespace |
| 57 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 58 | ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer) |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 59 | : ContextImpl(state), mRenderer(renderer), mCurrentDrawMode(GL_NONE) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 60 | { |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 61 | // The module handle is filled out at draw time. |
| 62 | mCurrentShaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
| 63 | mCurrentShaderStages[0].pNext = nullptr; |
| 64 | mCurrentShaderStages[0].flags = 0; |
| 65 | mCurrentShaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
| 66 | mCurrentShaderStages[0].module = VK_NULL_HANDLE; |
| 67 | mCurrentShaderStages[0].pName = "main"; |
| 68 | mCurrentShaderStages[0].pSpecializationInfo = nullptr; |
| 69 | |
| 70 | mCurrentShaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
| 71 | mCurrentShaderStages[1].pNext = nullptr; |
| 72 | mCurrentShaderStages[1].flags = 0; |
| 73 | mCurrentShaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 74 | mCurrentShaderStages[1].module = VK_NULL_HANDLE; |
| 75 | mCurrentShaderStages[1].pName = "main"; |
| 76 | mCurrentShaderStages[1].pSpecializationInfo = nullptr; |
| 77 | |
| 78 | // The binding descriptions are filled in at draw time. |
| 79 | mCurrentVertexInputState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 80 | mCurrentVertexInputState.pNext = nullptr; |
| 81 | mCurrentVertexInputState.flags = 0; |
| 82 | mCurrentVertexInputState.vertexBindingDescriptionCount = 0; |
| 83 | mCurrentVertexInputState.pVertexBindingDescriptions = nullptr; |
| 84 | mCurrentVertexInputState.vertexAttributeDescriptionCount = 0; |
| 85 | mCurrentVertexInputState.pVertexAttributeDescriptions = nullptr; |
| 86 | |
| 87 | // Primitive topology is filled in at draw time. |
| 88 | mCurrentInputAssemblyState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 89 | mCurrentInputAssemblyState.pNext = nullptr; |
| 90 | mCurrentInputAssemblyState.flags = 0; |
| 91 | mCurrentInputAssemblyState.topology = gl_vk::GetPrimitiveTopology(mCurrentDrawMode); |
| 92 | mCurrentInputAssemblyState.primitiveRestartEnable = VK_FALSE; |
| 93 | |
| 94 | // Set initial viewport and scissor state. |
| 95 | mCurrentViewportVk.x = 0.0f; |
| 96 | mCurrentViewportVk.y = 0.0f; |
| 97 | mCurrentViewportVk.width = 0.0f; |
| 98 | mCurrentViewportVk.height = 0.0f; |
| 99 | mCurrentViewportVk.minDepth = 0.0f; |
| 100 | mCurrentViewportVk.maxDepth = 1.0f; |
| 101 | |
| 102 | mCurrentScissorVk.offset.x = 0; |
| 103 | mCurrentScissorVk.offset.y = 0; |
| 104 | mCurrentScissorVk.extent.width = 0u; |
| 105 | mCurrentScissorVk.extent.height = 0u; |
| 106 | |
| 107 | mCurrentViewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 108 | mCurrentViewportState.pNext = nullptr; |
| 109 | mCurrentViewportState.flags = 0; |
| 110 | mCurrentViewportState.viewportCount = 1; |
| 111 | mCurrentViewportState.pViewports = &mCurrentViewportVk; |
| 112 | mCurrentViewportState.scissorCount = 1; |
| 113 | mCurrentViewportState.pScissors = &mCurrentScissorVk; |
| 114 | |
| 115 | // Set initial rasterizer state. |
| 116 | // TODO(jmadill): Extra rasterizer state features. |
| 117 | mCurrentRasterState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 118 | mCurrentRasterState.pNext = nullptr; |
| 119 | mCurrentRasterState.flags = 0; |
| 120 | mCurrentRasterState.depthClampEnable = VK_FALSE; |
| 121 | mCurrentRasterState.rasterizerDiscardEnable = VK_FALSE; |
| 122 | mCurrentRasterState.polygonMode = VK_POLYGON_MODE_FILL; |
| 123 | mCurrentRasterState.cullMode = VK_CULL_MODE_NONE; |
| 124 | mCurrentRasterState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 125 | mCurrentRasterState.depthBiasEnable = VK_FALSE; |
| 126 | mCurrentRasterState.depthBiasConstantFactor = 0.0f; |
| 127 | mCurrentRasterState.depthBiasClamp = 0.0f; |
| 128 | mCurrentRasterState.depthBiasSlopeFactor = 0.0f; |
| 129 | mCurrentRasterState.lineWidth = 1.0f; |
| 130 | |
| 131 | // Initialize a dummy multisample state. |
| 132 | // TODO(jmadill): Multisample state. |
| 133 | mCurrentMultisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 134 | mCurrentMultisampleState.pNext = nullptr; |
| 135 | mCurrentMultisampleState.flags = 0; |
| 136 | mCurrentMultisampleState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 137 | mCurrentMultisampleState.sampleShadingEnable = VK_FALSE; |
| 138 | mCurrentMultisampleState.minSampleShading = 0.0f; |
| 139 | mCurrentMultisampleState.pSampleMask = nullptr; |
| 140 | mCurrentMultisampleState.alphaToCoverageEnable = VK_FALSE; |
| 141 | mCurrentMultisampleState.alphaToOneEnable = VK_FALSE; |
| 142 | |
| 143 | // TODO(jmadill): Depth/stencil state. |
| 144 | |
| 145 | // Initialize a dummy MRT blend state. |
| 146 | // TODO(jmadill): Blend state/MRT. |
| 147 | mCurrentBlendAttachmentState.blendEnable = VK_FALSE; |
| 148 | mCurrentBlendAttachmentState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; |
| 149 | mCurrentBlendAttachmentState.dstColorBlendFactor = VK_BLEND_FACTOR_ONE; |
| 150 | mCurrentBlendAttachmentState.colorBlendOp = VK_BLEND_OP_ADD; |
| 151 | mCurrentBlendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; |
| 152 | mCurrentBlendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE; |
| 153 | mCurrentBlendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD; |
| 154 | mCurrentBlendAttachmentState.colorWriteMask = |
| 155 | (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | |
| 156 | VK_COLOR_COMPONENT_A_BIT); |
| 157 | |
| 158 | mCurrentBlendState.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 159 | mCurrentBlendState.pNext = 0; |
| 160 | mCurrentBlendState.flags = 0; |
| 161 | mCurrentBlendState.logicOpEnable = VK_FALSE; |
| 162 | mCurrentBlendState.logicOp = VK_LOGIC_OP_CLEAR; |
| 163 | mCurrentBlendState.attachmentCount = 1; |
| 164 | mCurrentBlendState.pAttachments = &mCurrentBlendAttachmentState; |
| 165 | mCurrentBlendState.blendConstants[0] = 0.0f; |
| 166 | mCurrentBlendState.blendConstants[1] = 0.0f; |
| 167 | mCurrentBlendState.blendConstants[2] = 0.0f; |
| 168 | mCurrentBlendState.blendConstants[3] = 0.0f; |
| 169 | |
| 170 | // TODO(jmadill): Dynamic state. |
| 171 | |
| 172 | // The layout and renderpass are filled out at draw time. |
| 173 | mCurrentPipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 174 | mCurrentPipelineInfo.pNext = nullptr; |
| 175 | mCurrentPipelineInfo.flags = 0; |
| 176 | mCurrentPipelineInfo.stageCount = 2; |
| 177 | mCurrentPipelineInfo.pStages = mCurrentShaderStages; |
| 178 | mCurrentPipelineInfo.pVertexInputState = &mCurrentVertexInputState; |
| 179 | mCurrentPipelineInfo.pInputAssemblyState = &mCurrentInputAssemblyState; |
| 180 | mCurrentPipelineInfo.pTessellationState = nullptr; |
| 181 | mCurrentPipelineInfo.pViewportState = &mCurrentViewportState; |
| 182 | mCurrentPipelineInfo.pRasterizationState = &mCurrentRasterState; |
| 183 | mCurrentPipelineInfo.pMultisampleState = &mCurrentMultisampleState; |
| 184 | mCurrentPipelineInfo.pDepthStencilState = nullptr; |
| 185 | mCurrentPipelineInfo.pColorBlendState = &mCurrentBlendState; |
| 186 | mCurrentPipelineInfo.pDynamicState = nullptr; |
| 187 | mCurrentPipelineInfo.layout = VK_NULL_HANDLE; |
| 188 | mCurrentPipelineInfo.renderPass = VK_NULL_HANDLE; |
| 189 | mCurrentPipelineInfo.subpass = 0; |
| 190 | mCurrentPipelineInfo.basePipelineHandle = VK_NULL_HANDLE; |
| 191 | mCurrentPipelineInfo.basePipelineIndex = 0; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | ContextVk::~ContextVk() |
| 195 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 196 | invalidateCurrentPipeline(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | gl::Error ContextVk::initialize() |
| 200 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 201 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | gl::Error ContextVk::flush() |
| 205 | { |
| 206 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 207 | return gl::InternalError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | gl::Error ContextVk::finish() |
| 211 | { |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 212 | // TODO(jmadill): Implement finish. |
| 213 | // UNIMPLEMENTED(); |
| 214 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 215 | } |
| 216 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 217 | gl::Error ContextVk::initPipeline(const gl::Context *context) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 218 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 219 | ASSERT(!mCurrentPipeline.valid()); |
| 220 | |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 221 | VkDevice device = mRenderer->getDevice(); |
| 222 | const auto &state = mState.getState(); |
| 223 | const auto &programGL = state.getProgram(); |
| 224 | const auto &vao = state.getVertexArray(); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 225 | const auto &programVk = GetImplAs<ProgramVk>(programGL); |
| 226 | const auto *drawFBO = state.getDrawFramebuffer(); |
| 227 | FramebufferVk *vkFBO = GetImplAs<FramebufferVk>(drawFBO); |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 228 | VertexArrayVk *vkVAO = GetImplAs<VertexArrayVk>(vao); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 229 | |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 230 | // Ensure the attribs and bindings are updated. |
| 231 | vkVAO->updateVertexDescriptions(context); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 232 | |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 233 | const auto &vertexBindings = vkVAO->getVertexBindingDescs(); |
| 234 | const auto &vertexAttribs = vkVAO->getVertexAttribDescs(); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 235 | |
| 236 | // TODO(jmadill): Validate with ASSERT against physical device limits/caps? |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 237 | mCurrentVertexInputState.vertexBindingDescriptionCount = |
| 238 | static_cast<uint32_t>(vertexBindings.size()); |
| 239 | mCurrentVertexInputState.pVertexBindingDescriptions = vertexBindings.data(); |
| 240 | mCurrentVertexInputState.vertexAttributeDescriptionCount = |
| 241 | static_cast<uint32_t>(vertexAttribs.size()); |
| 242 | mCurrentVertexInputState.pVertexAttributeDescriptions = vertexAttribs.data(); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 243 | |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 244 | mCurrentInputAssemblyState.topology = gl_vk::GetPrimitiveTopology(mCurrentDrawMode); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 245 | |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 246 | vk::RenderPass *renderPass = nullptr; |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 247 | ANGLE_TRY_RESULT(vkFBO->getRenderPass(context, device), renderPass); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 248 | ASSERT(renderPass && renderPass->valid()); |
| 249 | |
Jamie Madill | c514348 | 2017-10-15 20:20:06 -0400 | [diff] [blame^] | 250 | const vk::PipelineLayout &pipelineLayout = programVk->getPipelineLayout(); |
| 251 | ASSERT(pipelineLayout.valid()); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 252 | |
Jamie Madill | c514348 | 2017-10-15 20:20:06 -0400 | [diff] [blame^] | 253 | mCurrentPipelineInfo.layout = pipelineLayout.getHandle(); |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 254 | mCurrentPipelineInfo.renderPass = renderPass->getHandle(); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 255 | |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 256 | vk::Pipeline newPipeline; |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 257 | ANGLE_TRY(newPipeline.initGraphics(device, mCurrentPipelineInfo)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 258 | |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 259 | // TODO(jmadill): Don't dispose the current pipeline immediately, it could be in use. |
Jamie Madill | 5deea72 | 2017-02-16 10:44:46 -0500 | [diff] [blame] | 260 | mCurrentPipeline.retain(device, std::move(newPipeline)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 261 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 262 | return gl::NoError(); |
| 263 | } |
| 264 | |
Jamie Madill | d03a849 | 2017-10-03 15:46:06 -0400 | [diff] [blame] | 265 | gl::Error ContextVk::setupDraw(const gl::Context *context, GLenum mode) |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 266 | { |
| 267 | if (mode != mCurrentDrawMode) |
| 268 | { |
| 269 | invalidateCurrentPipeline(); |
| 270 | mCurrentDrawMode = mode; |
| 271 | } |
| 272 | |
| 273 | if (!mCurrentPipeline.valid()) |
| 274 | { |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 275 | ANGLE_TRY(initPipeline(context)); |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 276 | ASSERT(mCurrentPipeline.valid()); |
| 277 | } |
| 278 | |
| 279 | VkDevice device = mRenderer->getDevice(); |
| 280 | const auto &state = mState.getState(); |
| 281 | const auto &programGL = state.getProgram(); |
| 282 | const auto &vao = state.getVertexArray(); |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 283 | VertexArrayVk *vkVAO = GetImplAs<VertexArrayVk>(vao); |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 284 | const auto *drawFBO = state.getDrawFramebuffer(); |
| 285 | FramebufferVk *vkFBO = GetImplAs<FramebufferVk>(drawFBO); |
| 286 | Serial queueSerial = mRenderer->getCurrentQueueSerial(); |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 287 | uint32_t maxAttrib = programGL->getState().getMaxActiveAttribLocation(); |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 288 | |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 289 | // Process vertex attributes. Assume zero offsets for now. |
| 290 | // TODO(jmadill): Offset handling. |
| 291 | const std::vector<VkBuffer> &vertexHandles = vkVAO->getCurrentVertexBufferHandlesCache(); |
| 292 | angle::MemoryBuffer *zeroBuf = nullptr; |
| 293 | ANGLE_TRY(context->getZeroFilledBuffer(maxAttrib * sizeof(VkDeviceSize), &zeroBuf)); |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 294 | |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 295 | vk::CommandBuffer *commandBuffer = nullptr; |
| 296 | ANGLE_TRY(mRenderer->getStartedCommandBuffer(&commandBuffer)); |
Jamie Madill | d482615 | 2017-09-21 11:18:59 -0400 | [diff] [blame] | 297 | ANGLE_TRY(vkFBO->ensureInRenderPass(context, device, commandBuffer, queueSerial, state)); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 298 | |
| 299 | commandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, mCurrentPipeline); |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 300 | commandBuffer->bindVertexBuffers(0, maxAttrib, vertexHandles.data(), |
| 301 | reinterpret_cast<const VkDeviceSize *>(zeroBuf->data())); |
| 302 | |
Jamie Madill | abd3135 | 2017-09-19 00:24:58 -0400 | [diff] [blame] | 303 | // TODO(jmadill): the queue serial should be bound to the pipeline. |
| 304 | setQueueSerial(queueSerial); |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 305 | vkVAO->updateCurrentBufferSerials(programGL->getActiveAttribLocationsMask(), queueSerial); |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 306 | |
| 307 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 308 | } |
| 309 | |
Jamie Madill | d03a849 | 2017-10-03 15:46:06 -0400 | [diff] [blame] | 310 | gl::Error ContextVk::drawArrays(const gl::Context *context, GLenum mode, GLint first, GLsizei count) |
| 311 | { |
| 312 | ANGLE_TRY(setupDraw(context, mode)); |
| 313 | |
| 314 | vk::CommandBuffer *commandBuffer = nullptr; |
| 315 | ANGLE_TRY(mRenderer->getStartedCommandBuffer(&commandBuffer)); |
| 316 | |
| 317 | commandBuffer->draw(count, 1, first, 0); |
| 318 | return gl::NoError(); |
| 319 | } |
| 320 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 321 | gl::Error ContextVk::drawArraysInstanced(const gl::Context *context, |
| 322 | GLenum mode, |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 323 | GLint first, |
| 324 | GLsizei count, |
| 325 | GLsizei instanceCount) |
| 326 | { |
| 327 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 328 | return gl::InternalError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 329 | } |
| 330 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 331 | gl::Error ContextVk::drawElements(const gl::Context *context, |
| 332 | GLenum mode, |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 333 | GLsizei count, |
| 334 | GLenum type, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 335 | const void *indices) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 336 | { |
Jamie Madill | d03a849 | 2017-10-03 15:46:06 -0400 | [diff] [blame] | 337 | ANGLE_TRY(setupDraw(context, mode)); |
| 338 | |
| 339 | if (indices) |
| 340 | { |
| 341 | // TODO(jmadill): Buffer offsets and immediate data. |
| 342 | UNIMPLEMENTED(); |
| 343 | return gl::InternalError() << "Only zero-offset index buffers are currently implemented."; |
| 344 | } |
| 345 | |
| 346 | if (type == GL_UNSIGNED_BYTE) |
| 347 | { |
| 348 | // TODO(jmadill): Index translation. |
| 349 | UNIMPLEMENTED(); |
| 350 | return gl::InternalError() << "Unsigned byte translation is not yet implemented."; |
| 351 | } |
| 352 | |
| 353 | vk::CommandBuffer *commandBuffer = nullptr; |
| 354 | ANGLE_TRY(mRenderer->getStartedCommandBuffer(&commandBuffer)); |
| 355 | |
| 356 | const gl::Buffer *elementArrayBuffer = |
| 357 | mState.getState().getVertexArray()->getElementArrayBuffer().get(); |
| 358 | ASSERT(elementArrayBuffer); |
| 359 | |
| 360 | BufferVk *elementArrayBufferVk = GetImplAs<BufferVk>(elementArrayBuffer); |
| 361 | |
| 362 | commandBuffer->bindIndexBuffer(elementArrayBufferVk->getVkBuffer(), 0, GetVkIndexType(type)); |
| 363 | commandBuffer->drawIndexed(count, 1, 0, 0, 0); |
| 364 | |
| 365 | return gl::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 366 | } |
| 367 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 368 | gl::Error ContextVk::drawElementsInstanced(const gl::Context *context, |
| 369 | GLenum mode, |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 370 | GLsizei count, |
| 371 | GLenum type, |
Jamie Madill | 876429b | 2017-04-20 15:46:24 -0400 | [diff] [blame] | 372 | const void *indices, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 373 | GLsizei instances) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 374 | { |
| 375 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 376 | return gl::InternalError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 377 | } |
| 378 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 379 | gl::Error ContextVk::drawRangeElements(const gl::Context *context, |
| 380 | GLenum mode, |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 381 | GLuint start, |
| 382 | GLuint end, |
| 383 | GLsizei count, |
| 384 | GLenum type, |
Qin Jiajia | 1da0065 | 2017-06-20 17:16:25 +0800 | [diff] [blame] | 385 | const void *indices) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 386 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 387 | return gl::NoError(); |
| 388 | } |
| 389 | |
| 390 | VkDevice ContextVk::getDevice() const |
| 391 | { |
| 392 | return mRenderer->getDevice(); |
| 393 | } |
| 394 | |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 395 | vk::Error ContextVk::getStartedCommandBuffer(vk::CommandBuffer **commandBufferOut) |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 396 | { |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 397 | return mRenderer->getStartedCommandBuffer(commandBufferOut); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 398 | } |
| 399 | |
Jamie Madill | 0c0dc34 | 2017-03-24 14:18:51 -0400 | [diff] [blame] | 400 | vk::Error ContextVk::submitCommands(vk::CommandBuffer *commandBuffer) |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 401 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 402 | setQueueSerial(mRenderer->getCurrentQueueSerial()); |
Jamie Madill | f651c77 | 2017-02-21 15:03:51 -0500 | [diff] [blame] | 403 | ANGLE_TRY(mRenderer->submitCommandBuffer(commandBuffer)); |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 404 | return vk::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 405 | } |
| 406 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 407 | gl::Error ContextVk::drawArraysIndirect(const gl::Context *context, |
| 408 | GLenum mode, |
| 409 | const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 410 | { |
| 411 | UNIMPLEMENTED(); |
| 412 | return gl::InternalError() << "DrawArraysIndirect hasn't been implemented for vulkan backend."; |
| 413 | } |
| 414 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 415 | gl::Error ContextVk::drawElementsIndirect(const gl::Context *context, |
| 416 | GLenum mode, |
| 417 | GLenum type, |
| 418 | const void *indirect) |
Jiajia Qin | d967122 | 2016-11-29 16:30:31 +0800 | [diff] [blame] | 419 | { |
| 420 | UNIMPLEMENTED(); |
| 421 | return gl::InternalError() |
| 422 | << "DrawElementsIndirect hasn't been implemented for vulkan backend."; |
| 423 | } |
| 424 | |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 425 | GLenum ContextVk::getResetStatus() |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 426 | { |
| 427 | UNIMPLEMENTED(); |
Corentin Wallez | 87fbe1c | 2016-08-03 14:41:42 -0400 | [diff] [blame] | 428 | return GL_NO_ERROR; |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | std::string ContextVk::getVendorString() const |
| 432 | { |
| 433 | UNIMPLEMENTED(); |
| 434 | return std::string(); |
| 435 | } |
| 436 | |
| 437 | std::string ContextVk::getRendererDescription() const |
| 438 | { |
Jamie Madill | e09bd5d | 2016-11-29 16:20:35 -0500 | [diff] [blame] | 439 | return mRenderer->getRendererDescription(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | void ContextVk::insertEventMarker(GLsizei length, const char *marker) |
| 443 | { |
| 444 | UNIMPLEMENTED(); |
| 445 | } |
| 446 | |
| 447 | void ContextVk::pushGroupMarker(GLsizei length, const char *marker) |
| 448 | { |
| 449 | UNIMPLEMENTED(); |
| 450 | } |
| 451 | |
| 452 | void ContextVk::popGroupMarker() |
| 453 | { |
| 454 | UNIMPLEMENTED(); |
| 455 | } |
| 456 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 457 | void ContextVk::syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 458 | { |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 459 | if (dirtyBits.any()) |
| 460 | { |
| 461 | invalidateCurrentPipeline(); |
| 462 | } |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 463 | |
| 464 | const auto &glState = context->getGLState(); |
| 465 | |
| 466 | // TODO(jmadill): Full dirty bits implementation. |
| 467 | |
| 468 | for (auto dirtyBit : dirtyBits) |
| 469 | { |
| 470 | switch (dirtyBit) |
| 471 | { |
| 472 | case gl::State::DIRTY_BIT_SCISSOR_TEST_ENABLED: |
| 473 | WARN() << "DIRTY_BIT_SCISSOR_TEST_ENABLED unimplemented"; |
| 474 | break; |
| 475 | case gl::State::DIRTY_BIT_SCISSOR: |
| 476 | WARN() << "DIRTY_BIT_SCISSOR unimplemented"; |
| 477 | break; |
| 478 | case gl::State::DIRTY_BIT_VIEWPORT: |
| 479 | { |
| 480 | const gl::Rectangle &viewportGL = glState.getViewport(); |
| 481 | mCurrentViewportVk.x = static_cast<float>(viewportGL.x); |
| 482 | mCurrentViewportVk.y = static_cast<float>(viewportGL.y); |
| 483 | mCurrentViewportVk.width = static_cast<float>(viewportGL.width); |
| 484 | mCurrentViewportVk.height = static_cast<float>(viewportGL.height); |
| 485 | mCurrentViewportVk.minDepth = glState.getNearPlane(); |
| 486 | mCurrentViewportVk.maxDepth = glState.getFarPlane(); |
| 487 | |
| 488 | // TODO(jmadill): Scissor. |
| 489 | mCurrentScissorVk.offset.x = viewportGL.x; |
| 490 | mCurrentScissorVk.offset.y = viewportGL.y; |
| 491 | mCurrentScissorVk.extent.width = viewportGL.width; |
| 492 | mCurrentScissorVk.extent.height = viewportGL.height; |
| 493 | break; |
| 494 | } |
| 495 | case gl::State::DIRTY_BIT_DEPTH_RANGE: |
| 496 | WARN() << "DIRTY_BIT_DEPTH_RANGE unimplemented"; |
| 497 | break; |
| 498 | case gl::State::DIRTY_BIT_BLEND_ENABLED: |
| 499 | WARN() << "DIRTY_BIT_BLEND_ENABLED unimplemented"; |
| 500 | break; |
| 501 | case gl::State::DIRTY_BIT_BLEND_COLOR: |
| 502 | WARN() << "DIRTY_BIT_BLEND_COLOR unimplemented"; |
| 503 | break; |
| 504 | case gl::State::DIRTY_BIT_BLEND_FUNCS: |
| 505 | WARN() << "DIRTY_BIT_BLEND_FUNCS unimplemented"; |
| 506 | break; |
| 507 | case gl::State::DIRTY_BIT_BLEND_EQUATIONS: |
| 508 | WARN() << "DIRTY_BIT_BLEND_EQUATIONS unimplemented"; |
| 509 | break; |
| 510 | case gl::State::DIRTY_BIT_COLOR_MASK: |
| 511 | WARN() << "DIRTY_BIT_COLOR_MASK unimplemented"; |
| 512 | break; |
| 513 | case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED: |
| 514 | WARN() << "DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED unimplemented"; |
| 515 | break; |
| 516 | case gl::State::DIRTY_BIT_SAMPLE_COVERAGE_ENABLED: |
| 517 | WARN() << "DIRTY_BIT_SAMPLE_COVERAGE_ENABLED unimplemented"; |
| 518 | break; |
| 519 | case gl::State::DIRTY_BIT_SAMPLE_COVERAGE: |
| 520 | WARN() << "DIRTY_BIT_SAMPLE_COVERAGE unimplemented"; |
| 521 | break; |
| 522 | case gl::State::DIRTY_BIT_SAMPLE_MASK_ENABLED: |
| 523 | WARN() << "DIRTY_BIT_SAMPLE_MASK_ENABLED unimplemented"; |
| 524 | break; |
| 525 | case gl::State::DIRTY_BIT_SAMPLE_MASK_WORD_0: |
| 526 | case gl::State::DIRTY_BIT_SAMPLE_MASK_WORD_0 + 1: |
| 527 | WARN() << "DIRTY_BIT_SAMPLE_MASK_WORD unimplemented"; |
| 528 | break; |
| 529 | case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED: |
| 530 | WARN() << "DIRTY_BIT_DEPTH_TEST_ENABLED unimplemented"; |
| 531 | break; |
| 532 | case gl::State::DIRTY_BIT_DEPTH_FUNC: |
| 533 | WARN() << "DIRTY_BIT_DEPTH_FUNC unimplemented"; |
| 534 | break; |
| 535 | case gl::State::DIRTY_BIT_DEPTH_MASK: |
| 536 | WARN() << "DIRTY_BIT_DEPTH_MASK unimplemented"; |
| 537 | break; |
| 538 | case gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED: |
| 539 | WARN() << "DIRTY_BIT_STENCIL_TEST_ENABLED unimplemented"; |
| 540 | break; |
| 541 | case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT: |
| 542 | WARN() << "DIRTY_BIT_STENCIL_FUNCS_FRONT unimplemented"; |
| 543 | break; |
| 544 | case gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK: |
| 545 | WARN() << "DIRTY_BIT_STENCIL_FUNCS_BACK unimplemented"; |
| 546 | break; |
| 547 | case gl::State::DIRTY_BIT_STENCIL_OPS_FRONT: |
| 548 | WARN() << "DIRTY_BIT_STENCIL_OPS_FRONT unimplemented"; |
| 549 | break; |
| 550 | case gl::State::DIRTY_BIT_STENCIL_OPS_BACK: |
| 551 | WARN() << "DIRTY_BIT_STENCIL_OPS_BACK unimplemented"; |
| 552 | break; |
| 553 | case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT: |
| 554 | WARN() << "DIRTY_BIT_STENCIL_WRITEMASK_FRONT unimplemented"; |
| 555 | break; |
| 556 | case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK: |
| 557 | WARN() << "DIRTY_BIT_STENCIL_WRITEMASK_BACK unimplemented"; |
| 558 | break; |
| 559 | case gl::State::DIRTY_BIT_CULL_FACE_ENABLED: |
| 560 | case gl::State::DIRTY_BIT_CULL_FACE: |
| 561 | mCurrentRasterState.cullMode = gl_vk::GetCullMode(glState.getRasterizerState()); |
| 562 | break; |
| 563 | case gl::State::DIRTY_BIT_FRONT_FACE: |
| 564 | mCurrentRasterState.frontFace = |
| 565 | gl_vk::GetFrontFace(glState.getRasterizerState().frontFace); |
| 566 | break; |
| 567 | case gl::State::DIRTY_BIT_POLYGON_OFFSET_FILL_ENABLED: |
| 568 | WARN() << "DIRTY_BIT_POLYGON_OFFSET_FILL_ENABLED unimplemented"; |
| 569 | break; |
| 570 | case gl::State::DIRTY_BIT_POLYGON_OFFSET: |
| 571 | WARN() << "DIRTY_BIT_POLYGON_OFFSET unimplemented"; |
| 572 | break; |
| 573 | case gl::State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED: |
| 574 | WARN() << "DIRTY_BIT_RASTERIZER_DISCARD_ENABLED unimplemented"; |
| 575 | break; |
| 576 | case gl::State::DIRTY_BIT_LINE_WIDTH: |
| 577 | mCurrentRasterState.lineWidth = glState.getLineWidth(); |
| 578 | break; |
| 579 | case gl::State::DIRTY_BIT_PRIMITIVE_RESTART_ENABLED: |
| 580 | WARN() << "DIRTY_BIT_PRIMITIVE_RESTART_ENABLED unimplemented"; |
| 581 | break; |
| 582 | case gl::State::DIRTY_BIT_CLEAR_COLOR: |
| 583 | WARN() << "DIRTY_BIT_CLEAR_COLOR unimplemented"; |
| 584 | break; |
| 585 | case gl::State::DIRTY_BIT_CLEAR_DEPTH: |
| 586 | WARN() << "DIRTY_BIT_CLEAR_DEPTH unimplemented"; |
| 587 | break; |
| 588 | case gl::State::DIRTY_BIT_CLEAR_STENCIL: |
| 589 | WARN() << "DIRTY_BIT_CLEAR_STENCIL unimplemented"; |
| 590 | break; |
| 591 | case gl::State::DIRTY_BIT_UNPACK_ALIGNMENT: |
| 592 | WARN() << "DIRTY_BIT_UNPACK_ALIGNMENT unimplemented"; |
| 593 | break; |
| 594 | case gl::State::DIRTY_BIT_UNPACK_ROW_LENGTH: |
| 595 | WARN() << "DIRTY_BIT_UNPACK_ROW_LENGTH unimplemented"; |
| 596 | break; |
| 597 | case gl::State::DIRTY_BIT_UNPACK_IMAGE_HEIGHT: |
| 598 | WARN() << "DIRTY_BIT_UNPACK_IMAGE_HEIGHT unimplemented"; |
| 599 | break; |
| 600 | case gl::State::DIRTY_BIT_UNPACK_SKIP_IMAGES: |
| 601 | WARN() << "DIRTY_BIT_UNPACK_SKIP_IMAGES unimplemented"; |
| 602 | break; |
| 603 | case gl::State::DIRTY_BIT_UNPACK_SKIP_ROWS: |
| 604 | WARN() << "DIRTY_BIT_UNPACK_SKIP_ROWS unimplemented"; |
| 605 | break; |
| 606 | case gl::State::DIRTY_BIT_UNPACK_SKIP_PIXELS: |
| 607 | WARN() << "DIRTY_BIT_UNPACK_SKIP_PIXELS unimplemented"; |
| 608 | break; |
| 609 | case gl::State::DIRTY_BIT_UNPACK_BUFFER_BINDING: |
| 610 | WARN() << "DIRTY_BIT_UNPACK_BUFFER_BINDING unimplemented"; |
| 611 | break; |
| 612 | case gl::State::DIRTY_BIT_PACK_ALIGNMENT: |
| 613 | WARN() << "DIRTY_BIT_PACK_ALIGNMENT unimplemented"; |
| 614 | break; |
| 615 | case gl::State::DIRTY_BIT_PACK_REVERSE_ROW_ORDER: |
| 616 | WARN() << "DIRTY_BIT_PACK_REVERSE_ROW_ORDER unimplemented"; |
| 617 | break; |
| 618 | case gl::State::DIRTY_BIT_PACK_ROW_LENGTH: |
| 619 | WARN() << "DIRTY_BIT_PACK_ROW_LENGTH unimplemented"; |
| 620 | break; |
| 621 | case gl::State::DIRTY_BIT_PACK_SKIP_ROWS: |
| 622 | WARN() << "DIRTY_BIT_PACK_SKIP_ROWS unimplemented"; |
| 623 | break; |
| 624 | case gl::State::DIRTY_BIT_PACK_SKIP_PIXELS: |
| 625 | WARN() << "DIRTY_BIT_PACK_SKIP_PIXELS unimplemented"; |
| 626 | break; |
| 627 | case gl::State::DIRTY_BIT_PACK_BUFFER_BINDING: |
| 628 | WARN() << "DIRTY_BIT_PACK_BUFFER_BINDING unimplemented"; |
| 629 | break; |
| 630 | case gl::State::DIRTY_BIT_DITHER_ENABLED: |
| 631 | WARN() << "DIRTY_BIT_DITHER_ENABLED unimplemented"; |
| 632 | break; |
| 633 | case gl::State::DIRTY_BIT_GENERATE_MIPMAP_HINT: |
| 634 | WARN() << "DIRTY_BIT_GENERATE_MIPMAP_HINT unimplemented"; |
| 635 | break; |
| 636 | case gl::State::DIRTY_BIT_SHADER_DERIVATIVE_HINT: |
| 637 | WARN() << "DIRTY_BIT_SHADER_DERIVATIVE_HINT unimplemented"; |
| 638 | break; |
| 639 | case gl::State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING: |
| 640 | WARN() << "DIRTY_BIT_READ_FRAMEBUFFER_BINDING unimplemented"; |
| 641 | break; |
| 642 | case gl::State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING: |
| 643 | WARN() << "DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING unimplemented"; |
| 644 | break; |
| 645 | case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING: |
| 646 | WARN() << "DIRTY_BIT_RENDERBUFFER_BINDING unimplemented"; |
| 647 | break; |
| 648 | case gl::State::DIRTY_BIT_VERTEX_ARRAY_BINDING: |
| 649 | WARN() << "DIRTY_BIT_VERTEX_ARRAY_BINDING unimplemented"; |
| 650 | break; |
| 651 | case gl::State::DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING: |
| 652 | WARN() << "DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING unimplemented"; |
| 653 | break; |
| 654 | case gl::State::DIRTY_BIT_PROGRAM_BINDING: |
| 655 | WARN() << "DIRTY_BIT_PROGRAM_BINDING unimplemented"; |
| 656 | break; |
| 657 | case gl::State::DIRTY_BIT_PROGRAM_EXECUTABLE: |
| 658 | { |
| 659 | // { vertex, fragment } |
| 660 | ProgramVk *programVk = GetImplAs<ProgramVk>(glState.getProgram()); |
| 661 | mCurrentShaderStages[0].module = programVk->getLinkedVertexModule().getHandle(); |
| 662 | mCurrentShaderStages[1].module = programVk->getLinkedFragmentModule().getHandle(); |
| 663 | |
| 664 | // Also invalidate the vertex descriptions cache in the Vertex Array. |
| 665 | VertexArrayVk *vaoVk = GetImplAs<VertexArrayVk>(glState.getVertexArray()); |
| 666 | vaoVk->invalidateVertexDescriptions(); |
| 667 | break; |
| 668 | } |
| 669 | case gl::State::DIRTY_BIT_TEXTURE_BINDINGS: |
| 670 | WARN() << "DIRTY_BIT_TEXTURE_BINDINGS unimplemented"; |
| 671 | break; |
| 672 | case gl::State::DIRTY_BIT_SAMPLER_BINDINGS: |
| 673 | WARN() << "DIRTY_BIT_SAMPLER_BINDINGS unimplemented"; |
| 674 | break; |
| 675 | case gl::State::DIRTY_BIT_MULTISAMPLING: |
| 676 | WARN() << "DIRTY_BIT_MULTISAMPLING unimplemented"; |
| 677 | break; |
| 678 | case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_ONE: |
| 679 | WARN() << "DIRTY_BIT_SAMPLE_ALPHA_TO_ONE unimplemented"; |
| 680 | break; |
| 681 | case gl::State::DIRTY_BIT_COVERAGE_MODULATION: |
| 682 | WARN() << "DIRTY_BIT_COVERAGE_MODULATION unimplemented"; |
| 683 | break; |
| 684 | case gl::State::DIRTY_BIT_PATH_RENDERING_MATRIX_MV: |
| 685 | WARN() << "DIRTY_BIT_PATH_RENDERING_MATRIX_MV unimplemented"; |
| 686 | break; |
| 687 | case gl::State::DIRTY_BIT_PATH_RENDERING_MATRIX_PROJ: |
| 688 | WARN() << "DIRTY_BIT_PATH_RENDERING_MATRIX_PROJ unimplemented"; |
| 689 | break; |
| 690 | case gl::State::DIRTY_BIT_PATH_RENDERING_STENCIL_STATE: |
| 691 | WARN() << "DIRTY_BIT_PATH_RENDERING_STENCIL_STATE unimplemented"; |
| 692 | break; |
| 693 | case gl::State::DIRTY_BIT_FRAMEBUFFER_SRGB: |
| 694 | WARN() << "DIRTY_BIT_FRAMEBUFFER_SRGB unimplemented"; |
| 695 | break; |
| 696 | default: |
| 697 | if (dirtyBit >= gl::State::DIRTY_BIT_CURRENT_VALUE_0 && |
| 698 | dirtyBit < gl::State::DIRTY_BIT_CURRENT_VALUE_MAX) |
| 699 | { |
| 700 | WARN() << "DIRTY_BIT_CURRENT_VALUE unimplemented"; |
| 701 | } |
| 702 | else |
| 703 | { |
| 704 | UNREACHABLE(); |
| 705 | } |
| 706 | break; |
| 707 | } |
| 708 | } |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | GLint ContextVk::getGPUDisjoint() |
| 712 | { |
| 713 | UNIMPLEMENTED(); |
| 714 | return GLint(); |
| 715 | } |
| 716 | |
| 717 | GLint64 ContextVk::getTimestamp() |
| 718 | { |
| 719 | UNIMPLEMENTED(); |
| 720 | return GLint64(); |
| 721 | } |
| 722 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 723 | void ContextVk::onMakeCurrent(const gl::Context * /*context*/) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 724 | { |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | const gl::Caps &ContextVk::getNativeCaps() const |
| 728 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 729 | return mRenderer->getNativeCaps(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | const gl::TextureCapsMap &ContextVk::getNativeTextureCaps() const |
| 733 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 734 | return mRenderer->getNativeTextureCaps(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | const gl::Extensions &ContextVk::getNativeExtensions() const |
| 738 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 739 | return mRenderer->getNativeExtensions(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | const gl::Limitations &ContextVk::getNativeLimitations() const |
| 743 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 744 | return mRenderer->getNativeLimitations(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | CompilerImpl *ContextVk::createCompiler() |
| 748 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 749 | return new CompilerVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 750 | } |
| 751 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 752 | ShaderImpl *ContextVk::createShader(const gl::ShaderState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 753 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 754 | return new ShaderVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 755 | } |
| 756 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 757 | ProgramImpl *ContextVk::createProgram(const gl::ProgramState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 758 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 759 | return new ProgramVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 760 | } |
| 761 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 762 | FramebufferImpl *ContextVk::createFramebuffer(const gl::FramebufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 763 | { |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 764 | return FramebufferVk::CreateUserFBO(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | TextureImpl *ContextVk::createTexture(const gl::TextureState &state) |
| 768 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 769 | return new TextureVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | RenderbufferImpl *ContextVk::createRenderbuffer() |
| 773 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 774 | return new RenderbufferVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 775 | } |
| 776 | |
Jamie Madill | 8f77560 | 2016-11-03 16:45:34 -0400 | [diff] [blame] | 777 | BufferImpl *ContextVk::createBuffer(const gl::BufferState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 778 | { |
Jamie Madill | 8f77560 | 2016-11-03 16:45:34 -0400 | [diff] [blame] | 779 | return new BufferVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 780 | } |
| 781 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 782 | VertexArrayImpl *ContextVk::createVertexArray(const gl::VertexArrayState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 783 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 784 | return new VertexArrayVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | QueryImpl *ContextVk::createQuery(GLenum type) |
| 788 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 789 | return new QueryVk(type); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | FenceNVImpl *ContextVk::createFenceNV() |
| 793 | { |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 794 | return new FenceNVVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 795 | } |
| 796 | |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 797 | SyncImpl *ContextVk::createSync() |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 798 | { |
Jamie Madill | 70b5bb0 | 2017-08-28 13:32:37 -0400 | [diff] [blame] | 799 | return new SyncVk(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 800 | } |
| 801 | |
Geoff Lang | 73bd218 | 2016-07-15 13:01:24 -0400 | [diff] [blame] | 802 | TransformFeedbackImpl *ContextVk::createTransformFeedback(const gl::TransformFeedbackState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 803 | { |
Geoff Lang | 73bd218 | 2016-07-15 13:01:24 -0400 | [diff] [blame] | 804 | return new TransformFeedbackVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 805 | } |
| 806 | |
Jamie Madill | 06ef36b | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 807 | SamplerImpl *ContextVk::createSampler(const gl::SamplerState &state) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 808 | { |
Jamie Madill | 06ef36b | 2017-09-09 23:32:46 -0400 | [diff] [blame] | 809 | return new SamplerVk(state); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 810 | } |
| 811 | |
Yunchao He | a336b90 | 2017-08-02 16:05:21 +0800 | [diff] [blame] | 812 | ProgramPipelineImpl *ContextVk::createProgramPipeline(const gl::ProgramPipelineState &state) |
| 813 | { |
| 814 | return new ProgramPipelineVk(state); |
| 815 | } |
| 816 | |
Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame] | 817 | std::vector<PathImpl *> ContextVk::createPaths(GLsizei) |
| 818 | { |
| 819 | return std::vector<PathImpl *>(); |
| 820 | } |
| 821 | |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 822 | // TODO(jmadill): Use pipeline cache. |
| 823 | void ContextVk::invalidateCurrentPipeline() |
| 824 | { |
| 825 | mRenderer->enqueueGarbageOrDeleteNow(*this, mCurrentPipeline); |
| 826 | } |
| 827 | |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 828 | gl::Error ContextVk::dispatchCompute(const gl::Context *context, |
| 829 | GLuint numGroupsX, |
| 830 | GLuint numGroupsY, |
| 831 | GLuint numGroupsZ) |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 832 | { |
| 833 | UNIMPLEMENTED(); |
Yuly Novikov | c4d18aa | 2017-03-09 18:45:02 -0500 | [diff] [blame] | 834 | return gl::InternalError(); |
Xinghua Cao | 2b39659 | 2017-03-29 15:36:04 +0800 | [diff] [blame] | 835 | } |
| 836 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 837 | } // namespace rx |