Loading...
Searching...
No Matches
ptexTextureObject.h
1//
2// Copyright 2020 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_ST_PTEX_TEXTURE_OBJECT_H
8#define PXR_IMAGING_HD_ST_PTEX_TEXTURE_OBJECT_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hdSt/textureObject.h"
13
14#include "pxr/imaging/hgi/handle.h"
15
16#include "pxr/base/gf/vec2i.h"
17#include "pxr/base/gf/vec3i.h"
18
19#ifdef PXR_PTEX_SUPPORT_ENABLED
20#include "pxr/imaging/hdSt/ptexMipmapTextureLoader.h"
21#endif
22
23PXR_NAMESPACE_OPEN_SCOPE
24
33HDST_API bool HdStIsSupportedPtexTexture(std::string const & imageFilePath);
34
35enum HgiFormat : int;
37
43{
44public:
45 HDST_API
47 const HdStTextureIdentifier &textureId,
48 HdSt_TextureObjectRegistry *textureObjectRegistry);
49
50 HDST_API
51 ~HdStPtexTextureObject() override;
52
57 HgiTextureHandle GetTexelTexture() const { return _texelTexture; }
58
63 HgiTextureHandle GetLayoutTexture() const { return _layoutTexture; }
64
65 HDST_API
66 bool IsValid() const override;
67
68 HDST_API
69 HdStTextureType GetTextureType() const override;
70
71protected:
72 HDST_API
73 void _Load() override;
74
75 HDST_API
76 void _Commit() override;
77
78private:
79 HgiFormat _format;
80 GfVec3i _texelDimensions;
81 int _texelLayers;
82 size_t _texelDataSize;
83 GfVec2i _layoutDimensions;
84 size_t _layoutDataSize;
85
86 std::unique_ptr<uint8_t[]> _texelData;
87 std::unique_ptr<uint8_t[]> _layoutData;
88
89 HgiTextureHandle _texelTexture;
90 HgiTextureHandle _layoutTexture;
91
92 void _DestroyTextures();
93};
94
95template<>
96struct HdSt_TypedTextureObjectHelper<HdStTextureType::Ptex> {
97 using type = HdStPtexTextureObject;
98};
99
100PXR_NAMESPACE_CLOSE_SCOPE
101
102#endif
Basic type for a vector of 2 int components.
Definition: vec2i.h:44
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
HDST_API void _Load() override
Load texture to CPU (thread-safe)
HgiTextureHandle GetTexelTexture() const
Get the GPU texture handle for the texels.
HDST_API bool IsValid() const override
Is texture valid? Only correct after commit phase.
HDST_API void _Commit() override
Commit texture to GPU (not thread-safe)
HgiTextureHandle GetLayoutTexture() const
Get the GPU texture handle for the layout.
HDST_API HdStTextureType GetTextureType() const override
Get texture type.
Class to identify a texture file or a texture within the texture file (e.g., a frame in a movie).
Base class for a texture object.
Definition: textureObject.h:43