Loading...
Searching...
No Matches
drawItem.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_IMAGING_HD_ST_DRAW_ITEM_H
25#define PXR_IMAGING_HD_ST_DRAW_ITEM_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hdSt/api.h"
29
30#include "pxr/imaging/hd/drawItem.h"
31
32PXR_NAMESPACE_OPEN_SCOPE
33
34
35using HdSt_GeometricShaderSharedPtr =
36 std::shared_ptr<class HdSt_GeometricShader>;
37using HdSt_MaterialNetworkShaderSharedPtr =
38 std::shared_ptr<class HdSt_MaterialNetworkShader>;
39
40class HdStDrawItem : public HdDrawItem
41{
42public:
43 HF_MALLOC_TAG_NEW("new HdStDrawItem");
44
45 HDST_API
46 HdStDrawItem(HdRprimSharedData const *sharedData);
47
48 HDST_API
49 ~HdStDrawItem() override;
50
52 bool HasInstancer() const {
53 TF_VERIFY(_GetSharedData()->instancerLevels != -1);
54 return (_GetSharedData()->instancerLevels > 0);
55 }
56
58 int GetInstancePrimvarNumLevels() const {
59 TF_VERIFY(_GetSharedData()->instancerLevels != -1);
60 return _GetSharedData()->instancerLevels;
61 }
62
74 HdBufferArrayRangeSharedPtr const &
75 GetInstancePrimvarRange(int level) const {
76 return _GetSharedData()->barContainer.Get(
77 _GetDrawingCoord().GetInstancePrimvarIndex(level));
78 }
79
81 HdBufferArrayRangeSharedPtr const &GetInstanceIndexRange() const {
82 return _GetSharedData()->barContainer.Get(
83 _GetDrawingCoord().GetInstanceIndexIndex());
84 }
85
87 HdBufferArrayRangeSharedPtr const &GetConstantPrimvarRange() const {
88 return _GetSharedData()->barContainer.Get(
89 _GetDrawingCoord().GetConstantPrimvarIndex());
90 }
91
93 HdBufferArrayRangeSharedPtr const &GetElementPrimvarRange() const {
94 return _GetSharedData()->barContainer.Get(
95 _GetDrawingCoord().GetElementPrimvarIndex());
96 }
97
99 HdBufferArrayRangeSharedPtr const &GetVertexPrimvarRange() const {
100 return _GetSharedData()->barContainer.Get(
101 _GetDrawingCoord().GetVertexPrimvarIndex());
102 }
103
105 HdBufferArrayRangeSharedPtr const &GetVaryingPrimvarRange() const {
106 return _GetSharedData()->barContainer.Get(
107 _GetDrawingCoord().GetVaryingPrimvarIndex());
108 }
109
111 HdBufferArrayRangeSharedPtr const &GetFaceVaryingPrimvarRange() const {
112 return _GetSharedData()->barContainer.Get(
113 _GetDrawingCoord().GetFaceVaryingPrimvarIndex());
114 }
115
117 HdBufferArrayRangeSharedPtr const &GetTopologyRange() const {
118 return _GetSharedData()->barContainer.Get(
119 _GetDrawingCoord().GetTopologyIndex());
120 }
121
123 HdBufferArrayRangeSharedPtr const &GetTopologyVisibilityRange() const {
124 return _GetSharedData()->barContainer.Get(
125 _GetDrawingCoord().GetTopologyVisibilityIndex());
126 }
127
129 TopologyToPrimvarVector const &GetFvarTopologyToPrimvarVector() const {
130 return _GetSharedData()->fvarTopologyToPrimvarVector;
131 }
132
133 void SetGeometricShader(HdSt_GeometricShaderSharedPtr const &shader) {
134 _geometricShader = shader;
135 }
136
137 HdSt_GeometricShaderSharedPtr const &GetGeometricShader() const {
138 return _geometricShader;
139 }
140
141 HdSt_MaterialNetworkShaderSharedPtr const &
142 GetMaterialNetworkShader() const {
143 return _materialNetworkShader;
144 }
145
146 void SetMaterialNetworkShader(
147 HdSt_MaterialNetworkShaderSharedPtr const &shader) {
148 _materialNetworkShader = shader;
149 }
150
151 bool GetMaterialIsFinal() const {
152 return _materialIsFinal;
153 }
154
155 void SetMaterialIsFinal(bool isFinal) {
156 _materialIsFinal = isFinal;
157 }
158
163 HDST_API
164 bool IntersectsViewVolume(GfMatrix4d const &viewProjMatrix) const;
165
171 HDST_API
172 size_t GetBufferArraysHash() const;
173
178 HDST_API
179 size_t GetElementOffsetsHash() const;
180
181private:
182 HdSt_GeometricShaderSharedPtr _geometricShader;
183 HdSt_MaterialNetworkShaderSharedPtr _materialNetworkShader;
184 bool _materialIsFinal;
185};
186
187
188PXR_NAMESPACE_CLOSE_SCOPE
189
190#endif //PXR_IMAGING_HD_ST_DRAW_ITEM_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
A draw item is a light-weight representation of an HdRprim's resources and material to be used for re...
Definition: drawItem.h:65
HdRprimSharedData const * _GetSharedData() const
Returns the shared data.
Definition: drawItem.h:109
HdDrawingCoord const & _GetDrawingCoord() const
Returns the drawingCoord.
Definition: drawItem.h:104
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:283