Panda3D

Loading...
Searching...
No Matches
shaderBuffer.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file shaderBuffer.I
10 * @author rdb
11 * @date 2016-12-12
12 */
13
14/**
15 * Creates an uninitialized buffer object with the given size. For now, these
16 * parameters cannot be modified, but this may change in the future.
17 */
18INLINE ShaderBuffer::
19ShaderBuffer(const std::string &name, uint64_t size, UsageHint usage_hint) :
20 Namable(name),
21 _data_size_bytes(size),
22 _usage_hint(usage_hint) {
23}
24
25/**
26 * Creates a buffer object initialized with the given data. For now, these
27 * parameters cannot be modified, but this may change in the future.
28 */
29INLINE ShaderBuffer::
30ShaderBuffer(const std::string &name, vector_uchar initial_data, UsageHint usage_hint) :
31 Namable(name),
32 _data_size_bytes(initial_data.size()),
33 _usage_hint(usage_hint),
34 _initial_data(std::move(initial_data)) {
35
36 // Make sure it is padded to 16 bytes. Some drivers like that.
37 if ((_initial_data.size() & 15u) != 0) {
38 _initial_data.resize((_initial_data.size() + 15u) & ~15u, 0);
39 _data_size_bytes = _initial_data.size();
40 }
41}
42
43/**
44 * Returns the buffer size in bytes.
45 */
46INLINE uint64_t ShaderBuffer::
47 get_data_size_bytes() const {
48 return _data_size_bytes;
49}
50
51/**
52 * Returns the buffer usage hint.
53 */
54INLINE GeomEnums::UsageHint ShaderBuffer::
55 get_usage_hint() const {
56 return _usage_hint;
57}
58
59/**
60 * Returns a pointer to the initial buffer data, or NULL if not specified.
61 */
62INLINE const unsigned char *ShaderBuffer::
63 get_initial_data() const {
64 if (_initial_data.empty()) {
65 return nullptr;
66 } else {
67 return &_initial_data[0];
68 }
69}
ShaderBuffer::get_initial_data
const unsigned char * get_initial_data() const
Returns a pointer to the initial buffer data, or NULL if not specified.
Definition shaderBuffer.I:63
ShaderBuffer::get_usage_hint
get_usage_hint
Returns the buffer usage hint.
Definition shaderBuffer.h:52
ShaderBuffer::get_data_size_bytes
get_data_size_bytes
Returns the buffer size in bytes.
Definition shaderBuffer.h:51
std
STL namespace.