Various refactoring, esp. of GLSL input system

This commit is contained in:
rdb 2015-05-21 14:16:45 +02:00
parent b49289a4f6
commit e2dfc935a1
23 changed files with 1379 additions and 1095 deletions

View File

@ -26,6 +26,11 @@ format_string(const string &value) {
return value;
}
INLINE string
format_string(bool value) {
return string(value ? "true" : "false");
}
INLINE string
format_string(float value) {
char buffer[32];

View File

@ -69,6 +69,7 @@ INLINE string format_string(const Thing &thing);
// Fast specializations for some primitive types.
INLINE string format_string(const string &value);
INLINE string format_string(bool value);
INLINE string format_string(float value);
INLINE string format_string(double value);
INLINE string format_string(unsigned int value);

View File

@ -720,11 +720,16 @@ get_valid_child_classes(std::map<std::string, CastDetails> &answer, CPPStructTyp
///////////////////////////////////////////////////////////////////////////////
void InterfaceMakerPythonNative::
write_python_instance(ostream &out, int indent_level, const string &return_expr,
bool owns_memory, const string &class_name,
CPPType *ctype, bool is_const) {
bool owns_memory, const InterrogateType &itype, bool is_const) {
out << boolalpha;
if (IsPandaTypedObject(ctype->as_struct_type())) {
if (!isExportThisRun(itype._cpptype)) {
_external_imports.insert(itype._cpptype);
}
string class_name = itype.get_scoped_name();
if (IsPandaTypedObject(itype._cpptype->as_struct_type())) {
// We can't let DTool_CreatePyInstanceTyped do the NULL check since we
// will be grabbing the type index (which would obviously crash when called
// on a NULL pointer), so we do it here.
@ -6046,31 +6051,19 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap,
TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(type)),false);
const InterrogateType &itype = idb->get_type(type_index);
if (!isExportThisRun(itype._cpptype)) {
_external_imports.insert(itype._cpptype);
}
write_python_instance(out, indent_level, return_expr, owns_memory, itype.get_scoped_name(), itype._cpptype, is_const);
write_python_instance(out, indent_level, return_expr, owns_memory, itype, is_const);
} else {
TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)),false);
const InterrogateType &itype = idb->get_type(type_index);
if (!isExportThisRun(itype._cpptype)) {
_external_imports.insert(itype._cpptype);
}
write_python_instance(out, indent_level, return_expr, owns_memory, itype.get_scoped_name(), itype._cpptype, is_const);
write_python_instance(out, indent_level, return_expr, owns_memory, itype, is_const);
}
} else if (TypeManager::is_struct(orig_type->as_pointer_type()->_pointing_at)) {
TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)),false);
const InterrogateType &itype = idb->get_type(type_index);
if (!isExportThisRun(itype._cpptype)) {
_external_imports.insert(itype._cpptype);
}
write_python_instance(out, indent_level, return_expr, owns_memory, itype.get_scoped_name(), itype._cpptype, is_const);
write_python_instance(out, indent_level, return_expr, owns_memory, itype, is_const);
} else {
indent(out, indent_level) << "Should Never Reach This InterfaceMakerPythonNative::pack_python_value";
@ -6638,6 +6631,7 @@ HasAGetClassTypeFunction(const InterrogateType &itype_class) {
int num_methods = itype_class.number_of_methods();
int mi;
for (mi = 0; mi < num_methods; mi++) {
FunctionIndex func_index = itype_class.get_method(mi);
const InterrogateFunction &ifunc = idb->get_function(func_index);

View File

@ -198,7 +198,7 @@ public:
void get_valid_child_classes(std::map<std::string, CastDetails> &answer, CPPStructType *inclass, const std::string &upcast_seed = "", bool can_downcast = true);
bool DoesInheritFromIsClass(const CPPStructType * inclass, const std::string &name);
bool IsPandaTypedObject(CPPStructType * inclass) { return DoesInheritFromIsClass(inclass,"TypedObject"); };
void write_python_instance(ostream &out, int indent_level, const std::string &return_expr, bool owns_memory, const std::string &class_name, CPPType *ctype, bool is_const);
void write_python_instance(ostream &out, int indent_level, const std::string &return_expr, bool owns_memory, const InterrogateType &itype, bool is_const);
bool HasAGetClassTypeFunction(const InterrogateType &itype_class);
int NeedsAStrFunction(const InterrogateType &itype_class);
int NeedsAReprFunction(const InterrogateType &itype_class);

View File

@ -643,9 +643,7 @@ update_shader_texture_bindings(ShaderContext *prev) {
SamplerState sampler;
if (id != NULL) {
const ShaderInput *input = _glgsg->_target_shader->get_shader_input(id);
tex = input->get_texture();
sampler = input->get_sampler();
tex = _glgsg->_target_shader->get_shader_input_texture(id, &sampler);
} else {
if (_shader->_tex_spec[i]._stage >= texattrib->get_num_on_stages()) {

View File

@ -1461,6 +1461,23 @@ reset() {
}
#endif
#ifndef OPENGLES
// Check for uniform buffers.
if (is_at_least_gl_version(3, 1) || has_extension("GL_ARB_uniform_buffer_object")) {
_supports_uniform_buffers = true;
_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)
get_extension_func("glGetActiveUniformsiv");
_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)
get_extension_func("glGetActiveUniformBlockiv");
_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)
get_extension_func("glGetActiveUniformBlockName");
} else {
_supports_uniform_buffers = false;
}
#else
_supports_uniform_buffers = false;
#endif
// Check whether we support geometry instancing and instanced vertex attribs.
#if defined(OPENGLES_1)
_supports_vertex_attrib_divisor = false;

View File

@ -636,6 +636,7 @@ protected:
GLint _max_image_units;
bool _supports_multi_bind;
bool _supports_get_program_binary;
bool _supports_uniform_buffers;
#ifdef OPENGLES
bool _supports_depth24;
@ -845,6 +846,9 @@ public:
PFNGLDRAWELEMENTSINSTANCEDPROC _glDrawElementsInstanced;
#endif // !OPENGLES_1
#ifndef OPENGLES
PFNGLGETACTIVEUNIFORMSIVPROC _glGetActiveUniformsiv;
PFNGLGETACTIVEUNIFORMBLOCKIVPROC _glGetActiveUniformBlockiv;
PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC _glGetActiveUniformBlockName;
PFNGLGENSAMPLERSPROC _glGenSamplers;
PFNGLDELETESAMPLERSPROC _glDeleteSamplers;
PFNGLBINDSAMPLERPROC _glBindSampler;

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
#include "shader.h"
#include "shaderContext.h"
#include "deletedChain.h"
#include "paramTexture.h"
class CLP(GraphicsStateGuardian);
@ -35,6 +36,12 @@ public:
~CLP(ShaderContext)();
ALLOC_DELETED_CHAIN(CLP(ShaderContext));
void reflect_attribute(int i, char *name_buf, GLsizei name_buflen);
#ifndef OPENGLES
void reflect_uniform_block(int i, const char *block_name,
char *name_buffer, GLsizei name_buflen);
#endif
void reflect_uniform(int i, char *name_buffer, GLsizei name_buflen);
bool get_sampler_texture_type(int &out, GLenum param_type);
INLINE bool valid(void);
@ -51,6 +58,7 @@ public:
INLINE bool uses_custom_texture_bindings(void);
private:
bool _validated;
GLuint _glsl_program;
typedef pvector<GLuint> GLSLShaders;
GLSLShaders _glsl_shaders;
@ -66,11 +74,14 @@ private:
//ParamContexts _params;
GLint _color_attrib_index;
pvector<GLint> _glsl_parameter_map;
pmap<GLint, GLuint64> _glsl_uniform_handles;
pvector<CPT(InternalName)> _glsl_img_inputs;
pvector<CLP(TextureContext)*> _glsl_img_textures;
struct ImageInput {
CPT(InternalName) _name;
CLP(TextureContext) *_gtc;
bool _writable;
};
pvector<ImageInput> _glsl_img_inputs;
CLP(GraphicsStateGuardian) *_glgsg;

View File

@ -222,6 +222,12 @@ ConfigVariableBool gl_dump_compiled_shaders
"programs to disk with a filename like glsl_program0.dump "
"into the current directory."));
ConfigVariableBool gl_validate_shaders
("gl-validate-shaders", true,
PRC_DESC("Set this to true to enable glValidateShader the first time "
"a shader is bound. This may cause helpful information about "
"shaders to be printed."));
ConfigVariableBool gl_immutable_texture_storage
("gl-immutable-texture-storage", false,
PRC_DESC("This configures Panda to pre-allocate immutable storage "

View File

@ -70,6 +70,7 @@ extern ConfigVariableBool gl_force_flush;
extern ConfigVariableBool gl_separate_specular_color;
extern ConfigVariableBool gl_cube_map_seamless;
extern ConfigVariableBool gl_dump_compiled_shaders;
extern ConfigVariableBool gl_validate_shaders;
extern ConfigVariableBool gl_immutable_texture_storage;
extern ConfigVariableBool gl_use_bindless_texture;
extern ConfigVariableBool gl_enable_memory_barriers;

View File

@ -33,13 +33,16 @@ GeomVertexColumn() :
INLINE GeomVertexColumn::
GeomVertexColumn(CPT_InternalName name, int num_components,
NumericType numeric_type, Contents contents,
int start, int column_alignment) :
int start, int column_alignment, int num_elements,
int element_stride) :
_name(MOVE(name)),
_num_components(num_components),
_numeric_type(numeric_type),
_contents(contents),
_start(start),
_column_alignment(column_alignment),
_num_elements(num_elements),
_element_stride(element_stride),
_packer(NULL)
{
setup();
@ -58,6 +61,8 @@ GeomVertexColumn(const GeomVertexColumn &copy) :
_contents(copy._contents),
_start(copy._start),
_column_alignment(copy._column_alignment),
_num_elements(copy._num_elements),
_element_stride(copy._element_stride),
_packer(NULL)
{
setup();
@ -317,6 +322,12 @@ compare_to(const GeomVertexColumn &other) const {
if (_column_alignment != other._column_alignment) {
return _column_alignment - other._column_alignment;
}
if (_num_elements != other._num_elements) {
return _num_elements - other._num_elements;
}
if (_element_stride != other._element_stride) {
return _element_stride - other._element_stride;
}
return 0;
}

View File

@ -30,6 +30,8 @@ operator = (const GeomVertexColumn &copy) {
_contents = copy._contents;
_start = copy._start;
_column_alignment = copy._column_alignment;
_num_elements = copy._num_elements;
_element_stride = copy._element_stride;
setup();
}
@ -159,6 +161,10 @@ output(ostream &out) const {
}
out << ")";
if (_num_elements > 1) {
out << "[" << _num_elements << "]";
}
}
////////////////////////////////////////////////////////////////////
@ -172,7 +178,6 @@ setup() {
nassertv(_num_components > 0 && _start >= 0);
_num_values = _num_components;
_num_elements = 1;
if (_numeric_type == NT_stdfloat) {
if (vertices_float64) {
@ -222,8 +227,13 @@ setup() {
break;
}
if (_num_elements == 0) {
// Matrices are assumed to be square.
if (_contents == C_matrix) {
_num_elements = _num_components;
} else {
_num_elements = 1;
}
}
if (_column_alignment < 1) {
@ -236,7 +246,9 @@ setup() {
// Enforce the column alignment requirements on the _start byte.
_start = ((_start + _column_alignment - 1) / _column_alignment) * _column_alignment;
if (_element_stride < 1) {
_element_stride = _component_bytes * _num_components;
}
_total_bytes = _element_stride * _num_elements;
if (_packer != NULL) {
@ -433,6 +445,9 @@ fillin(DatagramIterator &scan, BamReader *manager) {
_column_alignment = scan.get_uint8();
}
_num_elements = 0;
_element_stride = 0;
setup();
}

View File

@ -43,7 +43,8 @@ private:
PUBLISHED:
INLINE GeomVertexColumn(CPT_InternalName name, int num_components,
NumericType numeric_type, Contents contents,
int start, int column_alignment = 0);
int start, int column_alignment = 0,
int num_elements = 0, int element_stride = 0);
INLINE GeomVertexColumn(const GeomVertexColumn &copy);
void operator = (const GeomVertexColumn &copy);
INLINE ~GeomVertexColumn();
@ -346,7 +347,7 @@ private:
}
};
class Packer_nativedouble_3 : public Packer_float64_3 {
class Packer_nativedouble_3 FINAL : public Packer_float64_3 {
public:
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
@ -355,7 +356,7 @@ private:
}
};
class Packer_point_nativedouble_2 : public Packer_point_float64_2 {
class Packer_point_nativedouble_2 FINAL : public Packer_point_float64_2 {
public:
virtual const LVecBase2d &get_data2d(const unsigned char *pointer);
@ -364,7 +365,7 @@ private:
}
};
class Packer_point_nativedouble_3 : public Packer_point_float64_3 {
class Packer_point_nativedouble_3 FINAL : public Packer_point_float64_3 {
public:
virtual const LVecBase3d &get_data3d(const unsigned char *pointer);
@ -382,7 +383,7 @@ private:
}
};
class Packer_argb_packed : public Packer_color {
class Packer_argb_packed FINAL : public Packer_color {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
@ -392,7 +393,7 @@ private:
}
};
class Packer_rgba_uint8_4 : public Packer_color {
class Packer_rgba_uint8_4 FINAL : public Packer_color {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
@ -412,7 +413,7 @@ private:
}
};
class Packer_rgba_nativefloat_4 : public Packer_rgba_float32_4 {
class Packer_rgba_nativefloat_4 FINAL : public Packer_rgba_float32_4 {
public:
virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
@ -421,7 +422,7 @@ private:
}
};
class Packer_uint16_1 : public Packer {
class Packer_uint16_1 FINAL : public Packer {
public:
virtual int get_data1i(const unsigned char *pointer);
virtual void set_data1i(unsigned char *pointer, int value);

View File

@ -138,3 +138,48 @@ lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix4) &source) {
source(2, 0), source(2, 1), source(2, 2), source(2, 3),
source(3, 0), source(3, 1), source(3, 2), source(3, 3));
}
INLINE_LINMATH FLOATNAME2(LVecBase2)
lcast_to(FLOATTYPE2 *, const LVecBase2i &source) {
return FLOATNAME2(LVecBase2)(source[0], source[1]);
}
INLINE_LINMATH FLOATNAME2(LVecBase3)
lcast_to(FLOATTYPE2 *, const LVecBase3i &source) {
return FLOATNAME2(LVecBase3)(source[0], source[1], source[2]);
}
INLINE_LINMATH FLOATNAME2(LVecBase4)
lcast_to(FLOATTYPE2 *, const LVecBase4i &source) {
return FLOATNAME2(LVecBase4)(source[0], source[1], source[2], source[3]);
}
INLINE_LINMATH FLOATNAME2(LVector2)
lcast_to(FLOATTYPE2 *, const LVector2i &source) {
return FLOATNAME2(LVector2)(source[0], source[1]);
}
INLINE_LINMATH FLOATNAME2(LVector3)
lcast_to(FLOATTYPE2 *, const LVector3i &source) {
return FLOATNAME2(LVector3)(source[0], source[1], source[2]);
}
INLINE_LINMATH FLOATNAME2(LVector4)
lcast_to(FLOATTYPE2 *, const LVector4i &source) {
return FLOATNAME2(LVector4)(source[0], source[1], source[2], source[3]);
}
INLINE_LINMATH FLOATNAME2(LPoint2)
lcast_to(FLOATTYPE2 *, const LPoint2i &source) {
return FLOATNAME2(LPoint2)(source[0], source[1]);
}
INLINE_LINMATH FLOATNAME2(LPoint3)
lcast_to(FLOATTYPE2 *, const LPoint3i &source) {
return FLOATNAME2(LPoint3)(source[0], source[1], source[2]);
}
INLINE_LINMATH FLOATNAME2(LPoint4)
lcast_to(FLOATTYPE2 *, const LPoint4i &source) {
return FLOATNAME2(LPoint4)(source[0], source[1], source[2], source[3]);
}

View File

@ -86,6 +86,33 @@ lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix3) &source);
INLINE_LINMATH FLOATNAME2(LMatrix4)
lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix4) &source);
INLINE_LINMATH FLOATNAME2(LVecBase2)
lcast_to(FLOATTYPE2 *, const LVecBase2i &source);
INLINE_LINMATH FLOATNAME2(LVecBase3)
lcast_to(FLOATTYPE2 *, const LVecBase3i &source);
INLINE_LINMATH FLOATNAME2(LVecBase4)
lcast_to(FLOATTYPE2 *, const LVecBase4i &source);
INLINE_LINMATH FLOATNAME2(LVector2)
lcast_to(FLOATTYPE2 *, const LVector2i &source);
INLINE_LINMATH FLOATNAME2(LVector3)
lcast_to(FLOATTYPE2 *, const LVector3i &source);
INLINE_LINMATH FLOATNAME2(LVector4)
lcast_to(FLOATTYPE2 *, const LVector4i &source);
INLINE_LINMATH FLOATNAME2(LPoint2)
lcast_to(FLOATTYPE2 *, const LPoint2i &source);
INLINE_LINMATH FLOATNAME2(LPoint3)
lcast_to(FLOATTYPE2 *, const LPoint3i &source);
INLINE_LINMATH FLOATNAME2(LPoint4)
lcast_to(FLOATTYPE2 *, const LPoint4i &source);
#include "lcast_to_src.I"
#endif // CPPPARSER

View File

@ -429,9 +429,12 @@ get_shader_input_ptr(const InternalName *id) const {
// Access: Published
// Description: Returns the ShaderInput as a texture. Assertion
// fails if there is none, or if it is not a texture.
//
// If sampler is not NULL, the sampler state to use
// for this texture is assigned to it.
////////////////////////////////////////////////////////////////////
Texture *ShaderAttrib::
get_shader_input_texture(const InternalName *id) const {
get_shader_input_texture(const InternalName *id, SamplerState *sampler) const {
Inputs::const_iterator i = _inputs.find(id);
if (i == _inputs.end()) {
ostringstream strm;
@ -447,37 +450,13 @@ get_shader_input_texture(const InternalName *id) const {
nassert_raise(strm.str());
return NULL;
}
if (sampler != NULL) {
*sampler = p->get_sampler();
}
return p->get_texture();
}
}
////////////////////////////////////////////////////////////////////
// Function: ShaderAttrib::get_shader_input_sampler
// Access: Published
// Description: Returns the ShaderInput as a sampler. Assertion
// fails if there is none, or if it is not a texture.
////////////////////////////////////////////////////////////////////
const SamplerState &ShaderAttrib::
get_shader_input_sampler(const InternalName *id) const {
Inputs::const_iterator i = _inputs.find(id);
if (i == _inputs.end()) {
ostringstream strm;
strm << "Shader input " << id->get_name() << " is not present.\n";
nassert_raise(strm.str());
return SamplerState::get_default();
} else {
const ShaderInput *p = (*i).second;
if (p->get_value_type() != ShaderInput::M_texture &&
p->get_value_type() != ShaderInput::M_texture_sampler) {
ostringstream strm;
strm << "Shader input " << id->get_name() << " is not a texture.\n";
nassert_raise(strm.str());
return SamplerState::get_default();
}
return p->get_sampler();
}
}
////////////////////////////////////////////////////////////////////
// Function: ShaderAttrib::get_shader_input_matrix
// Access: Published

View File

@ -106,8 +106,7 @@ PUBLISHED:
const NodePath &get_shader_input_nodepath(const InternalName *id) const;
LVecBase4 get_shader_input_vector(InternalName *id) const;
Texture *get_shader_input_texture(const InternalName *id) const;
const SamplerState &get_shader_input_sampler(const InternalName *id) const;
Texture *get_shader_input_texture(const InternalName *id, SamplerState *sampler=NULL) const;
const Shader::ShaderPtrData *get_shader_input_ptr(const InternalName *id) const;
const LMatrix4 &get_shader_input_matrix(const InternalName *id, LMatrix4 &matrix) const;

View File

@ -31,10 +31,7 @@ INLINE ShaderInput::
ShaderInput(CPT_InternalName name, int priority) :
_name(MOVE(name)),
_type(M_invalid),
_priority(priority),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_priority(priority)
{
}
@ -48,60 +45,10 @@ ShaderInput(CPT_InternalName name, Texture *tex, int priority) :
_name(MOVE(name)),
_type(M_texture),
_priority(priority),
_value(tex),
_bind_layer(0),
_bind_level(0),
_access(A_read | A_write | A_layered)
_value(tex)
{
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE ShaderInput::
ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) :
_name(MOVE(name)),
_type(M_texture_sampler),
_priority(priority),
_value(tex),
_sampler(sampler),
_bind_layer(0),
_bind_level(0),
_access(A_read | A_layered)
{
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE ShaderInput::
ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) :
_name(MOVE(name)),
_type(M_texture),
_priority(priority),
_value(tex),
_bind_layer(z),
_bind_level(n),
_access(0)
{
if (read) {
_access |= A_read;
}
if (write) {
_access |= A_write;
}
if (z >= 0) {
_bind_layer = z;
} else {
_bind_layer = 0;
_access |= A_layered;
}
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::Constructor
// Access: Published
@ -112,10 +59,7 @@ ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) :
_name(MOVE(name)),
_type(M_param),
_priority(priority),
_value(param),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_value(param)
{
}
@ -129,10 +73,7 @@ ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -146,10 +87,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -163,10 +101,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -180,10 +115,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -198,10 +130,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) :
_type(M_vector),
_priority(priority),
_stored_ptr(vec),
_stored_vector(LCAST(PN_stdfloat, vec)),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector(LCAST(PN_stdfloat, vec))
{
}
@ -216,10 +145,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) :
_type(M_vector),
_priority(priority),
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0)
{
}
@ -234,10 +160,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) :
_type(M_vector),
_priority(priority),
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0)
{
}
@ -251,10 +174,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -268,10 +188,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -285,10 +202,7 @@ ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(mat),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(mat)
{
}
@ -302,10 +216,7 @@ ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(mat),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(mat)
{
}
@ -319,10 +230,7 @@ ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -336,10 +244,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -353,10 +258,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -370,10 +272,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -388,10 +287,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector(LCAST(PN_stdfloat, vec)),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector(LCAST(PN_stdfloat, vec))
{
}
@ -406,10 +302,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector(vec.get_x(), vec.get_y(), vec.get_z(), 0.0)
{
}
@ -424,10 +317,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector(vec.get_x(), vec.get_y(), 0.0, 0.0)
{
}
@ -441,10 +331,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -458,10 +345,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -475,10 +359,7 @@ ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(mat),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(mat)
{
}
@ -492,10 +373,7 @@ ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(mat),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(mat)
{
}
@ -509,10 +387,7 @@ ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -526,10 +401,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -543,10 +415,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -560,10 +429,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) :
_name(MOVE(name)),
_type(M_numeric),
_priority(priority),
_stored_ptr(ptr),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_ptr(ptr)
{
}
@ -578,10 +444,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), (int)vec.get_w()),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), (int)vec.get_w())
{
}
@ -596,10 +459,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), 0.0),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector((int)vec.get_x(), (int)vec.get_y(), (int)vec.get_z(), 0.0)
{
}
@ -614,10 +474,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority) :
_type(M_numeric),
_priority(priority),
_stored_ptr(vec),
_stored_vector((int)vec.get_x(), (int)vec.get_y(), 0.0, 0.0),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_stored_vector((int)vec.get_x(), (int)vec.get_y(), 0.0, 0.0)
{
}
@ -651,16 +508,6 @@ get_priority() const {
return _priority;
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::get_texture
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE Texture *ShaderInput::
get_texture() const {
return DCAST(Texture, _value);
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::get_vector
// Access: Published
@ -681,18 +528,6 @@ get_ptr() const {
return _stored_ptr;
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::get_sampler
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE const SamplerState &ShaderInput::
get_sampler() const {
return (_type == M_texture)
? get_texture()->get_default_sampler()
: _sampler;
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::get_param
// Access: Public

View File

@ -14,6 +14,7 @@
#include "shaderInput.h"
#include "paramNodePath.h"
#include "paramTexture.h"
TypeHandle ShaderInput::_type_handle;
@ -43,10 +44,35 @@ ShaderInput(CPT_InternalName name, const NodePath &np, int priority) :
_name(MOVE(name)),
_type(M_nodepath),
_priority(priority),
_value(new ParamNodePath(np)),
_bind_layer(0),
_bind_level(0),
_access(A_read)
_value(new ParamNodePath(np))
{
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
ShaderInput::
ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) :
_name(MOVE(name)),
_type(M_texture_image),
_priority(priority),
_value(new ParamTextureImage(tex, read, write, z, n))
{
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
ShaderInput::
ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) :
_name(MOVE(name)),
_type(M_texture_sampler),
_priority(priority),
_value(new ParamTextureSampler(tex, sampler))
{
}
@ -61,6 +87,40 @@ get_nodepath() const {
return DCAST(ParamNodePath, _value)->get_value();
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::get_texture
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
Texture *ShaderInput::
get_texture() const {
switch (_type) {
case M_texture_sampler:
return DCAST(ParamTextureSampler, _value)->get_texture();
case M_texture_image:
return DCAST(ParamTextureImage, _value)->get_texture();
case M_texture:
return DCAST(Texture, _value);
default:
return NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::get_sampler
// Access: Published
// Description: Warning: no error checking is done.
////////////////////////////////////////////////////////////////////
const SamplerState &ShaderInput::
get_sampler() const {
return (_type == M_texture_sampler)
? DCAST(ParamTextureSampler, _value)->get_sampler()
: get_texture()->get_default_sampler();
}
////////////////////////////////////////////////////////////////////
// Function: ShaderInput::register_with_read_factory
// Access: Public, Static

View File

@ -53,8 +53,6 @@ PUBLISHED:
static const ShaderInput *get_blank();
INLINE ShaderInput(CPT_InternalName name, int priority=0);
INLINE ShaderInput(CPT_InternalName name, Texture *tex, int priority=0);
INLINE ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority=0);
INLINE ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z=-1, int n=0, int priority=0);
INLINE ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority=0);
INLINE ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority=0);
INLINE ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority=0);
@ -89,6 +87,8 @@ PUBLISHED:
INLINE ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority=0);
ShaderInput(CPT_InternalName name, const NodePath &np, int priority=0);
ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z=-1, int n=0, int priority=0);
ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority=0);
enum ShaderInputType {
M_invalid = 0,
@ -97,19 +97,20 @@ PUBLISHED:
M_vector,
M_numeric,
M_texture_sampler,
M_param
M_param,
M_texture_image
};
INLINE const InternalName *get_name() const;
INLINE int get_value_type() const;
INLINE int get_priority() const;
INLINE Texture *get_texture() const;
INLINE const LVecBase4 &get_vector() const;
INLINE const Shader::ShaderPtrData &get_ptr() const;
INLINE const SamplerState &get_sampler() const;
const NodePath &get_nodepath() const;
Texture *get_texture() const;
const SamplerState &get_sampler() const;
public:
INLINE ParamValueBase *get_param() const;
@ -117,25 +118,19 @@ public:
static void register_with_read_factory();
private:
SamplerState _sampler;
LVecBase4 _stored_vector;
Shader::ShaderPtrData _stored_ptr;
CPT_InternalName _name;
PT(TypedWritableReferenceCount) _value;
int _priority;
public:
int _type : 8;
int _access : 8;
int _bind_level : 16;
int _bind_layer;
int _type;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
ReferenceCount::init_type();
TypedWritableReferenceCount::init_type();
register_type(_type_handle, "ShaderInput",
TypedWritableReferenceCount::get_class_type());
}

View File

@ -104,6 +104,7 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
_awaiting_configure = false;
_dga_mouse_enabled = false;
_override_redirect = False;
_wm_delete_window = x11_pipe->_wm_delete_window;
GraphicsWindowInputDevice device =
@ -946,9 +947,10 @@ open_window() {
wa.border_pixel = 0;
wa.colormap = _colormap;
wa.event_mask = _event_mask;
wa.override_redirect = _override_redirect;
unsigned long attrib_mask =
CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
_xwindow = XCreateWindow
(_display, parent_window,

View File

@ -99,6 +99,7 @@ protected:
long _event_mask;
bool _awaiting_configure;
bool _dga_mouse_enabled;
Bool _override_redirect;
Atom _wm_delete_window;
struct MouseDeviceInfo {