Hash :
611bbaab
Author :
Date :
2018-12-06T01:59:53
Vulkan: Convert vertex attributes in compute In this commit, VertexArrayVk::convertVertexBuffer() is renamed to VertexArrayVk::convertVertexBufferCpu() to explicitly show it does a CPU readback. A new VertexArrayVk::convertVertexBuffer() function is added that has the same functionality in gpu (with some assumptions, where the CPU fallback is used should those assumptions fail). Currently, the only requirement is that buffer offset/stride are divided by the component size. ConvertVertex.comp is the shader responsible for this conversion, and it implements the functionality in renderer/copyvertex.inc, minus a few functions that are not used in the Vulkan backend. Bug: angleproject:2958, angleproject:3009 Change-Id: I8ec9a5f4672509bcf7b9e352cd27663970ad4653 Reviewed-on: https://chromium-review.googlesource.com/c/1364451 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
//
// Copyright 2016 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.
//
// Format:
// A universal description of typed GPU storage. Across multiple
// renderer back-ends, there are common formats and some distinct
// permutations, this enum encapsulates them all. Formats apply to
// textures, but could also apply to any typed data.
#ifndef LIBANGLE_RENDERER_FORMAT_H_
#define LIBANGLE_RENDERER_FORMAT_H_
#include "libANGLE/renderer/renderer_utils.h"
namespace angle
{
enum class FormatID;
struct Format final : private angle::NonCopyable
{
constexpr Format(FormatID id,
GLenum glFormat,
GLenum fboFormat,
rx::MipGenerationFunction mipGen,
const rx::FastCopyFunctionMap &fastCopyFunctions,
rx::PixelReadFunction colorRead,
rx::PixelWriteFunction colorWrite,
GLenum componentType,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint depthBits,
GLuint stencilBits,
GLuint pixelBytes,
bool isBlock,
bool isFixed);
static const Format &Get(FormatID id);
static FormatID InternalFormatToID(GLenum internalFormat);
constexpr bool hasDepthOrStencilBits() const;
constexpr GLuint channelCount() const;
bool operator==(const Format &other) const { return this->id == other.id; }
FormatID id;
// The closest matching GL internal format for the storage this format uses. Note that this
// may be a different internal format than the one this ANGLE format is used for.
GLenum glInternalFormat;
// The format we should report to the GL layer when querying implementation formats from a FBO.
// This might not be the same as the glInternalFormat, since some DXGI formats don't have
// matching GL format enums, like BGRA4, BGR5A1 and B5G6R6.
GLenum fboImplementationInternalFormat;
rx::MipGenerationFunction mipGenerationFunction;
rx::PixelReadFunction pixelReadFunction;
rx::PixelWriteFunction pixelWriteFunction;
// A map from a gl::FormatType to a fast pixel copy function for this format.
const rx::FastCopyFunctionMap &fastCopyFunctions;
GLenum componentType;
GLuint redBits;
GLuint greenBits;
GLuint blueBits;
GLuint alphaBits;
GLuint depthBits;
GLuint stencilBits;
GLuint pixelBytes;
bool isBlock;
bool isFixed;
};
constexpr Format::Format(FormatID id,
GLenum glFormat,
GLenum fboFormat,
rx::MipGenerationFunction mipGen,
const rx::FastCopyFunctionMap &fastCopyFunctions,
rx::PixelReadFunction colorRead,
rx::PixelWriteFunction colorWrite,
GLenum componentType,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint depthBits,
GLuint stencilBits,
GLuint pixelBytes,
bool isBlock,
bool isFixed)
: id(id),
glInternalFormat(glFormat),
fboImplementationInternalFormat(fboFormat),
mipGenerationFunction(mipGen),
pixelReadFunction(colorRead),
pixelWriteFunction(colorWrite),
fastCopyFunctions(fastCopyFunctions),
componentType(componentType),
redBits(redBits),
greenBits(greenBits),
blueBits(blueBits),
alphaBits(alphaBits),
depthBits(depthBits),
stencilBits(stencilBits),
pixelBytes(pixelBytes),
isBlock(isBlock),
isFixed(isFixed)
{}
constexpr bool Format::hasDepthOrStencilBits() const
{
return depthBits > 0 || stencilBits > 0;
}
constexpr GLuint Format::channelCount() const
{
return (redBits > 0) + (greenBits > 0) + (blueBits > 0) + (alphaBits > 0) + (depthBits > 0) +
(stencilBits > 0);
}
} // namespace angle
#include "libANGLE/renderer/FormatID_autogen.inc"
#endif // LIBANGLE_RENDERER_FORMAT_H_