Panda3D
Loading...
Searching...
No Matches
shaderBuffer.h
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.h
10 * @author rdb
11 * @date 2016-12-12
12 */
13
14#ifndef SHADERBUFFER_H
15#define SHADERBUFFER_H
16
17#include "pandabase.h"
19#include "namable.h"
20#include "geomEnums.h"
22#include "factoryParams.h"
23#include "vector_uchar.h"
24
25class BufferContext;
27
28/**
29 * This is a generic buffer object that lives in graphics memory.
30 *
31 * @since 1.10.0
32 */
33class EXPCL_PANDA_GOBJ ShaderBuffer : public TypedWritableReferenceCount, public Namable, public GeomEnums {
34private:
35 INLINE ShaderBuffer() = default;
36
37PUBLISHED:
39
40 INLINE explicit ShaderBuffer(const std::string &name, uint64_t size, UsageHint usage_hint);
41 INLINE explicit ShaderBuffer(const std::string &name, vector_uchar initial_data, UsageHint usage_hint);
42
43public:
44 INLINE uint64_t get_data_size_bytes() const;
45 INLINE UsageHint get_usage_hint() const;
46 INLINE const unsigned char *get_initial_data() const;
47
48 virtual void output(std::ostream &out) const;
49
50PUBLISHED:
51 MAKE_PROPERTY(data_size_bytes, get_data_size_bytes);
52 MAKE_PROPERTY(usage_hint, get_usage_hint);
53
54 void prepare(PreparedGraphicsObjects *prepared_objects);
55 bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
56
57 BufferContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
59 bool release(PreparedGraphicsObjects *prepared_objects);
60 int release_all();
61
62private:
63 void clear_prepared(PreparedGraphicsObjects *prepared_objects);
64
65private:
66 uint64_t _data_size_bytes;
67 UsageHint _usage_hint;
68 vector_uchar _initial_data;
69
71 Contexts *_contexts = nullptr;
72
73public:
74 static void register_with_read_factory();
75 virtual void write_datagram(BamWriter *manager, Datagram &dg);
76
77protected:
78 static TypedWritable *make_from_bam(const FactoryParams &params);
79 void fillin(DatagramIterator &scan, BamReader *manager);
80
81public:
82 virtual TypeHandle get_type() const {
83 return get_class_type();
84 }
85 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 static TypeHandle get_class_type() {
87 return _type_handle;
88 }
89 static void init_type() {
90 TypedWritableReferenceCount::init_type();
91 Namable::init_type();
92 register_type(_type_handle, "ShaderBuffer",
93 TypedWritableReferenceCount::get_class_type(),
94 Namable::get_class_type());
95 }
96
97private:
98 static TypeHandle _type_handle;
99
100 friend class PreparedGraphicsObjects;
101};
102
103INLINE std::ostream &operator << (std::ostream &out, const ShaderBuffer &m) {
104 m.output(out);
105 return out;
106}
107
108#include "shaderBuffer.I"
109
110#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This class exists just to provide scoping for the various enumerated types used by Geom,...
Definition geomEnums.h:24
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A base class for all things which can have a name.
Definition namable.h:26
void output(std::ostream &out) const
Outputs the Namable.
Definition namable.I:61
A table of objects that are saved within the graphics context for reference by handle later.
This is a generic buffer object that lives in graphics memory.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.