add usd-21-11-win64_py39
This commit is contained in:
1 parent
41d23e71ba
commit
ba5e1f7e67
15684 files changed
+3069957
No files matched your search
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_API_H
|
||||
#define PXR_IMAGING_HIO_API_H
|
||||
|
||||
#include "pxr/base/arch/export.h"
|
||||
|
||||
#if defined(PXR_STATIC)
|
||||
# define HIO_API
|
||||
# define HIO_API_TEMPLATE_CLASS(...)
|
||||
# define HIO_API_TEMPLATE_STRUCT(...)
|
||||
# define HIO_LOCAL
|
||||
#else
|
||||
# if defined(HIO_EXPORTS)
|
||||
# define HIO_API ARCH_EXPORT
|
||||
# define HIO_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define HIO_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# else
|
||||
# define HIO_API ARCH_IMPORT
|
||||
# define HIO_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define HIO_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# endif
|
||||
# define HIO_LOCAL ARCH_HIDDEN
|
||||
#endif
|
||||
|
||||
#endif // PXR_IMAGING_HIO_API_H
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// Copyright 2021 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_FIELD_TEXTURE_DATA_H
|
||||
#define PXR_IMAGING_HIO_FIELD_TEXTURE_DATA_H
|
||||
|
||||
/// \file hio/fieldTextureData.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hio/api.h"
|
||||
#include "pxr/imaging/hio/image.h"
|
||||
|
||||
#include "pxr/base/gf/bbox3d.h"
|
||||
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
using HioFieldTextureDataSharedPtr = std::shared_ptr<class HioFieldTextureData>;
|
||||
|
||||
/// \class HioFieldTextureData
|
||||
///
|
||||
/// An interface class for reading volume files having a
|
||||
/// transformation.
|
||||
///
|
||||
class HioFieldTextureData
|
||||
{
|
||||
public:
|
||||
HIO_API
|
||||
HioFieldTextureData();
|
||||
|
||||
HIO_API
|
||||
virtual ~HioFieldTextureData();
|
||||
|
||||
/// Load Volume Field Data
|
||||
///
|
||||
/// fieldName corresponds to the gridName in an OpenVDB file or
|
||||
/// to the layer/attribute name in a Field3D file.
|
||||
/// fieldIndex corresponds to the partition index
|
||||
/// fieldPurpose corresponds to the partition name/grouping
|
||||
///
|
||||
/// Returns nullptr and posts an error if the specified data cannot be
|
||||
/// loaded.
|
||||
///
|
||||
HIO_API
|
||||
static HioFieldTextureDataSharedPtr New(
|
||||
std::string const & filePath,
|
||||
std::string const & fieldName,
|
||||
int fieldIndex,
|
||||
std::string const & fieldPurpose,
|
||||
size_t targetMemory);
|
||||
|
||||
/// Bounding box describing how 3d texture maps into
|
||||
/// world space.
|
||||
///
|
||||
virtual const GfBBox3d &GetBoundingBox() const = 0;
|
||||
|
||||
virtual int ResizedWidth() const = 0;
|
||||
|
||||
virtual int ResizedHeight() const = 0;
|
||||
|
||||
virtual int ResizedDepth() const = 0;
|
||||
|
||||
virtual HioFormat GetFormat() const = 0;
|
||||
|
||||
virtual bool Read() = 0;
|
||||
|
||||
virtual bool HasRawBuffer() const = 0;
|
||||
|
||||
virtual unsigned char const * GetRawBuffer() const = 0;
|
||||
|
||||
private:
|
||||
// Disallow copies
|
||||
HioFieldTextureData(const HioFieldTextureData&) = delete;
|
||||
HioFieldTextureData& operator=(const HioFieldTextureData&) = delete;
|
||||
|
||||
};
|
||||
|
||||
/// \class HioFieldTextureDataFactoryBase
|
||||
///
|
||||
/// A base class to make HioFieldTextureData objects, implemented by plugins.
|
||||
///
|
||||
class HIO_API HioFieldTextureDataFactoryBase : public TfType::FactoryBase
|
||||
{
|
||||
protected:
|
||||
friend class HioFieldTextureData;
|
||||
|
||||
virtual HioFieldTextureDataSharedPtr _New(
|
||||
std::string const & filePath,
|
||||
std::string const & fieldName,
|
||||
int fieldIndex,
|
||||
std::string const & fieldPurpose,
|
||||
size_t targetMemory) const = 0;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,282 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_GLSLFX_H
|
||||
#define PXR_IMAGING_HIO_GLSLFX_H
|
||||
|
||||
/// \file hio/glslfx.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hio/api.h"
|
||||
#include "pxr/imaging/hio/glslfxConfig.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/staticTokens.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
// Version 1 - Added HioGlslfx::ExtractImports
|
||||
//
|
||||
#define HIO_GLSLFX_API_VERSION 1
|
||||
|
||||
#define HIO_GLSLFX_TOKENS \
|
||||
(glslfx) \
|
||||
\
|
||||
(fragmentShader) \
|
||||
(geometryShader) \
|
||||
(geometryShaderInjection) \
|
||||
(preamble) \
|
||||
(tessControlShader) \
|
||||
(tessEvalShader) \
|
||||
(vertexShader) \
|
||||
(vertexShaderInjection) \
|
||||
\
|
||||
(surfaceShader) \
|
||||
(displacementShader) \
|
||||
(volumeShader) \
|
||||
((defVal, "default"))
|
||||
|
||||
|
||||
TF_DECLARE_PUBLIC_TOKENS(HioGlslfxTokens, HIO_API, HIO_GLSLFX_TOKENS);
|
||||
|
||||
/// \class HioGlslfx
|
||||
///
|
||||
/// A class representing the config and shader source of a glslfx file.
|
||||
///
|
||||
/// a HioGlslfx object is constructed by providing the path of a file whose
|
||||
/// contents look something like this:
|
||||
///
|
||||
/// \code
|
||||
/// -- glslfx version 0.1
|
||||
///
|
||||
/// -- configuration
|
||||
///
|
||||
/// {
|
||||
///
|
||||
/// 'textures' : {
|
||||
/// 'texture_1':{
|
||||
/// 'documentation' : 'a useful texture.',
|
||||
/// },
|
||||
/// 'texture_2':{
|
||||
/// 'documentation' : 'another useful texture.',
|
||||
/// },
|
||||
/// },
|
||||
/// 'parameters': {
|
||||
/// 'param_1' : {
|
||||
/// 'default' : 1.0,
|
||||
/// 'documentation' : 'the first parameter'
|
||||
/// },
|
||||
/// 'param_2' : {
|
||||
/// 'default' : [1.0, 1.0, 1.0],
|
||||
/// 'documentation' : 'a vec3f parameter'
|
||||
/// },
|
||||
/// 'param_3' : {
|
||||
/// 'default' : 2.0
|
||||
/// },
|
||||
/// 'param_4' : {
|
||||
/// 'default' : True
|
||||
/// },
|
||||
/// 'param_5' : {
|
||||
/// 'default' : [1.0, 1.0, 1.0],
|
||||
/// 'role' : 'color'
|
||||
/// 'documentation' : 'specifies a color for use in the shader'
|
||||
/// },
|
||||
/// },
|
||||
/// 'parameterOrder': ['param_1',
|
||||
/// 'param_2',
|
||||
/// 'param_3',
|
||||
/// 'param_4',
|
||||
/// 'param_5'],
|
||||
///
|
||||
/// 'techniques': {
|
||||
/// 'default': {
|
||||
/// 'fragmentShader': {
|
||||
/// 'source': [ 'MyFragment' ]
|
||||
/// }
|
||||
/// },
|
||||
/// 'metal': {
|
||||
/// 'fragmentShader': {
|
||||
/// 'source': [ 'MyFragment.Metal' ]
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// -- glsl MyFragment
|
||||
///
|
||||
/// uniform float param_1;
|
||||
/// uniform float param_2;
|
||||
/// uniform float param_3;
|
||||
/// uniform float param_4;
|
||||
/// uniform float param_5;
|
||||
///
|
||||
/// void main()
|
||||
/// {
|
||||
/// // ...
|
||||
/// // glsl code which consumes the various uniforms, and perhaps sets
|
||||
/// // gl_FragColor = someOutputColor;
|
||||
/// // ...
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
class HioGlslfx
|
||||
{
|
||||
public:
|
||||
/// Create an invalid glslfx object
|
||||
HIO_API
|
||||
HioGlslfx();
|
||||
|
||||
/// Create a glslfx object from a file
|
||||
HIO_API
|
||||
HioGlslfx(
|
||||
std::string const & filePath,
|
||||
TfToken const & technique = HioGlslfxTokens->defVal);
|
||||
|
||||
/// Create a glslfx object from a stream
|
||||
HIO_API
|
||||
HioGlslfx(
|
||||
std::istream &is,
|
||||
TfToken const & technique = HioGlslfxTokens->defVal);
|
||||
|
||||
/// Return the parameters specified in the configuration
|
||||
HIO_API
|
||||
HioGlslfxConfig::Parameters GetParameters() const;
|
||||
|
||||
/// Return the textures specified in the configuration
|
||||
HIO_API
|
||||
HioGlslfxConfig::Textures GetTextures() const;
|
||||
|
||||
/// Return the attributes specified in the configuration
|
||||
HIO_API
|
||||
HioGlslfxConfig::Attributes GetAttributes() const;
|
||||
|
||||
/// Return the metadata specified in the configuration
|
||||
HIO_API
|
||||
HioGlslfxConfig::MetadataDictionary GetMetadata() const;
|
||||
|
||||
/// Returns true if this is a valid glslfx file
|
||||
HIO_API
|
||||
bool IsValid(std::string *reason=NULL) const;
|
||||
|
||||
/// \name Access to commonly used shader sources.
|
||||
/// @{
|
||||
|
||||
/// Get the surface source string
|
||||
HIO_API
|
||||
std::string GetSurfaceSource() const;
|
||||
|
||||
/// Get the displacement source string
|
||||
HIO_API
|
||||
std::string GetDisplacementSource() const;
|
||||
|
||||
/// Get the volume source string
|
||||
HIO_API
|
||||
std::string GetVolumeSource() const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// Get the shader source associated with given key
|
||||
HIO_API
|
||||
std::string GetSource(const TfToken &shaderStageKey) const;
|
||||
|
||||
/// Get the original file name passed to the constructor
|
||||
const std::string &GetFilePath() const { return _globalContext.filename; }
|
||||
|
||||
/// Return set of all files processed for this glslfx object.
|
||||
/// This includes the original file given to the constructor
|
||||
/// as well as any other files that were imported. This set
|
||||
/// will only contain files that exist.
|
||||
const std::set<std::string>& GetFiles() const { return _seenFiles; }
|
||||
|
||||
/// Return the computed hash value based on the string
|
||||
size_t GetHash() const { return _hash; }
|
||||
|
||||
/// Extract imported files from the specified glslfx file. The returned
|
||||
/// paths are as-authored, in the order of declaration, with possible
|
||||
/// duplicates. This function is not recursive -- it only extracts imports
|
||||
/// from the specified \p filename.
|
||||
HIO_API
|
||||
static std::vector<std::string> ExtractImports(const std::string& filename);
|
||||
|
||||
private:
|
||||
class _ParseContext {
|
||||
public:
|
||||
_ParseContext() { }
|
||||
|
||||
_ParseContext(std::string const & filePath) :
|
||||
filename(filePath), lineNo(0), version(-1.0) { }
|
||||
|
||||
std::string filename;
|
||||
int lineNo;
|
||||
double version;
|
||||
std::string currentLine;
|
||||
std::string currentSectionType;
|
||||
std::string currentSectionId;
|
||||
std::vector<std::string> imports;
|
||||
};
|
||||
|
||||
private:
|
||||
bool _ProcessFile(std::string const & filePath,
|
||||
_ParseContext & context);
|
||||
bool _ProcessInput(std::istream * input,
|
||||
_ParseContext & context);
|
||||
bool _ProcessImport(_ParseContext & context);
|
||||
bool _ParseSectionLine(_ParseContext & context);
|
||||
bool _ParseGLSLSectionLine(std::vector<std::string> const &tokens,
|
||||
_ParseContext & context);
|
||||
bool _ParseVersionLine(std::vector<std::string> const &tokens,
|
||||
_ParseContext & context);
|
||||
bool _ParseConfigurationLine(_ParseContext & context);
|
||||
bool _ComposeConfiguration(std::string *reason);
|
||||
std::string _GetSource(const TfToken &shaderStageKey) const;
|
||||
|
||||
private:
|
||||
_ParseContext _globalContext;
|
||||
|
||||
typedef std::map<std::string, std::string> _SourceMap;
|
||||
|
||||
_SourceMap _sourceMap;
|
||||
_SourceMap _configMap;
|
||||
std::vector<std::string> _configOrder;
|
||||
std::set<std::string> _seenFiles;
|
||||
|
||||
std::unique_ptr<HioGlslfxConfig> _config;
|
||||
|
||||
TfToken _technique;
|
||||
|
||||
bool _valid;
|
||||
std::string _invalidReason; // if _valid is false, reason why
|
||||
size_t _hash;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_GLSLFX_CONFIG_H
|
||||
#define PXR_IMAGING_HIO_GLSLFX_CONFIG_H
|
||||
|
||||
/// \file hio/glslfxConfig.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hio/api.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/vt/dictionary.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// \class HioGlslfxConfig
|
||||
///
|
||||
/// A class representing the configuration of a glslfx file.
|
||||
///
|
||||
/// HioGlslfxConfig provides an API for querying the configuration of a
|
||||
/// glslfx file
|
||||
///
|
||||
class HioGlslfxConfig
|
||||
{
|
||||
public:
|
||||
/// Enumerates Roles that parameters can have.
|
||||
///
|
||||
/// <b>enum Role:</b>
|
||||
/// <ul>
|
||||
/// <li><b><c> RoleNone = 0</c></b> None: the default role
|
||||
/// <li><b><c> RoleColor = 1</c></b> Color: the role of a color
|
||||
/// </ul>
|
||||
///
|
||||
enum Role {
|
||||
RoleNone = 0,
|
||||
RoleColor = 1,
|
||||
};
|
||||
|
||||
/// \class Parameter
|
||||
///
|
||||
/// A class representing a parameter.
|
||||
///
|
||||
class Parameter {
|
||||
public:
|
||||
Parameter(std::string const & name,
|
||||
VtValue const & defaultValue,
|
||||
std::string const & docString = "",
|
||||
Role const & role = RoleNone) :
|
||||
name(name),
|
||||
defaultValue(defaultValue),
|
||||
docString(docString),
|
||||
role(role) { }
|
||||
|
||||
std::string name;
|
||||
VtValue defaultValue;
|
||||
std::string docString;
|
||||
Role role;
|
||||
};
|
||||
|
||||
typedef std::vector<Parameter> Parameters;
|
||||
|
||||
/// \class Texture
|
||||
///
|
||||
/// A class representing a texture.
|
||||
///
|
||||
class Texture {
|
||||
public:
|
||||
Texture(std::string const & name,
|
||||
VtValue const & defaultValue,
|
||||
std::string const & docString = "") :
|
||||
name(name),
|
||||
defaultValue(defaultValue),
|
||||
docString(docString) { }
|
||||
|
||||
std::string name;
|
||||
VtValue defaultValue;
|
||||
std::string docString;
|
||||
};
|
||||
|
||||
typedef std::vector<Texture> Textures;
|
||||
|
||||
/// \class Attribute
|
||||
///
|
||||
/// A class representing an attribute.
|
||||
///
|
||||
class Attribute {
|
||||
public:
|
||||
Attribute(std::string const & name,
|
||||
VtValue const & defaultValue,
|
||||
std::string const & docString = "") :
|
||||
name(name),
|
||||
defaultValue(defaultValue),
|
||||
docString(docString) { }
|
||||
|
||||
std::string name;
|
||||
VtValue defaultValue;
|
||||
std::string docString;
|
||||
};
|
||||
|
||||
typedef std::vector<Attribute> Attributes;
|
||||
|
||||
/// Create a new HioGlslfxConfig from an input string
|
||||
///
|
||||
/// The \p filename parameter is only used for error reporting.
|
||||
///
|
||||
HIO_API
|
||||
static HioGlslfxConfig * Read(TfToken const & technique,
|
||||
std::string const & input,
|
||||
std::string const & filename,
|
||||
std::string *errorStr);
|
||||
|
||||
typedef std::vector<std::string> SourceKeys;
|
||||
|
||||
typedef VtDictionary MetadataDictionary;
|
||||
|
||||
/// Return the set of source keys for a particular shader stage
|
||||
HIO_API
|
||||
SourceKeys GetSourceKeys(TfToken const & shaderStageKey) const;
|
||||
|
||||
/// Return the parameters specified in the configuration
|
||||
HIO_API
|
||||
Parameters GetParameters() const;
|
||||
|
||||
/// Return the textures specified in the configuration
|
||||
HIO_API
|
||||
Textures GetTextures() const;
|
||||
|
||||
/// Returns the attributes specified in the configuration
|
||||
HIO_API
|
||||
Attributes GetAttributes() const;
|
||||
|
||||
/// Returns the metadata specified in the configuration
|
||||
HIO_API
|
||||
MetadataDictionary GetMetadata() const;
|
||||
|
||||
private:
|
||||
// private ctor. should only be called by ::Read
|
||||
HioGlslfxConfig(TfToken const& technique,
|
||||
VtDictionary const & dict,
|
||||
std::string *errorStr);
|
||||
|
||||
void _Init(VtDictionary const & dict, std::string *errorStr);
|
||||
|
||||
Parameters _GetParameters(VtDictionary const & dict,
|
||||
std::string *errorStr) const;
|
||||
Textures _GetTextures(VtDictionary const & dict,
|
||||
std::string *errorStr) const;
|
||||
|
||||
Attributes _GetAttributes(VtDictionary const & dict,
|
||||
std::string *errorStr) const;
|
||||
|
||||
MetadataDictionary _GetMetadata(VtDictionary const & dict,
|
||||
std::string *errorStr) const;
|
||||
|
||||
typedef std::map<std::string, SourceKeys> _SourceKeyMap;
|
||||
_SourceKeyMap _GetSourceKeyMap(VtDictionary const & dict,
|
||||
std::string *errorStr) const;
|
||||
|
||||
TfToken _technique;
|
||||
Parameters _params;
|
||||
Textures _textures;
|
||||
Attributes _attributes;
|
||||
MetadataDictionary _metadata;
|
||||
_SourceKeyMap _sourceKeyMap;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,219 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_IMAGE_H
|
||||
#define PXR_IMAGING_HIO_IMAGE_H
|
||||
|
||||
/// \file hio/image.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hio/api.h"
|
||||
#include "pxr/imaging/hio/types.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
#include "pxr/base/vt/dictionary.h"
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
using HioImageSharedPtr = std::shared_ptr<class HioImage>;
|
||||
|
||||
/// \class HioImage
|
||||
///
|
||||
/// A base class for reading and writing texture image data.
|
||||
///
|
||||
/// The class allows basic access to texture image file data.
|
||||
///
|
||||
class HioImage
|
||||
{
|
||||
public:
|
||||
|
||||
/// Specifies whether to treat the image origin as the upper-left corner
|
||||
/// or the lower left
|
||||
enum ImageOriginLocation
|
||||
{
|
||||
OriginUpperLeft,
|
||||
OriginLowerLeft
|
||||
};
|
||||
|
||||
/// Specifies the source color space in which the texture is encoded, with
|
||||
/// "Auto" indicating the texture reader should determine color space based
|
||||
/// on hints from the image (e.g. file type, number of channels, image
|
||||
/// metadata)
|
||||
enum SourceColorSpace
|
||||
{
|
||||
Raw,
|
||||
SRGB,
|
||||
Auto
|
||||
};
|
||||
|
||||
/// \class StorageSpec
|
||||
///
|
||||
/// Describes the memory layout and storage of a texture image
|
||||
///
|
||||
class StorageSpec
|
||||
{
|
||||
public:
|
||||
StorageSpec()
|
||||
: width(0), height(0), depth(0)
|
||||
, format(HioFormatInvalid)
|
||||
, flipped(false)
|
||||
, data(0) { }
|
||||
|
||||
int width, height, depth;
|
||||
HioFormat format;
|
||||
bool flipped;
|
||||
void * data;
|
||||
};
|
||||
|
||||
public:
|
||||
HioImage() = default;
|
||||
|
||||
HIO_API
|
||||
virtual ~HioImage();
|
||||
|
||||
// Disallow copies
|
||||
HioImage(const HioImage&) = delete;
|
||||
HioImage& operator=(const HioImage&) = delete;
|
||||
|
||||
/// Returns whether \a filename opened as a texture image.
|
||||
HIO_API
|
||||
static bool IsSupportedImageFile(std::string const & filename);
|
||||
|
||||
/// \name Reading
|
||||
/// {@
|
||||
|
||||
/// Opens \a filename for reading from the given \a subimage at mip level
|
||||
/// \a mip, using \a sourceColorSpace to help determine the color space
|
||||
/// with which to interpret the texture
|
||||
HIO_API
|
||||
static HioImageSharedPtr OpenForReading(std::string const & filename,
|
||||
int subimage = 0,
|
||||
int mip = 0,
|
||||
SourceColorSpace sourceColorSpace =
|
||||
SourceColorSpace::Auto,
|
||||
bool suppressErrors = false);
|
||||
|
||||
/// Reads the image file into \a storage.
|
||||
virtual bool Read(StorageSpec const & storage) = 0;
|
||||
|
||||
/// Reads the cropped sub-image into \a storage.
|
||||
virtual bool ReadCropped(int const cropTop,
|
||||
int const cropBottom,
|
||||
int const cropLeft,
|
||||
int const cropRight,
|
||||
StorageSpec const & storage) = 0;
|
||||
|
||||
/// }@
|
||||
|
||||
/// \name Writing
|
||||
/// {@
|
||||
|
||||
/// Opens \a filename for writing from the given \a storage.
|
||||
HIO_API
|
||||
static HioImageSharedPtr OpenForWriting(std::string const & filename);
|
||||
|
||||
/// Writes the image with \a metadata.
|
||||
virtual bool Write(StorageSpec const & storage,
|
||||
VtDictionary const & metadata = VtDictionary()) = 0;
|
||||
|
||||
/// }@
|
||||
|
||||
/// Returns the image filename.
|
||||
virtual std::string const & GetFilename() const = 0;
|
||||
|
||||
/// Returns the image width.
|
||||
virtual int GetWidth() const = 0;
|
||||
|
||||
/// Returns the image height.
|
||||
virtual int GetHeight() const = 0;
|
||||
|
||||
/// Returns the destination HioFormat.
|
||||
virtual HioFormat GetFormat() const = 0;
|
||||
|
||||
/// Returns the number of bytes per pixel.
|
||||
virtual int GetBytesPerPixel() const = 0;
|
||||
|
||||
/// Returns the number of mips available.
|
||||
virtual int GetNumMipLevels() const = 0;
|
||||
|
||||
/// Returns whether the image is in the sRGB color space.
|
||||
virtual bool IsColorSpaceSRGB() const = 0;
|
||||
|
||||
/// \name Metadata
|
||||
/// {@
|
||||
template <typename T>
|
||||
bool GetMetadata(TfToken const & key, T * value) const;
|
||||
|
||||
virtual bool GetMetadata(TfToken const & key, VtValue * value) const = 0;
|
||||
|
||||
virtual bool GetSamplerMetadata(HioAddressDimension dim,
|
||||
HioAddressMode * param) const = 0;
|
||||
|
||||
/// }@
|
||||
|
||||
protected:
|
||||
virtual bool _OpenForReading(std::string const & filename,
|
||||
int subimage,
|
||||
int mip,
|
||||
SourceColorSpace sourceColorSpace,
|
||||
bool suppressErrors) = 0;
|
||||
|
||||
virtual bool _OpenForWriting(std::string const & filename) = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool
|
||||
HioImage::GetMetadata(TfToken const & key, T * value) const
|
||||
{
|
||||
VtValue any;
|
||||
if (!GetMetadata(key, &any) || !any.IsHolding<T>()) {
|
||||
return false;
|
||||
}
|
||||
*value = any.UncheckedGet<T>();
|
||||
return true;
|
||||
}
|
||||
|
||||
class HIO_API HioImageFactoryBase : public TfType::FactoryBase {
|
||||
public:
|
||||
virtual HioImageSharedPtr New() const = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class HioImageFactory : public HioImageFactoryBase {
|
||||
public:
|
||||
virtual HioImageSharedPtr New() const
|
||||
{
|
||||
return HioImageSharedPtr(new T);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_IMAGING_HIO_IMAGE_H
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_IMAGE_REGISTRY_H
|
||||
#define PXR_IMAGING_HIO_IMAGE_REGISTRY_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hio/api.h"
|
||||
#include "pxr/base/tf/singleton.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
using HioImageSharedPtr = std::shared_ptr<class HioImage>;
|
||||
|
||||
class HioRankedTypeMap;
|
||||
|
||||
/// \class HioImageRegistry
|
||||
///
|
||||
/// Manages plugin registration and loading for HioImage subclasses.
|
||||
///
|
||||
class HioImageRegistry : public TfSingleton<HioImageRegistry>
|
||||
{
|
||||
public:
|
||||
HIO_API
|
||||
static HioImageRegistry& GetInstance();
|
||||
|
||||
HIO_API
|
||||
bool IsSupportedImageFile(std::string const & filename);
|
||||
|
||||
private:
|
||||
friend class TfSingleton<HioImageRegistry>;
|
||||
HioImageRegistry();
|
||||
|
||||
friend class HioImage;
|
||||
|
||||
HioImageSharedPtr _ConstructImage(std::string const & filename);
|
||||
|
||||
private:
|
||||
std::unique_ptr<HioRankedTypeMap> const _typeMap;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_IMAGING_HIO_IMAGE_REGISTRY_H
|
||||
@@ -0,0 +1,216 @@
|
||||
//
|
||||
// Copyright 2020 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_IMAGING_HIO_TYPES_H
|
||||
#define PXR_IMAGING_HIO_TYPES_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/imaging/hio/api.h"
|
||||
#include <stdlib.h>
|
||||
#include <cinttypes>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class GfVec3i;
|
||||
|
||||
/// \enum HioFormat
|
||||
///
|
||||
/// HioFormat describes the memory format of image buffers used in Hio.
|
||||
///
|
||||
/// For reference, see:
|
||||
/// https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#VkFormat
|
||||
enum HioFormat
|
||||
{
|
||||
HioFormatInvalid=-1,
|
||||
|
||||
// UNorm8 - a 1-byte value representing a float between 0 and 1.
|
||||
// float value = (unorm / 255.0f);
|
||||
HioFormatUNorm8=0,
|
||||
HioFormatUNorm8Vec2,
|
||||
HioFormatUNorm8Vec3,
|
||||
HioFormatUNorm8Vec4,
|
||||
|
||||
// SNorm8 - a 1-byte value representing a float between -1 and 1.
|
||||
// float value = max(snorm / 127.0f, -1.0f);
|
||||
HioFormatSNorm8,
|
||||
HioFormatSNorm8Vec2,
|
||||
HioFormatSNorm8Vec3,
|
||||
HioFormatSNorm8Vec4,
|
||||
|
||||
// Float16 - a 2-byte IEEE half-precision float.
|
||||
HioFormatFloat16,
|
||||
HioFormatFloat16Vec2,
|
||||
HioFormatFloat16Vec3,
|
||||
HioFormatFloat16Vec4,
|
||||
|
||||
// Float32 - a 4-byte IEEE float.
|
||||
HioFormatFloat32,
|
||||
HioFormatFloat32Vec2,
|
||||
HioFormatFloat32Vec3,
|
||||
HioFormatFloat32Vec4,
|
||||
|
||||
// Double64 - a 8-byte IEEE double.
|
||||
HioFormatDouble64,
|
||||
HioFormatDouble64Vec2,
|
||||
HioFormatDouble64Vec3,
|
||||
HioFormatDouble64Vec4,
|
||||
|
||||
// UInt16 - a 2-byte unsigned short integer.
|
||||
HioFormatUInt16,
|
||||
HioFormatUInt16Vec2,
|
||||
HioFormatUInt16Vec3,
|
||||
HioFormatUInt16Vec4,
|
||||
|
||||
// Int16 - a 2-byte signed short integer.
|
||||
HioFormatInt16,
|
||||
HioFormatInt16Vec2,
|
||||
HioFormatInt16Vec3,
|
||||
HioFormatInt16Vec4,
|
||||
|
||||
// UInt32 - a 4-byte unsigned integer.
|
||||
HioFormatUInt32,
|
||||
HioFormatUInt32Vec2,
|
||||
HioFormatUInt32Vec3,
|
||||
HioFormatUInt32Vec4,
|
||||
|
||||
// Int32 - a 4-byte signed integer.
|
||||
HioFormatInt32,
|
||||
HioFormatInt32Vec2,
|
||||
HioFormatInt32Vec3,
|
||||
HioFormatInt32Vec4,
|
||||
|
||||
// UNorm8 SRGB - a 1-byte value representing a float between 0 and 1.
|
||||
HioFormatUNorm8srgb,
|
||||
HioFormatUNorm8Vec2srgb,
|
||||
HioFormatUNorm8Vec3srgb,
|
||||
HioFormatUNorm8Vec4srgb,
|
||||
|
||||
// BPTC compressed. 3-component, 4x4 blocks, signed floating-point
|
||||
HioFormatBC6FloatVec3,
|
||||
|
||||
// BPTC compressed. 3-component, 4x4 blocks, unsigned floating-point
|
||||
HioFormatBC6UFloatVec3,
|
||||
|
||||
// BPTC compressed. 4-component, 4x4 blocks, unsigned byte.
|
||||
// Representing a float between 0 and 1.
|
||||
HioFormatBC7UNorm8Vec4,
|
||||
|
||||
// BPTC compressed. 4-component, 4x4 blocks, unsigned byte, sRGB.
|
||||
// Representing a float between 0 and 1.
|
||||
HioFormatBC7UNorm8Vec4srgb,
|
||||
|
||||
// S3TC/DXT compressed. 4-component, 4x4 blocks, unsigned byte
|
||||
// Representing a float between 0 and 1.
|
||||
HioFormatBC1UNorm8Vec4,
|
||||
|
||||
// S3TC/DXT compressed. 4-component, 4x4 blocks, unsigned byte
|
||||
// Representing a float between 0 and 1.
|
||||
HioFormatBC3UNorm8Vec4,
|
||||
|
||||
HioFormatCount
|
||||
};
|
||||
|
||||
/// \enum HioAddressDimension
|
||||
///
|
||||
/// Available texture sampling dimensions.
|
||||
///
|
||||
enum HioAddressDimension
|
||||
{
|
||||
HioAddressDimensionU,
|
||||
HioAddressDimensionV,
|
||||
HioAddressDimensionW
|
||||
};
|
||||
|
||||
/// \enum HioAddressMode
|
||||
///
|
||||
/// Various modes used during sampling of a texture.
|
||||
///
|
||||
enum HioAddressMode
|
||||
{
|
||||
HioAddressModeClampToEdge = 0,
|
||||
HioAddressModeMirrorClampToEdge,
|
||||
HioAddressModeRepeat,
|
||||
HioAddressModeMirrorRepeat,
|
||||
HioAddressModeClampToBorderColor
|
||||
};
|
||||
|
||||
/// \enum HioColorChannelType
|
||||
///
|
||||
/// Various color channel representation formats.
|
||||
///
|
||||
enum HioType
|
||||
{
|
||||
HioTypeUnsignedByte,
|
||||
HioTypeUnsignedByteSRGB,
|
||||
HioTypeSignedByte,
|
||||
HioTypeUnsignedShort,
|
||||
HioTypeSignedShort,
|
||||
HioTypeUnsignedInt,
|
||||
HioTypeInt,
|
||||
HioTypeHalfFloat,
|
||||
HioTypeFloat,
|
||||
HioTypeDouble,
|
||||
|
||||
HioTypeCount
|
||||
};
|
||||
|
||||
/// Returns the HioFormat of containing nChannels of HioType type.
|
||||
HIO_API
|
||||
HioFormat HioGetFormat(uint32_t nchannels,
|
||||
HioType type,
|
||||
bool isSRGB);
|
||||
|
||||
/// Return the HioType corresponding to the given HioFormat
|
||||
HIO_API
|
||||
HioType HioGetHioType(HioFormat);
|
||||
|
||||
/// Return the count of components (channels) in the given HioFormat.
|
||||
HIO_API
|
||||
int HioGetComponentCount(HioFormat format);
|
||||
|
||||
/// Return the size in bytes for a component (channel) in the given HioFormat.
|
||||
HIO_API
|
||||
size_t HioGetDataSizeOfType(HioFormat hioFormat);
|
||||
|
||||
/// Return the size in bytes for a component (channel) in the given HioType.
|
||||
HIO_API
|
||||
size_t HioGetDataSizeOfType(HioType type);
|
||||
|
||||
/// Returns the size of bytes per pixel for the given HioFormat
|
||||
HIO_API
|
||||
size_t HioGetDataSizeOfFormat(HioFormat format,
|
||||
size_t *blockWidth = nullptr,
|
||||
size_t *blockHeight = nullptr);
|
||||
|
||||
/// Return if the given format is compressed.
|
||||
HIO_API
|
||||
bool HioIsCompressed(HioFormat format);
|
||||
|
||||
/// Calculate the byte size of texture. If compressed, takes block size
|
||||
/// into account.
|
||||
HIO_API
|
||||
size_t HioGetDataSize(const HioFormat hioFormat, const GfVec3i &dimensions);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user