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