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
71 HDST_API
72 size_t GetCommittedSize() const override;
73
74protected:
75 HDST_API
76 void _Load() override;
77
78 HDST_API
79 void _Commit() override;
80
81private:
82 HgiFormat _format;
83 GfVec3i _texelDimensions;
84 int _texelLayers;
85 size_t _texelDataSize;
86 GfVec2i _layoutDimensions;
87 size_t _layoutDataSize;
88
89 std::unique_ptr<uint8_t[]> _texelData;
90 std::unique_ptr<uint8_t[]> _layoutData;
91
92 HgiTextureHandle _texelTexture;
93 HgiTextureHandle _layoutTexture;
94
95 void _DestroyTextures();
96};
97
98template<>
99struct HdSt_TypedTextureObjectHelper<HdStTextureType::Ptex> {
100 using type = HdStPtexTextureObject;
101};
102
103PXR_NAMESPACE_CLOSE_SCOPE
104
105#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)
HDST_API size_t GetCommittedSize() const override
Returns the actual amount of memory committed to the GPU.
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