From: Mikko Rasa Date: Sat, 3 Apr 2021 19:56:09 +0000 (+0300) Subject: Comments and cosmetic cleanups X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=70d9d2d28e5fe723c6b46894276e4c935f578e2d;p=libs%2Fgl.git Comments and cosmetic cleanups --- diff --git a/shaderlib/cooktorrance.glsl b/shaderlib/cooktorrance.glsl index 33035ee3..d834cee4 100644 --- a/shaderlib/cooktorrance.glsl +++ b/shaderlib/cooktorrance.glsl @@ -86,7 +86,8 @@ float normal_distribution_ggxtr(vec3 normal, vec3 halfway, float roughness) float rough_q = roughness * roughness; rough_q *= rough_q; float denom = n_dot_h*n_dot_h*(rough_q-1)+1; - // Scale by pi to get a result per steradian, suitable for integration + /* Scale by pi to normalize the total area of the microfacets as projected + to the macrosurface */ return rough_q/(PI*denom*denom); } diff --git a/source/core/datatype.h b/source/core/datatype.h index 6bc08527..c7ee2841 100644 --- a/source/core/datatype.h +++ b/source/core/datatype.h @@ -91,8 +91,8 @@ enum DataType }; inline unsigned get_type_size(DataType t) { return t&0xFF; } -inline bool is_matrix(DataType t) { return (t>>14)&3; } -inline bool is_vector(DataType t) { return !is_matrix(t) && ((t>>12)&3); } +inline bool is_matrix(DataType t) { return t&0xC000; } +inline bool is_vector(DataType t) { return !is_matrix(t) && (t&0x3000); } GLenum get_gl_type(DataType); DataType from_gl_type(GLenum); diff --git a/source/core/module.cpp b/source/core/module.cpp index 5287ae9c..374ef8ae 100644 --- a/source/core/module.cpp +++ b/source/core/module.cpp @@ -70,6 +70,7 @@ void GlslModule::compile(SL::Compiler &compiler) compiler.compile(SL::Compiler::MODULE); prepared_source = compiler.get_combined_glsl(); source_map = compiler.get_source_map(); + #ifdef DEBUG string diagnostics = compiler.get_diagnostics(); if(!diagnostics.empty()) diff --git a/source/core/vertexarray.cpp b/source/core/vertexarray.cpp index 67a90ef7..da868c79 100644 --- a/source/core/vertexarray.cpp +++ b/source/core/vertexarray.cpp @@ -85,6 +85,7 @@ VertexArray::Loader::Loader(VertexArray &a): add("weight", static_cast(&Loader::weight)); add("weight", static_cast(&Loader::weight)); + // Deprecated add("vertex2", static_cast(&Loader::vertex)); add("vertex3", static_cast(&Loader::vertex)); add("vertex4", static_cast(&Loader::vertex)); diff --git a/source/effects/environmentmap.h b/source/effects/environmentmap.h index 1aaa26b7..db97d1d8 100644 --- a/source/effects/environmentmap.h +++ b/source/effects/environmentmap.h @@ -13,7 +13,6 @@ namespace Msp { namespace GL { -class Renderable; class Resources; /** diff --git a/source/effects/shadowmap.h b/source/effects/shadowmap.h index 7dab9eb9..5f6c5c15 100644 --- a/source/effects/shadowmap.h +++ b/source/effects/shadowmap.h @@ -12,10 +12,9 @@ namespace GL { class Light; class Resources; -class Scene; /** -Creates shadows on a Scene through a shadow map texture. In the preparation +Creates shadows on a renderable through a shadow map texture. In the setup phase, the scene is rendered to a depth texture from the point of view of the lightsource. This texture is then used in the rendering phase together with texture coordinate generation to determine whether each fragment is lit. diff --git a/source/glsl/builtin.cpp b/source/glsl/builtin.cpp index 9e0244df..f60d2a8a 100644 --- a/source/glsl/builtin.cpp +++ b/source/glsl/builtin.cpp @@ -2,7 +2,6 @@ #include #include "builtin.h" #include "parser.h" -#include "visitor.h" using namespace std; diff --git a/source/glsl/finalize.h b/source/glsl/finalize.h index 3db581be..0638026d 100644 --- a/source/glsl/finalize.h +++ b/source/glsl/finalize.h @@ -1,5 +1,5 @@ -#ifndef MSP_GL_SL_COMPATIBILITY_H_ -#define MSP_GL_SL_COMPATIBILITY_H_ +#ifndef MSP_GL_SL_FINALIZE_H_ +#define MSP_GL_SL_FINALIZE_H_ #include #include "visitor.h" @@ -8,6 +8,8 @@ namespace Msp { namespace GL { namespace SL { +/** Assigns location and binding layout qualifiers to interface variables and +blocks. */ class LocationAllocator: private TraversingVisitor { private: diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index c03a5ccb..a48ad53f 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -7,6 +7,7 @@ namespace Msp { namespace GL { namespace SL { +/** Determines the number of interface locations required by a variable. */ class LocationCounter: private NodeVisitor { private: diff --git a/source/glsl/validate.h b/source/glsl/validate.h index acb5b4e4..7f8339f6 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -10,6 +10,8 @@ namespace Msp { namespace GL { namespace SL { +/** Base class for validators. Contains some utilities for adding diagnostic +messages. */ class Validator: protected TraversingVisitor { protected: @@ -24,6 +26,7 @@ protected: void add_info(Node &, const std::string &); }; +/** Verifies that declarations are valid in isolation. */ class DeclarationValidator: private Validator { private: @@ -59,6 +62,8 @@ private: virtual void visit(FunctionDeclaration &); }; +/** Verifies that identifiers are unique or, in the case of functions, are +overloaded only in valid ways. */ class IdentifierValidator: private Validator { private: @@ -89,6 +94,7 @@ private: virtual void visit(FunctionDeclaration &); }; +/** Verifies that there are no unresolved references. */ class ReferenceValidator: private Validator { public: @@ -106,6 +112,8 @@ private: virtual void visit(FunctionDeclaration &); }; +/** Verifies that expressions are valid. In most cases an invalid expression +is indicated by a null result type. */ class ExpressionValidator: private Validator { private: @@ -127,6 +135,9 @@ private: virtual void visit(Return &); }; +/** Verifies that stage input and output interfaces are valid. Linked +variables must have matching types and locations and there must not be any +overlap in locations. */ class StageInterfaceValidator: private Validator { private: @@ -142,6 +153,8 @@ private: virtual void visit(FunctionDeclaration &) { } }; +/** Verifies that uniform interfaces are valid across the entire module. +Variables declared with the same binding must have the same name and type. */ class GlobalInterfaceValidator: private Validator { private: diff --git a/source/render/objectinstance.h b/source/render/objectinstance.h index 0ebef2fe..4d3e858b 100644 --- a/source/render/objectinstance.h +++ b/source/render/objectinstance.h @@ -12,9 +12,6 @@ namespace GL { Represents a single instance of an Object. Thanks to being derived from Placeable in can be positioned without additional effort. Other instance parameters can be set by overriding the hook functions. - -ObjectInstances can benefit from being put in an InstanceScene, which will -render all instances of the same object consecutively. */ class ObjectInstance: public PlacedRenderable { diff --git a/source/render/programdata.h b/source/render/programdata.h index e96a73ac..c772272e 100644 --- a/source/render/programdata.h +++ b/source/render/programdata.h @@ -158,7 +158,7 @@ private: mutable ProgramMap programs; mutable UniformBlock *last_block; mutable Buffer *buffer; - mutable unsigned dirty; + mutable Mask dirty; public: ProgramData(const Program * = 0);