Move shader types into compositor and document format convention.
This commit is contained in:
@@ -17,12 +17,40 @@ namespace impeller {
|
||||
|
||||
class Texture;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief The Pixel formats supported by Impeller. The naming convention
|
||||
/// denotes the usage of the component, the bit width of that
|
||||
/// component, and then one or more qualifiers to its
|
||||
/// interpretation.
|
||||
///
|
||||
/// For instance, `kR8G8B8A8_UNormInt_SRGB` is a 32 bits-per-pixel
|
||||
/// format ordered in RGBA with 8 bits per component with each
|
||||
/// component expressed as an unsigned normalized integer and a
|
||||
/// conversion from sRGB to linear color space.
|
||||
///
|
||||
/// Key:
|
||||
/// R -> Red Component
|
||||
/// G -> Green Component
|
||||
/// B -> Blue Component
|
||||
/// D -> Depth Component
|
||||
/// S -> Stencil Component
|
||||
/// U -> Unsigned (Lack of this denotes a signed component)
|
||||
/// Norm -> Normalized
|
||||
/// SRGB -> sRGB to linear interpretation
|
||||
///
|
||||
/// While the effective bit width of the pixel can be determined by
|
||||
/// adding up the widths of each component, only the non-esoteric
|
||||
/// formats are tightly packed. Do not assume tight packing for the
|
||||
/// esoteric formats and use blit passes to convert to a
|
||||
/// non-esoteric pass.
|
||||
///
|
||||
enum class PixelFormat {
|
||||
kUnknown,
|
||||
kR8G8B8A8_UNormInt,
|
||||
kR8G8B8A8_UNormInt_SRGB,
|
||||
kB8G8R8A8_UNormInt,
|
||||
kB8G8R8A8_UNormInt_SRGB,
|
||||
// Esoteric formats only used as render targets.
|
||||
kD32_Float_S8_UNormInt,
|
||||
};
|
||||
|
||||
|
||||
11
engine/src/flutter/impeller/compositor/shader_types.cc
Normal file
11
engine/src/flutter/impeller/compositor/shader_types.cc
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/compositor/shader_types.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
//
|
||||
|
||||
} // namespace impeller
|
||||
77
engine/src/flutter/impeller/compositor/shader_types.h
Normal file
77
engine/src/flutter/impeller/compositor/shader_types.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <string_view>
|
||||
|
||||
#include "impeller/geometry/matrix.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
enum class ShaderStage {
|
||||
kUnknown,
|
||||
kVertex,
|
||||
kFragment,
|
||||
};
|
||||
|
||||
enum class ShaderType {
|
||||
kUnknown,
|
||||
kVoid,
|
||||
kBoolean,
|
||||
kSignedByte,
|
||||
kUnsignedByte,
|
||||
kSignedShort,
|
||||
kUnsignedShort,
|
||||
kSignedInt,
|
||||
kUnsignedInt,
|
||||
kSignedInt64,
|
||||
kUnsignedInt64,
|
||||
kAtomicCounter,
|
||||
kHalfFloat,
|
||||
kFloat,
|
||||
kDouble,
|
||||
kStruct,
|
||||
kImage,
|
||||
kSampledImage,
|
||||
kSampler,
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct ShaderUniformSlot {
|
||||
using Type = T;
|
||||
const char* name;
|
||||
size_t binding;
|
||||
};
|
||||
|
||||
struct ShaderStageIOSlot {
|
||||
const char* name;
|
||||
size_t location;
|
||||
size_t set;
|
||||
size_t binding;
|
||||
ShaderType type;
|
||||
size_t bit_width;
|
||||
size_t vec_size;
|
||||
size_t columns;
|
||||
};
|
||||
|
||||
struct SampledImageSlot {
|
||||
const char* name;
|
||||
size_t texture_index;
|
||||
size_t sampler_index;
|
||||
|
||||
constexpr bool HasTexture() const { return texture_index < 32u; }
|
||||
|
||||
constexpr bool HasSampler() const { return sampler_index < 32u; }
|
||||
};
|
||||
|
||||
template <size_t Size>
|
||||
struct Padding {
|
||||
private:
|
||||
uint8_t pad_[Size];
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -194,7 +194,7 @@ Scalar Matrix::GetDeterminant() const {
|
||||
}
|
||||
|
||||
/*
|
||||
* Adapted for Radar from Graphics Gems:
|
||||
* Adapted for Impeller from Graphics Gems:
|
||||
* http://www.realtimerendering.com/resources/GraphicsGems/gemsii/unmatrix.c
|
||||
*/
|
||||
Matrix::DecompositionResult Matrix::Decompose() const {
|
||||
|
||||
Reference in New Issue
Block a user