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 | // VertexArrayVk.cpp: |
| 7 | // Implements the class methods for VertexArrayVk. |
| 8 | // |
| 9 | |
| 10 | #include "libANGLE/renderer/vulkan/VertexArrayVk.h" |
| 11 | |
| 12 | #include "common/debug.h" |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 13 | #include "common/utilities.h" |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 14 | #include "libANGLE/Context.h" |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 15 | #include "libANGLE/renderer/vulkan/BufferVk.h" |
Jamie Madill | 1f46bc1 | 2018-02-20 16:09:43 -0500 | [diff] [blame] | 16 | #include "libANGLE/renderer/vulkan/CommandGraph.h" |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 17 | #include "libANGLE/renderer/vulkan/ContextVk.h" |
Jamie Madill | 316c606 | 2018-05-29 10:49:45 -0400 | [diff] [blame] | 18 | #include "libANGLE/renderer/vulkan/FramebufferVk.h" |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 19 | #include "libANGLE/renderer/vulkan/RendererVk.h" |
Jamie Madill | 3c424b4 | 2018-01-19 12:35:09 -0500 | [diff] [blame] | 20 | #include "libANGLE/renderer/vulkan/vk_format_utils.h" |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 21 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 22 | namespace rx |
| 23 | { |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 24 | namespace |
| 25 | { |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 26 | constexpr size_t kDynamicVertexDataSize = 1024 * 1024; |
| 27 | constexpr size_t kDynamicIndexDataSize = 1024 * 8; |
| 28 | constexpr size_t kMaxVertexFormatAlignment = 4; |
| 29 | constexpr VkBufferUsageFlags kVertexBufferUsageFlags = |
| 30 | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 31 | constexpr VkBufferUsageFlags kIndexBufferUsageFlags = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | |
| 32 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | |
| 33 | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 34 | |
| 35 | bool BindingIsAligned(const gl::VertexBinding &binding, unsigned componentSize) |
| 36 | { |
| 37 | return (binding.getOffset() % componentSize == 0) && (binding.getStride() % componentSize == 0); |
| 38 | } |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 39 | |
| 40 | angle::Result StreamVertexData(ContextVk *contextVk, |
| 41 | vk::DynamicBuffer *dynamicBuffer, |
| 42 | const uint8_t *sourceData, |
| 43 | size_t bytesToAllocate, |
| 44 | size_t destOffset, |
| 45 | size_t vertexCount, |
| 46 | size_t stride, |
| 47 | VertexCopyFunction vertexLoadFunction, |
Shahbaz Youssefi | ec06305 | 2018-12-06 01:58:06 +0100 | [diff] [blame] | 48 | vk::BufferHelper **bufferOut, |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 49 | VkDeviceSize *bufferOffsetOut) |
| 50 | { |
| 51 | uint8_t *dst = nullptr; |
Shahbaz Youssefi | ec06305 | 2018-12-06 01:58:06 +0100 | [diff] [blame] | 52 | ANGLE_TRY(dynamicBuffer->allocate(contextVk, bytesToAllocate, &dst, nullptr, bufferOffsetOut, |
| 53 | nullptr)); |
| 54 | *bufferOut = dynamicBuffer->getCurrentBuffer(); |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 55 | dst += destOffset; |
| 56 | vertexLoadFunction(sourceData, stride, vertexCount, dst); |
| 57 | |
| 58 | ANGLE_TRY(dynamicBuffer->flush(contextVk)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 59 | return angle::Result::Continue; |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 60 | } |
jchen10 | 5dc0a6f | 2018-09-20 14:30:45 +0800 | [diff] [blame] | 61 | |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 62 | size_t GetVertexCount(BufferVk *srcBuffer, const gl::VertexBinding &binding, uint32_t srcFormatSize) |
| 63 | { |
| 64 | // Bytes usable for vertex data. |
| 65 | GLint64 bytes = srcBuffer->getSize() - binding.getOffset(); |
| 66 | if (bytes < srcFormatSize) |
| 67 | return 0; |
| 68 | |
| 69 | // Count the last vertex. It may occupy less than a full stride. |
| 70 | size_t numVertices = 1; |
| 71 | bytes -= srcFormatSize; |
| 72 | |
| 73 | // Count how many strides fit remaining space. |
| 74 | if (bytes > 0) |
| 75 | numVertices += static_cast<size_t>(bytes) / binding.getStride(); |
| 76 | |
| 77 | return numVertices; |
| 78 | } |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 79 | } // anonymous namespace |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 80 | |
Shahbaz Youssefi | 254b32c | 2018-11-26 11:58:03 -0500 | [diff] [blame] | 81 | #define INIT \ |
| 82 | { \ |
| 83 | kVertexBufferUsageFlags, 1024 * 8, true \ |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 84 | } |
| 85 | |
Luc Ferron | a9ab0f3 | 2018-05-17 17:03:55 -0400 | [diff] [blame] | 86 | VertexArrayVk::VertexArrayVk(const gl::VertexArrayState &state, RendererVk *renderer) |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 87 | : VertexArrayImpl(state), |
Jamie Madill | da854a2 | 2017-11-30 17:24:21 -0500 | [diff] [blame] | 88 | mCurrentArrayBufferHandles{}, |
Frank Henigman | 1744895 | 2017-01-05 15:48:26 -0500 | [diff] [blame] | 89 | mCurrentArrayBufferOffsets{}, |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 90 | mCurrentArrayBuffers{}, |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 91 | mCurrentArrayBufferFormats{}, |
| 92 | mCurrentArrayBufferStrides{}, |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 93 | mCurrentArrayBufferConversion{{ |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 94 | INIT, |
| 95 | INIT, |
| 96 | INIT, |
| 97 | INIT, |
| 98 | INIT, |
| 99 | INIT, |
| 100 | INIT, |
| 101 | INIT, |
| 102 | INIT, |
| 103 | INIT, |
| 104 | INIT, |
| 105 | INIT, |
| 106 | INIT, |
| 107 | INIT, |
| 108 | INIT, |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 109 | INIT, |
| 110 | }}, |
| 111 | mCurrentArrayBufferConversionCanRelease{}, |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 112 | mCurrentElementArrayBufferOffset(0), |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 113 | mCurrentElementArrayBuffer(nullptr), |
Jamie Madill | 77b2436 | 2018-11-05 22:39:29 -0500 | [diff] [blame] | 114 | mPackedInputBindings{}, |
| 115 | mPackedInputAttributes{}, |
Shahbaz Youssefi | 254b32c | 2018-11-26 11:58:03 -0500 | [diff] [blame] | 116 | mDynamicVertexData(kVertexBufferUsageFlags, kDynamicVertexDataSize, true), |
| 117 | mDynamicIndexData(kIndexBufferUsageFlags, kDynamicIndexDataSize, true), |
| 118 | mTranslatedByteIndexData(kIndexBufferUsageFlags, kDynamicIndexDataSize, true), |
Luc Ferron | a9ab0f3 | 2018-05-17 17:03:55 -0400 | [diff] [blame] | 119 | mLineLoopHelper(renderer), |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 120 | mDirtyLineLoopTranslation(true) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 121 | { |
Jamie Madill | da854a2 | 2017-11-30 17:24:21 -0500 | [diff] [blame] | 122 | mCurrentArrayBufferHandles.fill(VK_NULL_HANDLE); |
Frank Henigman | 1744895 | 2017-01-05 15:48:26 -0500 | [diff] [blame] | 123 | mCurrentArrayBufferOffsets.fill(0); |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 124 | mCurrentArrayBuffers.fill(nullptr); |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 125 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 126 | for (vk::DynamicBuffer &buffer : mCurrentArrayBufferConversion) |
| 127 | { |
jchen10 | 5dc0a6f | 2018-09-20 14:30:45 +0800 | [diff] [blame] | 128 | buffer.init(kMaxVertexFormatAlignment, renderer); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 129 | } |
jchen10 | 5dc0a6f | 2018-09-20 14:30:45 +0800 | [diff] [blame] | 130 | mDynamicVertexData.init(kMaxVertexFormatAlignment, renderer); |
Luc Ferron | a9ab0f3 | 2018-05-17 17:03:55 -0400 | [diff] [blame] | 131 | mDynamicIndexData.init(1, renderer); |
Luc Ferron | 6ed167a | 2018-06-13 13:45:55 -0400 | [diff] [blame] | 132 | mTranslatedByteIndexData.init(1, renderer); |
Jamie Madill | 0a17e48 | 2018-08-31 17:19:11 -0400 | [diff] [blame] | 133 | |
| 134 | // Initially consider all inputs dirty. |
| 135 | mDirtyPackedInputs.set(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 136 | } |
| 137 | |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 138 | VertexArrayVk::~VertexArrayVk() {} |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 139 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 140 | void VertexArrayVk::destroy(const gl::Context *context) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 141 | { |
Shahbaz Youssefi | fca8fd6 | 2018-11-13 13:55:48 -0500 | [diff] [blame] | 142 | RendererVk *renderer = vk::GetImpl(context)->getRenderer(); |
| 143 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 144 | for (vk::DynamicBuffer &buffer : mCurrentArrayBufferConversion) |
| 145 | { |
Shahbaz Youssefi | fca8fd6 | 2018-11-13 13:55:48 -0500 | [diff] [blame] | 146 | buffer.release(renderer); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 147 | } |
Shahbaz Youssefi | fca8fd6 | 2018-11-13 13:55:48 -0500 | [diff] [blame] | 148 | mDynamicVertexData.release(renderer); |
| 149 | mDynamicIndexData.release(renderer); |
| 150 | mTranslatedByteIndexData.release(renderer); |
| 151 | mLineLoopHelper.release(renderer); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 152 | } |
| 153 | |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 154 | angle::Result VertexArrayVk::streamIndexData(ContextVk *contextVk, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 155 | gl::DrawElementsType indexType, |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 156 | size_t indexCount, |
| 157 | const void *sourcePointer, |
| 158 | vk::DynamicBuffer *dynamicBuffer) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 159 | { |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 160 | ASSERT(!mState.getElementArrayBuffer() || indexType == gl::DrawElementsType::UnsignedByte); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 161 | |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 162 | dynamicBuffer->releaseRetainedBuffers(contextVk->getRenderer()); |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 163 | |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 164 | const size_t amount = sizeof(GLushort) * indexCount; |
| 165 | GLubyte *dst = nullptr; |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 166 | |
Shahbaz Youssefi | 4abdf74 | 2018-11-28 14:41:10 -0500 | [diff] [blame] | 167 | ANGLE_TRY(dynamicBuffer->allocate(contextVk, amount, &dst, nullptr, |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 168 | &mCurrentElementArrayBufferOffset, nullptr)); |
Shahbaz Youssefi | 4abdf74 | 2018-11-28 14:41:10 -0500 | [diff] [blame] | 169 | mCurrentElementArrayBuffer = dynamicBuffer->getCurrentBuffer(); |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 170 | if (indexType == gl::DrawElementsType::UnsignedByte) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 171 | { |
| 172 | // Unsigned bytes don't have direct support in Vulkan so we have to expand the |
| 173 | // memory to a GLushort. |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 174 | const GLubyte *in = static_cast<const GLubyte *>(sourcePointer); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 175 | GLushort *expandedDst = reinterpret_cast<GLushort *>(dst); |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 176 | for (size_t index = 0; index < indexCount; index++) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 177 | { |
| 178 | expandedDst[index] = static_cast<GLushort>(in[index]); |
| 179 | } |
| 180 | } |
| 181 | else |
| 182 | { |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 183 | memcpy(dst, sourcePointer, amount); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 184 | } |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 185 | ANGLE_TRY(dynamicBuffer->flush(contextVk)); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 186 | return angle::Result::Continue; |
Frank Henigman | 1744895 | 2017-01-05 15:48:26 -0500 | [diff] [blame] | 187 | } |
| 188 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 189 | // We assume the buffer is completely full of the same kind of data and convert |
| 190 | // and/or align it as we copy it to a DynamicBuffer. The assumption could be wrong |
| 191 | // but the alternative of copying it piecemeal on each draw would have a lot more |
| 192 | // overhead. |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 193 | angle::Result VertexArrayVk::convertVertexBufferGpu(ContextVk *contextVk, |
| 194 | BufferVk *srcBuffer, |
| 195 | const gl::VertexBinding &binding, |
| 196 | size_t attribIndex) |
| 197 | { |
| 198 | RendererVk *renderer = contextVk->getRenderer(); |
| 199 | |
| 200 | const angle::Format &srcFormat = mCurrentArrayBufferFormats[attribIndex]->angleFormat(); |
| 201 | const angle::Format &destFormat = mCurrentArrayBufferFormats[attribIndex]->bufferFormat(); |
| 202 | |
| 203 | ASSERT(binding.getStride() % (srcFormat.pixelBytes / srcFormat.channelCount()) == 0); |
| 204 | |
| 205 | unsigned srcFormatSize = srcFormat.pixelBytes; |
| 206 | unsigned destFormatSize = destFormat.pixelBytes; |
| 207 | |
| 208 | size_t numVertices = GetVertexCount(srcBuffer, binding, srcFormatSize); |
| 209 | if (numVertices == 0) |
| 210 | { |
| 211 | return angle::Result::Continue; |
| 212 | } |
| 213 | |
| 214 | ASSERT(GetVertexInputAlignment(*mCurrentArrayBufferFormats[attribIndex]) <= |
| 215 | kMaxVertexFormatAlignment); |
| 216 | |
| 217 | // Allocate buffer for results |
| 218 | mCurrentArrayBufferConversion[attribIndex].releaseRetainedBuffers(renderer); |
| 219 | ANGLE_TRY(mCurrentArrayBufferConversion[attribIndex].allocate( |
| 220 | contextVk, numVertices * destFormatSize, nullptr, nullptr, |
| 221 | &mCurrentArrayBufferOffsets[attribIndex], nullptr)); |
| 222 | mCurrentArrayBuffers[attribIndex] = |
| 223 | mCurrentArrayBufferConversion[attribIndex].getCurrentBuffer(); |
| 224 | |
Shahbaz Youssefi | e321940 | 2018-12-08 16:54:14 +0100 | [diff] [blame^] | 225 | UtilsVk::ConvertVertexParameters params; |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 226 | params.vertexCount = numVertices; |
| 227 | params.srcFormat = &srcFormat; |
| 228 | params.destFormat = &destFormat; |
| 229 | params.srcStride = binding.getStride(); |
| 230 | params.srcOffset = binding.getOffset(); |
| 231 | params.destOffset = static_cast<size_t>(mCurrentArrayBufferOffsets[attribIndex]); |
| 232 | |
Shahbaz Youssefi | e321940 | 2018-12-08 16:54:14 +0100 | [diff] [blame^] | 233 | ANGLE_TRY(renderer->getUtils().convertVertexBuffer(contextVk, mCurrentArrayBuffers[attribIndex], |
| 234 | &srcBuffer->getBuffer(), params)); |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 235 | |
| 236 | mCurrentArrayBufferHandles[attribIndex] = |
| 237 | mCurrentArrayBuffers[attribIndex]->getBuffer().getHandle(); |
| 238 | mCurrentArrayBufferConversionCanRelease[attribIndex] = true; |
| 239 | |
| 240 | return angle::Result::Continue; |
| 241 | } |
| 242 | |
| 243 | angle::Result VertexArrayVk::convertVertexBufferCpu(ContextVk *contextVk, |
| 244 | BufferVk *srcBuffer, |
| 245 | const gl::VertexBinding &binding, |
| 246 | size_t attribIndex) |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 247 | { |
Frank Henigman | 9d84ccb | 2018-09-12 18:09:02 -0400 | [diff] [blame] | 248 | // Needed before reading buffer or we could get stale data. |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 249 | ANGLE_TRY(contextVk->getRenderer()->finish(contextVk)); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 250 | |
| 251 | unsigned srcFormatSize = mCurrentArrayBufferFormats[attribIndex]->angleFormat().pixelBytes; |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 252 | unsigned dstFormatSize = mCurrentArrayBufferStrides[attribIndex]; |
| 253 | |
| 254 | mCurrentArrayBufferConversion[attribIndex].releaseRetainedBuffers(contextVk->getRenderer()); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 255 | |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 256 | size_t numVertices = GetVertexCount(srcBuffer, binding, srcFormatSize); |
| 257 | if (numVertices == 0) |
| 258 | { |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 259 | return angle::Result::Continue; |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 260 | } |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 261 | |
Jamie Madill | 77abad8 | 2018-10-25 17:03:48 -0400 | [diff] [blame] | 262 | void *src = nullptr; |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 263 | ANGLE_TRY(srcBuffer->mapImpl(contextVk, &src)); |
| 264 | const uint8_t *srcBytes = reinterpret_cast<const uint8_t *>(src); |
| 265 | srcBytes += binding.getOffset(); |
jchen10 | 5dc0a6f | 2018-09-20 14:30:45 +0800 | [diff] [blame] | 266 | ASSERT(GetVertexInputAlignment(*mCurrentArrayBufferFormats[attribIndex]) <= |
| 267 | kMaxVertexFormatAlignment); |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 268 | ANGLE_TRY(StreamVertexData(contextVk, &mCurrentArrayBufferConversion[attribIndex], srcBytes, |
| 269 | numVertices * dstFormatSize, 0, numVertices, binding.getStride(), |
| 270 | mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction, |
Shahbaz Youssefi | ec06305 | 2018-12-06 01:58:06 +0100 | [diff] [blame] | 271 | &mCurrentArrayBuffers[attribIndex], |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 272 | &mCurrentArrayBufferOffsets[attribIndex])); |
| 273 | ANGLE_TRY(srcBuffer->unmapImpl(contextVk)); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 274 | |
Shahbaz Youssefi | ec06305 | 2018-12-06 01:58:06 +0100 | [diff] [blame] | 275 | mCurrentArrayBufferHandles[attribIndex] = |
| 276 | mCurrentArrayBuffers[attribIndex]->getBuffer().getHandle(); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 277 | mCurrentArrayBufferConversionCanRelease[attribIndex] = true; |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 278 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 279 | return angle::Result::Continue; |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | void VertexArrayVk::ensureConversionReleased(RendererVk *renderer, size_t attribIndex) |
| 283 | { |
| 284 | if (mCurrentArrayBufferConversionCanRelease[attribIndex]) |
| 285 | { |
| 286 | mCurrentArrayBufferConversion[attribIndex].release(renderer); |
| 287 | mCurrentArrayBufferConversionCanRelease[attribIndex] = false; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | #define ANGLE_VERTEX_DIRTY_ATTRIB_FUNC(INDEX) \ |
| 292 | case gl::VertexArray::DIRTY_BIT_ATTRIB_0 + INDEX: \ |
| 293 | ANGLE_TRY(syncDirtyAttrib(contextVk, attribs[INDEX], \ |
| 294 | bindings[attribs[INDEX].bindingIndex], INDEX)); \ |
Jamie Madill | bc5834c | 2018-11-06 11:13:50 -0500 | [diff] [blame] | 295 | invalidateContext = true; \ |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 296 | break; |
| 297 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 298 | #define ANGLE_VERTEX_DIRTY_BINDING_FUNC(INDEX) \ |
| 299 | case gl::VertexArray::DIRTY_BIT_BINDING_0 + INDEX: \ |
| 300 | ANGLE_TRY(syncDirtyAttrib(contextVk, attribs[INDEX], \ |
| 301 | bindings[attribs[INDEX].bindingIndex], INDEX)); \ |
Jamie Madill | bc5834c | 2018-11-06 11:13:50 -0500 | [diff] [blame] | 302 | invalidateContext = true; \ |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 303 | break; |
| 304 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 305 | #define ANGLE_VERTEX_DIRTY_BUFFER_DATA_FUNC(INDEX) \ |
| 306 | case gl::VertexArray::DIRTY_BIT_BUFFER_DATA_0 + INDEX: \ |
| 307 | ANGLE_TRY(syncDirtyAttrib(contextVk, attribs[INDEX], \ |
| 308 | bindings[attribs[INDEX].bindingIndex], INDEX)); \ |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 309 | break; |
| 310 | |
Jamie Madill | 6f755b2 | 2018-10-09 12:48:54 -0400 | [diff] [blame] | 311 | angle::Result VertexArrayVk::syncState(const gl::Context *context, |
| 312 | const gl::VertexArray::DirtyBits &dirtyBits, |
| 313 | const gl::VertexArray::DirtyAttribBitsArray &attribBits, |
| 314 | const gl::VertexArray::DirtyBindingBitsArray &bindingBits) |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 315 | { |
| 316 | ASSERT(dirtyBits.any()); |
Jamie Madill | 7210656 | 2017-03-24 14:18:50 -0400 | [diff] [blame] | 317 | |
Jamie Madill | bc5834c | 2018-11-06 11:13:50 -0500 | [diff] [blame] | 318 | bool invalidateContext = false; |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 319 | |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 320 | ContextVk *contextVk = vk::GetImpl(context); |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 321 | |
| 322 | // Rebuild current attribute buffers cache. This will fail horribly if the buffer changes. |
| 323 | // TODO(jmadill): Handle buffer storage changes. |
| 324 | const auto &attribs = mState.getVertexAttributes(); |
| 325 | const auto &bindings = mState.getVertexBindings(); |
| 326 | |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 327 | for (size_t dirtyBit : dirtyBits) |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 328 | { |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 329 | switch (dirtyBit) |
Jamie Madill | da854a2 | 2017-11-30 17:24:21 -0500 | [diff] [blame] | 330 | { |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 331 | case gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER: |
Jamie Madill | da854a2 | 2017-11-30 17:24:21 -0500 | [diff] [blame] | 332 | { |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 333 | gl::Buffer *bufferGL = mState.getElementArrayBuffer(); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 334 | if (bufferGL) |
| 335 | { |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 336 | BufferVk *bufferVk = vk::GetImpl(bufferGL); |
| 337 | mCurrentElementArrayBuffer = &bufferVk->getBuffer(); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 338 | } |
| 339 | else |
| 340 | { |
Shahbaz Youssefi | 4abdf74 | 2018-11-28 14:41:10 -0500 | [diff] [blame] | 341 | mCurrentElementArrayBuffer = nullptr; |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 342 | } |
Luc Ferron | 387b3b3 | 2018-05-28 10:11:57 -0400 | [diff] [blame] | 343 | |
| 344 | mCurrentElementArrayBufferOffset = 0; |
| 345 | mLineLoopBufferFirstIndex.reset(); |
| 346 | mLineLoopBufferLastIndex.reset(); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 347 | contextVk->setIndexBufferDirty(); |
Jamie Madill | b8e3966 | 2018-04-04 11:41:42 -0400 | [diff] [blame] | 348 | mDirtyLineLoopTranslation = true; |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 349 | break; |
Jamie Madill | da854a2 | 2017-11-30 17:24:21 -0500 | [diff] [blame] | 350 | } |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 351 | |
| 352 | case gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA: |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 353 | mLineLoopBufferFirstIndex.reset(); |
| 354 | mLineLoopBufferLastIndex.reset(); |
Jamie Madill | b8e3966 | 2018-04-04 11:41:42 -0400 | [diff] [blame] | 355 | mDirtyLineLoopTranslation = true; |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 356 | break; |
| 357 | |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 358 | ANGLE_VERTEX_INDEX_CASES(ANGLE_VERTEX_DIRTY_ATTRIB_FUNC); |
| 359 | ANGLE_VERTEX_INDEX_CASES(ANGLE_VERTEX_DIRTY_BINDING_FUNC); |
| 360 | ANGLE_VERTEX_INDEX_CASES(ANGLE_VERTEX_DIRTY_BUFFER_DATA_FUNC); |
| 361 | |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 362 | default: |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 363 | UNREACHABLE(); |
Jamie Madill | 0946393 | 2018-04-04 05:26:59 -0400 | [diff] [blame] | 364 | break; |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 365 | } |
| 366 | } |
Frank Henigman | 0af5b86 | 2018-03-27 20:19:33 -0400 | [diff] [blame] | 367 | |
Jamie Madill | bc5834c | 2018-11-06 11:13:50 -0500 | [diff] [blame] | 368 | if (invalidateContext) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 369 | { |
Jamie Madill | bc5834c | 2018-11-06 11:13:50 -0500 | [diff] [blame] | 370 | contextVk->invalidateVertexAndIndexBuffers(); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 371 | } |
| 372 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 373 | return angle::Result::Continue; |
Jamie Madill | bd159f0 | 2017-10-09 19:39:06 -0400 | [diff] [blame] | 374 | } |
| 375 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 376 | angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk, |
| 377 | const gl::VertexAttribute &attrib, |
| 378 | const gl::VertexBinding &binding, |
| 379 | size_t attribIndex) |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 380 | { |
| 381 | // Invalidate the input description for pipelines. |
| 382 | mDirtyPackedInputs.set(attribIndex); |
| 383 | |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 384 | RendererVk *renderer = contextVk->getRenderer(); |
| 385 | bool releaseConversion = true; |
| 386 | bool anyVertexBufferConvertedOnGpu = false; |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 387 | |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 388 | if (attrib.enabled) |
| 389 | { |
Frank Henigman | 67c388e | 2018-07-19 19:16:11 -0400 | [diff] [blame] | 390 | gl::Buffer *bufferGL = binding.getBuffer().get(); |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 391 | mCurrentArrayBufferFormats[attribIndex] = &renderer->getFormat(GetVertexFormatID(attrib)); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 392 | |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 393 | if (bufferGL) |
| 394 | { |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 395 | BufferVk *bufferVk = vk::GetImpl(bufferGL); |
| 396 | unsigned componentSize = |
| 397 | mCurrentArrayBufferFormats[attribIndex]->angleFormat().pixelBytes / attrib.size; |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 398 | bool bindingIsAligned = BindingIsAligned(binding, componentSize); |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 399 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 400 | if (mCurrentArrayBufferFormats[attribIndex]->vertexLoadRequiresConversion || |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 401 | !bindingIsAligned) |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 402 | { |
Jamie Madill | a064c27 | 2018-08-30 16:18:34 -0400 | [diff] [blame] | 403 | mCurrentArrayBufferStrides[attribIndex] = |
| 404 | mCurrentArrayBufferFormats[attribIndex]->bufferFormat().pixelBytes; |
| 405 | |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 406 | if (bindingIsAligned) |
| 407 | { |
| 408 | ANGLE_TRY(convertVertexBufferGpu(contextVk, bufferVk, binding, attribIndex)); |
| 409 | anyVertexBufferConvertedOnGpu = true; |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | // TODO(syoussefi): Implement unaligned vertex buffer conversions in compute. |
| 414 | // http://anglebug.com/3009 |
| 415 | ANGLE_TRY(convertVertexBufferCpu(contextVk, bufferVk, binding, attribIndex)); |
| 416 | } |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 417 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 418 | releaseConversion = false; |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 419 | } |
| 420 | else |
| 421 | { |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 422 | mCurrentArrayBuffers[attribIndex] = &bufferVk->getBuffer(); |
Jamie Madill | 2d03ff4 | 2018-09-27 15:04:26 -0400 | [diff] [blame] | 423 | mCurrentArrayBufferHandles[attribIndex] = |
| 424 | bufferVk->getBuffer().getBuffer().getHandle(); |
Jamie Madill | 77abad8 | 2018-10-25 17:03:48 -0400 | [diff] [blame] | 425 | mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset(); |
| 426 | mCurrentArrayBufferStrides[attribIndex] = binding.getStride(); |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 427 | } |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 428 | } |
| 429 | else |
| 430 | { |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 431 | mCurrentArrayBuffers[attribIndex] = nullptr; |
| 432 | mCurrentArrayBufferHandles[attribIndex] = VK_NULL_HANDLE; |
| 433 | mCurrentArrayBufferOffsets[attribIndex] = 0; |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 434 | mCurrentArrayBufferStrides[attribIndex] = |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 435 | mCurrentArrayBufferFormats[attribIndex]->bufferFormat().pixelBytes; |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 436 | } |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 437 | } |
| 438 | else |
| 439 | { |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 440 | contextVk->invalidateDefaultAttribute(attribIndex); |
| 441 | |
| 442 | // These will be filled out by the ContextVk. |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 443 | mCurrentArrayBuffers[attribIndex] = nullptr; |
| 444 | mCurrentArrayBufferHandles[attribIndex] = VK_NULL_HANDLE; |
| 445 | mCurrentArrayBufferOffsets[attribIndex] = 0; |
| 446 | mCurrentArrayBufferStrides[attribIndex] = 0; |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 447 | mCurrentArrayBufferFormats[attribIndex] = |
Jamie Madill | ba36593 | 2018-07-18 17:23:46 -0400 | [diff] [blame] | 448 | &renderer->getFormat(angle::FormatID::R32G32B32A32_FLOAT); |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 449 | } |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 450 | |
Shahbaz Youssefi | 611bbaa | 2018-12-06 01:59:53 +0100 | [diff] [blame] | 451 | if (anyVertexBufferConvertedOnGpu && renderer->getFeatures().flushAfterVertexConversion) |
| 452 | { |
| 453 | ANGLE_TRY(renderer->flush(contextVk)); |
| 454 | } |
| 455 | |
Frank Henigman | e452382 | 2018-07-19 16:10:53 -0400 | [diff] [blame] | 456 | if (releaseConversion) |
| 457 | ensureConversionReleased(renderer, attribIndex); |
| 458 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 459 | return angle::Result::Continue; |
Jamie Madill | a56467e | 2018-04-11 16:19:41 -0400 | [diff] [blame] | 460 | } |
| 461 | |
Shahbaz Youssefi | c30f45d | 2018-11-12 16:37:59 -0500 | [diff] [blame] | 462 | void VertexArrayVk::getPackedInputDescriptions(vk::GraphicsPipelineDesc *pipelineDesc) |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 463 | { |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 464 | updatePackedInputDescriptions(); |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 465 | pipelineDesc->updateVertexInputInfo(mPackedInputBindings, mPackedInputAttributes); |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 466 | } |
| 467 | |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 468 | void VertexArrayVk::updatePackedInputDescriptions() |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 469 | { |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 470 | if (!mDirtyPackedInputs.any()) |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 471 | { |
| 472 | return; |
| 473 | } |
| 474 | |
| 475 | const auto &attribs = mState.getVertexAttributes(); |
| 476 | const auto &bindings = mState.getVertexBindings(); |
| 477 | |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 478 | for (auto attribIndex : mDirtyPackedInputs) |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 479 | { |
| 480 | const auto &attrib = attribs[attribIndex]; |
| 481 | const auto &binding = bindings[attrib.bindingIndex]; |
| 482 | if (attrib.enabled) |
| 483 | { |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 484 | updatePackedInputInfo(static_cast<uint32_t>(attribIndex), binding, attrib); |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 485 | } |
| 486 | else |
| 487 | { |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 488 | vk::PackedVertexInputBindingDesc &bindingDesc = mPackedInputBindings[attribIndex]; |
| 489 | bindingDesc.stride = 0; |
| 490 | bindingDesc.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; |
| 491 | |
Jamie Madill | 77b2436 | 2018-11-05 22:39:29 -0500 | [diff] [blame] | 492 | mPackedInputAttributes.formats[attribIndex] = |
| 493 | static_cast<uint16_t>(VK_FORMAT_R32G32B32A32_SFLOAT); |
| 494 | mPackedInputAttributes.offsets[attribIndex] = 0; |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 495 | } |
| 496 | } |
| 497 | |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 498 | mDirtyPackedInputs.reset(); |
| 499 | } |
| 500 | |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 501 | void VertexArrayVk::updatePackedInputInfo(uint32_t attribIndex, |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 502 | const gl::VertexBinding &binding, |
| 503 | const gl::VertexAttribute &attrib) |
| 504 | { |
| 505 | vk::PackedVertexInputBindingDesc &bindingDesc = mPackedInputBindings[attribIndex]; |
| 506 | |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 507 | bindingDesc.stride = static_cast<uint16_t>(mCurrentArrayBufferStrides[attribIndex]); |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 508 | bindingDesc.inputRate = static_cast<uint16_t>( |
| 509 | binding.getDivisor() > 0 ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX); |
| 510 | |
Frank Henigman | 419acc8 | 2018-06-24 19:57:31 -0400 | [diff] [blame] | 511 | VkFormat vkFormat = mCurrentArrayBufferFormats[attribIndex]->vkBufferFormat; |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 512 | ASSERT(vkFormat <= std::numeric_limits<uint16_t>::max()); |
Frank Henigman | 8c379f3 | 2018-06-21 19:55:05 -0400 | [diff] [blame] | 513 | if (vkFormat == VK_FORMAT_UNDEFINED) |
| 514 | { |
Frank Henigman | 8c379f3 | 2018-06-21 19:55:05 -0400 | [diff] [blame] | 515 | UNIMPLEMENTED(); |
| 516 | } |
Jamie Madill | 112a3a8 | 2018-01-23 13:04:06 -0500 | [diff] [blame] | 517 | |
Jamie Madill | 77b2436 | 2018-11-05 22:39:29 -0500 | [diff] [blame] | 518 | mPackedInputAttributes.formats[attribIndex] = static_cast<uint8_t>(vkFormat); |
| 519 | mPackedInputAttributes.offsets[attribIndex] = static_cast<uint16_t>(attrib.relativeOffset); |
Jamie Madill | ebf7299 | 2017-10-13 14:09:45 -0400 | [diff] [blame] | 520 | } |
| 521 | |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 522 | angle::Result VertexArrayVk::updateClientAttribs(const gl::Context *context, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 523 | GLint firstVertex, |
| 524 | GLsizei vertexOrIndexCount, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 525 | gl::DrawElementsType indexTypeOrInvalid, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 526 | const void *indices) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 527 | { |
Jamie Madill | 77abad8 | 2018-10-25 17:03:48 -0400 | [diff] [blame] | 528 | ContextVk *contextVk = vk::GetImpl(context); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 529 | const gl::AttributesMask &clientAttribs = context->getStateCache().getActiveClientAttribsMask(); |
Jamie Madill | 2106102 | 2018-07-12 23:56:30 -0400 | [diff] [blame] | 530 | |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 531 | ASSERT(clientAttribs.any()); |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 532 | |
| 533 | GLint startVertex; |
| 534 | size_t vertexCount; |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 535 | ANGLE_TRY(GetVertexRangeInfo(context, firstVertex, vertexOrIndexCount, indexTypeOrInvalid, |
| 536 | indices, 0, &startVertex, &vertexCount)); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 537 | |
| 538 | mDynamicVertexData.releaseRetainedBuffers(contextVk->getRenderer()); |
| 539 | |
| 540 | const auto &attribs = mState.getVertexAttributes(); |
| 541 | const auto &bindings = mState.getVertexBindings(); |
| 542 | |
| 543 | // TODO(fjhenigman): When we have a bunch of interleaved attributes, they end up |
| 544 | // un-interleaved, wasting space and copying time. Consider improving on that. |
| 545 | for (size_t attribIndex : clientAttribs) |
| 546 | { |
| 547 | const gl::VertexAttribute &attrib = attribs[attribIndex]; |
| 548 | const gl::VertexBinding &binding = bindings[attrib.bindingIndex]; |
| 549 | ASSERT(attrib.enabled && binding.getBuffer().get() == nullptr); |
| 550 | |
| 551 | const size_t bytesToAllocate = |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 552 | (startVertex + vertexCount) * mCurrentArrayBufferStrides[attribIndex]; |
| 553 | const uint8_t *src = |
| 554 | static_cast<const uint8_t *>(attrib.pointer) + startVertex * binding.getStride(); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 555 | |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 556 | size_t destOffset = startVertex * mCurrentArrayBufferStrides[attribIndex]; |
jchen10 | 5dc0a6f | 2018-09-20 14:30:45 +0800 | [diff] [blame] | 557 | ASSERT(GetVertexInputAlignment(*mCurrentArrayBufferFormats[attribIndex]) <= |
| 558 | kMaxVertexFormatAlignment); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 559 | |
| 560 | // Only vertexCount() vertices will be used by the upcoming draw. so that is all we copy. |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 561 | // We allocate space for startVertex + vertexCount so indexing will work. If we |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 562 | // don't start at zero all the indices will be off. |
| 563 | // TODO(fjhenigman): See if we can account for indices being off by adjusting the |
| 564 | // offset, thus avoiding wasted memory. |
Jamie Madill | c1fd737 | 2018-10-26 22:48:39 -0400 | [diff] [blame] | 565 | ANGLE_TRY(StreamVertexData( |
| 566 | contextVk, &mDynamicVertexData, src, bytesToAllocate, destOffset, vertexCount, |
| 567 | binding.getStride(), mCurrentArrayBufferFormats[attribIndex]->vertexLoadFunction, |
Shahbaz Youssefi | ec06305 | 2018-12-06 01:58:06 +0100 | [diff] [blame] | 568 | &mCurrentArrayBuffers[attribIndex], &mCurrentArrayBufferOffsets[attribIndex])); |
| 569 | mCurrentArrayBufferHandles[attribIndex] = |
| 570 | mCurrentArrayBuffers[attribIndex]->getBuffer().getHandle(); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 571 | } |
| 572 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 573 | return angle::Result::Continue; |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | angle::Result VertexArrayVk::handleLineLoop(ContextVk *contextVk, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 577 | GLint firstVertex, |
| 578 | GLsizei vertexOrIndexCount, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 579 | gl::DrawElementsType indexTypeOrInvalid, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 580 | const void *indices) |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 581 | { |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 582 | if (indexTypeOrInvalid != gl::DrawElementsType::InvalidEnum) |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 583 | { |
| 584 | // Handle GL_LINE_LOOP drawElements. |
| 585 | if (mDirtyLineLoopTranslation) |
| 586 | { |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 587 | gl::Buffer *elementArrayBuffer = mState.getElementArrayBuffer(); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 588 | |
| 589 | if (!elementArrayBuffer) |
| 590 | { |
Frank Henigman | 85c4b43 | 2018-09-19 23:35:00 -0400 | [diff] [blame] | 591 | ANGLE_TRY(mLineLoopHelper.streamIndices( |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 592 | contextVk, indexTypeOrInvalid, vertexOrIndexCount, |
Shahbaz Youssefi | 4abdf74 | 2018-11-28 14:41:10 -0500 | [diff] [blame] | 593 | reinterpret_cast<const uint8_t *>(indices), &mCurrentElementArrayBuffer, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 594 | &mCurrentElementArrayBufferOffset)); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 595 | } |
| 596 | else |
| 597 | { |
| 598 | // When using an element array buffer, 'indices' is an offset to the first element. |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 599 | intptr_t offset = reinterpret_cast<intptr_t>(indices); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 600 | BufferVk *elementArrayBufferVk = vk::GetImpl(elementArrayBuffer); |
| 601 | ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer( |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 602 | contextVk, elementArrayBufferVk, indexTypeOrInvalid, vertexOrIndexCount, offset, |
Shahbaz Youssefi | 4abdf74 | 2018-11-28 14:41:10 -0500 | [diff] [blame] | 603 | &mCurrentElementArrayBuffer, &mCurrentElementArrayBufferOffset)); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 604 | } |
| 605 | } |
| 606 | |
| 607 | // If we've had a drawArrays call with a line loop before, we want to make sure this is |
| 608 | // invalidated the next time drawArrays is called since we use the same index buffer for |
| 609 | // both calls. |
| 610 | mLineLoopBufferFirstIndex.reset(); |
| 611 | mLineLoopBufferLastIndex.reset(); |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 612 | return angle::Result::Continue; |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 613 | } |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 614 | |
Jamie Madill | 18e323a | 2018-05-11 16:54:17 -0400 | [diff] [blame] | 615 | // Note: Vertex indexes can be arbitrarily large. |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 616 | uint32_t clampedVertexCount = gl::clampCast<uint32_t>(vertexOrIndexCount); |
Jamie Madill | 18e323a | 2018-05-11 16:54:17 -0400 | [diff] [blame] | 617 | |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 618 | // Handle GL_LINE_LOOP drawArrays. |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 619 | size_t lastVertex = static_cast<size_t>(firstVertex + clampedVertexCount); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 620 | if (!mLineLoopBufferFirstIndex.valid() || !mLineLoopBufferLastIndex.valid() || |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 621 | mLineLoopBufferFirstIndex != firstVertex || mLineLoopBufferLastIndex != lastVertex) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 622 | { |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 623 | ANGLE_TRY(mLineLoopHelper.getIndexBufferForDrawArrays( |
Shahbaz Youssefi | 4abdf74 | 2018-11-28 14:41:10 -0500 | [diff] [blame] | 624 | contextVk, clampedVertexCount, firstVertex, &mCurrentElementArrayBuffer, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 625 | &mCurrentElementArrayBufferOffset)); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 626 | |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 627 | mLineLoopBufferFirstIndex = firstVertex; |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 628 | mLineLoopBufferLastIndex = lastVertex; |
| 629 | } |
| 630 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 631 | return angle::Result::Continue; |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 632 | } |
| 633 | |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 634 | angle::Result VertexArrayVk::updateIndexTranslation(ContextVk *contextVk, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 635 | GLsizei indexCount, |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 636 | gl::DrawElementsType type, |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 637 | const void *indices) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 638 | { |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 639 | ASSERT(type != gl::DrawElementsType::InvalidEnum); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 640 | |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 641 | RendererVk *renderer = contextVk->getRenderer(); |
Jamie Madill | cd0a0a3 | 2018-10-18 18:41:57 -0400 | [diff] [blame] | 642 | gl::Buffer *glBuffer = mState.getElementArrayBuffer(); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 643 | |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 644 | if (!glBuffer) |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 645 | { |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 646 | ANGLE_TRY(streamIndexData(contextVk, type, indexCount, indices, &mDynamicIndexData)); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 647 | } |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 648 | else if (renderer->getFormat(angle::FormatID::R16_UINT).vkSupportsStorageBuffer) |
| 649 | { |
| 650 | BufferVk *bufferVk = vk::GetImpl(glBuffer); |
| 651 | |
| 652 | ASSERT(type == gl::DrawElementsType::UnsignedByte); |
| 653 | |
| 654 | intptr_t offsetIntoSrcData = reinterpret_cast<intptr_t>(indices); |
| 655 | size_t srcDataSize = static_cast<size_t>(bufferVk->getSize()) - offsetIntoSrcData; |
| 656 | |
| 657 | mTranslatedByteIndexData.releaseRetainedBuffers(renderer); |
| 658 | |
| 659 | ANGLE_TRY(mTranslatedByteIndexData.allocate(contextVk, sizeof(GLushort) * srcDataSize, |
| 660 | nullptr, nullptr, |
| 661 | &mCurrentElementArrayBufferOffset, nullptr)); |
| 662 | mCurrentElementArrayBuffer = mTranslatedByteIndexData.getCurrentBuffer(); |
| 663 | |
| 664 | vk::BufferHelper *dest = mTranslatedByteIndexData.getCurrentBuffer(); |
| 665 | vk::BufferHelper *src = &bufferVk->getBuffer(); |
| 666 | |
| 667 | ANGLE_TRY(src->initBufferView(contextVk, renderer->getFormat(angle::FormatID::R8_UINT))); |
| 668 | ANGLE_TRY(dest->initBufferView(contextVk, renderer->getFormat(angle::FormatID::R16_UINT))); |
| 669 | |
| 670 | // Copy relevant section of the source into destination at allocated offset. Note that the |
| 671 | // offset returned by allocate() above is in bytes, while our allocated array is of |
| 672 | // GLushorts. |
Shahbaz Youssefi | e321940 | 2018-12-08 16:54:14 +0100 | [diff] [blame^] | 673 | UtilsVk::CopyParameters params = {}; |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 674 | params.destOffset = |
| 675 | static_cast<size_t>(mCurrentElementArrayBufferOffset) / sizeof(GLushort); |
| 676 | params.srcOffset = offsetIntoSrcData; |
| 677 | params.size = srcDataSize; |
| 678 | |
| 679 | // Note: this is a copy, which implicitly converts between formats. Once support for |
| 680 | // primitive restart is added, a specialized shader is likely needed to special case 0xFF -> |
| 681 | // 0xFFFF. |
Shahbaz Youssefi | e321940 | 2018-12-08 16:54:14 +0100 | [diff] [blame^] | 682 | ANGLE_TRY(renderer->getUtils().copyBuffer(contextVk, dest, src, params)); |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 683 | } |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 684 | else |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 685 | { |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 686 | // If it's not possible to convert the buffer with compute, opt for a CPU read back for now. |
| 687 | // TODO(syoussefi): R8G8B8A8_UINT is required to have storage texel buffer support, so a |
| 688 | // specialized shader code can be made to read two ubyte indices and output them in R and B |
| 689 | // (or A and G based on endianness?) with 0 on the other channels. If specialized, we might |
| 690 | // as well support the ubyte to ushort case with correct handling of primitive restart. |
| 691 | // http://anglebug.com/3003 |
| 692 | |
Frank Henigman | 9d84ccb | 2018-09-12 18:09:02 -0400 | [diff] [blame] | 693 | // Needed before reading buffer or we could get stale data. |
Shahbaz Youssefi | 8f1b7a6 | 2018-11-14 16:02:54 -0500 | [diff] [blame] | 694 | ANGLE_TRY(renderer->finish(contextVk)); |
Frank Henigman | 9d84ccb | 2018-09-12 18:09:02 -0400 | [diff] [blame] | 695 | |
Jamie Madill | 8dc27f9 | 2018-11-29 11:45:44 -0500 | [diff] [blame] | 696 | ASSERT(type == gl::DrawElementsType::UnsignedByte); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 697 | // Unsigned bytes don't have direct support in Vulkan so we have to expand the |
| 698 | // memory to a GLushort. |
| 699 | BufferVk *bufferVk = vk::GetImpl(glBuffer); |
| 700 | void *srcDataMapping = nullptr; |
| 701 | ASSERT(!glBuffer->isMapped()); |
| 702 | ANGLE_TRY(bufferVk->mapImpl(contextVk, &srcDataMapping)); |
| 703 | uint8_t *srcData = static_cast<uint8_t *>(srcDataMapping); |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 704 | intptr_t offsetIntoSrcData = reinterpret_cast<intptr_t>(indices); |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 705 | srcData += offsetIntoSrcData; |
Jamie Madill | 253038d | 2018-08-30 16:18:35 -0400 | [diff] [blame] | 706 | |
Jamie Madill | bfe31c4 | 2018-10-25 17:03:47 -0400 | [diff] [blame] | 707 | ANGLE_TRY(streamIndexData(contextVk, type, |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 708 | static_cast<size_t>(bufferVk->getSize()) - offsetIntoSrcData, |
| 709 | srcData, &mTranslatedByteIndexData)); |
Luc Ferron | 6ed167a | 2018-06-13 13:45:55 -0400 | [diff] [blame] | 710 | |
Jamie Madill | 88fc6da | 2018-08-30 16:18:36 -0400 | [diff] [blame] | 711 | ANGLE_TRY(bufferVk->unmapImpl(contextVk)); |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 712 | } |
| 713 | |
Jamie Madill | 7c985f5 | 2018-11-29 18:16:17 -0500 | [diff] [blame] | 714 | return angle::Result::Continue; |
Jamie Madill | c3755fc | 2018-04-05 08:39:13 -0400 | [diff] [blame] | 715 | } |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 716 | |
| 717 | void VertexArrayVk::updateDefaultAttrib(RendererVk *renderer, |
| 718 | size_t attribIndex, |
| 719 | VkBuffer bufferHandle, |
| 720 | uint32_t offset) |
| 721 | { |
| 722 | if (!mState.getEnabledAttributesMask().test(attribIndex)) |
| 723 | { |
Jamie Madill | 03d1a5e | 2018-11-12 11:34:24 -0500 | [diff] [blame] | 724 | mCurrentArrayBufferHandles[attribIndex] = bufferHandle; |
| 725 | mCurrentArrayBufferOffsets[attribIndex] = offset; |
| 726 | mCurrentArrayBuffers[attribIndex] = nullptr; |
| 727 | mCurrentArrayBufferStrides[attribIndex] = 0; |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 728 | mCurrentArrayBufferFormats[attribIndex] = |
Jamie Madill | ba36593 | 2018-07-18 17:23:46 -0400 | [diff] [blame] | 729 | &renderer->getFormat(angle::FormatID::R32G32B32A32_FIXED); |
Jamie Madill | 5a4c932 | 2018-07-16 11:01:58 -0400 | [diff] [blame] | 730 | mDirtyPackedInputs.set(attribIndex); |
| 731 | } |
| 732 | } |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 733 | } // namespace rx |