Hash :
cfc4db34
Author :
Date :
2021-11-04T16:54:15
Metal: Provoking vertex support for Metal DrawArrays Add in provoking vertex rewrite support for drawArrays command, enabling 6 dEQP tests. GLES3/functional_rasterization_flatshading_line_loop GLES3/functional_rasterization_flatshading_line_strip GLES3/functional_rasterization_flatshading_lines GLES3/functional_rasterization_flatshading_triangle_fan GLES3/functional_rasterization_flatshading_triangle_strip GLES3/functional_rasterization_flatshading_triangles This patch adds a new shader to the Provoking Vertex helper that generates draw commands for all simple data types. Fix bug in provoking vertex helper that caused reused index buffers to suffer from allocation issues. Also fix Provoking vertex for triangle fan generation Bug: angleproject:5325 Change-Id: I7a1211dfcd99329868269ea0666eef1915d487b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3261635 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kyle Piddington <kpiddington@apple.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ProvokingVertexHelper.h:
// Manages re-writing index buffers when provoking vertex support is needed.
// Handles points, lines, triangles, line strips, and triangle strips.
// Line loops, and triangle fans should be pre-processed.
//
#ifndef LIBANGLE_RENDERER_METAL_PROVOKINGVERTEXHELPER_H
#define LIBANGLE_RENDERER_METAL_PROVOKINGVERTEXHELPER_H
#include "libANGLE/Context.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/metal/DisplayMtl.h"
#include "libANGLE/renderer/metal/mtl_buffer_pool.h"
#include "libANGLE/renderer/metal/mtl_command_buffer.h"
#include "libANGLE/renderer/metal/mtl_context_device.h"
#include "libANGLE/renderer/metal/mtl_state_cache.h"
namespace rx
{
class ContextMtl;
class ProvokingVertexHelper : public mtl::ProvokingVertexCacheSpecializeShaderFactory
{
public:
ProvokingVertexHelper(ContextMtl *context,
mtl::CommandQueue *commandQueue,
DisplayMtl *display);
mtl::BufferRef preconditionIndexBuffer(ContextMtl *context,
mtl::BufferRef indexBuffer,
size_t indexCount,
size_t indexOffset,
bool primitiveRestartEnabled,
gl::PrimitiveMode primitiveMode,
gl::DrawElementsType elementsType,
size_t &outIndexCount,
size_t &outIndexOffset,
gl::PrimitiveMode &outPrimitiveMode);
mtl::BufferRef generateIndexBuffer(ContextMtl *context,
size_t first,
size_t indexCount,
gl::PrimitiveMode primitiveMode,
gl::DrawElementsType elementsType,
size_t &outIndexCount,
size_t &outIndexOffset,
gl::PrimitiveMode &outPrimitiveMode);
void commitPreconditionCommandBuffer(ContextMtl *context);
void ensureCommandBufferReady();
void onDestroy(ContextMtl *context);
mtl::ComputeCommandEncoder *getComputeCommandEncoder();
private:
id<MTLLibrary> mProvokingVertexLibrary;
mtl::CommandBuffer mCommandBuffer;
mtl::BufferPool mIndexBuffers;
mtl::ProvokingVertexComputePipelineCache mPipelineCache;
mtl::ProvokingVertexComputePipelineDesc mCachedDesc;
mtl::ComputeCommandEncoder mCurrentEncoder;
// Program cache
virtual angle::Result getSpecializedShader(
rx::mtl::Context *context,
gl::ShaderType shaderType,
const mtl::ProvokingVertexComputePipelineDesc &renderPipelineDesc,
id<MTLFunction> *shaderOut) override;
// Private command buffer
virtual bool hasSpecializedShader(
gl::ShaderType shaderType,
const mtl::ProvokingVertexComputePipelineDesc &renderPipelineDesc) override;
void prepareCommandEncoderForDescriptor(ContextMtl *context,
mtl::ComputeCommandEncoder *encoder,
mtl::ProvokingVertexComputePipelineDesc desc);
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_PROVOKINGVERTEXHELPER_H */