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