This unifies vertex and texture data formats into a single base enum class. `TextureFormat` and `VertexFormat` then mask the invalid format for their respective usage. Having a base enum allows casting between `TextureFormat` and `VertexFormat` possible (needed for Buffer Textures). It also makes it easier to write and read data to buffers/textures as each format will have an associated host type. These enum is generated from MACRO expansion. This allow to centralize all information about the formats in one place. This avoid duplicating the list of enums for each backend. This only creates the new enum. Porting older enums will be done in other PRs. Normalized integer CPU format are missing and waiting for #130640 Rel #130632 Pull Request: https://projects.blender.org/blender/blender/pulls/138069
39 lines
900 B
C++
39 lines
900 B
C++
/* SPDX-FileCopyrightText: 2016 by Mike Erwin. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*
|
|
* GPU vertex format
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "GPU_vertex_buffer.hh"
|
|
|
|
struct GPUVertFormat;
|
|
|
|
void VertexFormat_pack(GPUVertFormat *format);
|
|
void VertexFormat_texture_buffer_pack(GPUVertFormat *format);
|
|
uint padding(uint offset, uint alignment);
|
|
uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len);
|
|
|
|
namespace blender::gpu {
|
|
|
|
bool is_fetch_normalized(VertAttrType attr_type);
|
|
bool is_fetch_int_to_float(VertAttrType attr_type);
|
|
bool is_fetch_float(VertAttrType attr_type);
|
|
|
|
inline int format_component_len(const VertAttrType format)
|
|
{
|
|
return format_component_len(DataFormat(int8_t(format)));
|
|
}
|
|
|
|
inline int to_bytesize(const VertAttrType format)
|
|
{
|
|
return to_bytesize(DataFormat(int8_t(format)));
|
|
}
|
|
|
|
} // namespace blender::gpu
|