Skip to content

Commit

Permalink
Merged Windows port into hdx.
Browse files Browse the repository at this point in the history
(Internal change: 1725336)
  • Loading branch information
pixar-oss committed Mar 17, 2017
1 parent 75cdaa3 commit de35592
Show file tree
Hide file tree
Showing 29 changed files with 240 additions and 33 deletions.
3 changes: 2 additions & 1 deletion pxr/imaging/lib/hdx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pxr_shared_library(hdx

PUBLIC_CLASSES
camera
debugCodes
drawTarget
drawTargetAttachmentDesc
drawTargetAttachmentDescArray
Expand Down Expand Up @@ -49,8 +48,10 @@ pxr_shared_library(hdx
PUBLIC_HEADERS
shadowMatrixComputation.h
version.h
api.h

PRIVATE_CLASSES
debugCodes
drawTargetTextureResource
unitTestDelegate

Expand Down
47 changes: 47 additions & 0 deletions pxr/imaging/lib/hdx/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Copyright 2017 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 HDX_API_H
#define HDX_API_H

#include "pxr/base/arch/export.h"

#if defined(HDX_STATIC)
# define HDX_API
# define HDX_API_TEMPLATE_CLASS(...)
# define HDX_API_TEMPLATE_STRUCT(...)
# define HDX_LOCAL
#else
# if defined(HDX_EXPORTS)
# define HDX_API ARCH_EXPORT
# define HDX_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
# define HDX_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
# else
# define HDX_API ARCH_IMPORT
# define HDX_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
# define HDX_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
# endif
# define HDX_LOCAL ARCH_HIDDEN
#endif

#endif // HDX_API_H
2 changes: 1 addition & 1 deletion pxr/imaging/lib/hdx/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ HdxCamera::Sync(HdSceneDelegate *sceneDelegate,

// extract view/projection matrices
VtValue vMatrices = sceneDelegate->Get(id, HdxCameraTokens->matrices);
if (not vMatrices.IsEmpty()) {
if (!vMatrices.IsEmpty()) {
const HdxCameraMatrices matrices =
vMatrices.Get<HdxCameraMatrices>();
worldToViewMatrix = matrices.viewMatrix;
Expand Down
11 changes: 10 additions & 1 deletion pxr/imaging/lib/hdx/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define HDX_CAMERA_H

#include "pxr/pxr.h"
#include "pxr/imaging/hdx/api.h"
#include "pxr/imaging/hd/version.h"
#include "pxr/imaging/hd/sprim.h"

Expand All @@ -47,7 +48,7 @@ PXR_NAMESPACE_OPEN_SCOPE
(projectionMatrix) \
(windowPolicy)

TF_DECLARE_PUBLIC_TOKENS(HdxCameraTokens, HDX_CAMERA_TOKENS);
TF_DECLARE_PUBLIC_TOKENS(HdxCameraTokens, HDX_API, HDX_CAMERA_TOKENS);

class HdSceneDelegate;

Expand All @@ -59,7 +60,9 @@ class HdxCamera : public HdSprim {
public:
typedef std::vector<GfVec4d> ClipPlanesVector;

HDX_API
HdxCamera(SdfPath const & id);
HDX_API
~HdxCamera(); // note: not virtual (for now)

// change tracking for HdxCamera
Expand All @@ -74,16 +77,19 @@ class HdxCamera : public HdSprim {
};

/// Synchronizes state from the delegate to this object.
HDX_API
virtual void Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits) override;

/// Accessor for tasks to get the parameters cached in this object.
HDX_API
virtual VtValue Get(TfToken const &token) const override;

/// Returns the minimal set of dirty bits to place in the
/// change tracker for use in the first sync of this prim.
/// Typically this would be all dirty bits.
HDX_API
virtual HdDirtyBits GetInitialDirtyBitsMask() const override;

private:
Expand All @@ -108,8 +114,11 @@ struct HdxCameraMatrices
};

// VtValue requirements
HDX_API
std::ostream& operator<<(std::ostream& out, const HdxCameraMatrices& pv);
HDX_API
bool operator==(const HdxCameraMatrices& lhs, const HdxCameraMatrices& rhs);
HDX_API
bool operator!=(const HdxCameraMatrices& lhs, const HdxCameraMatrices& rhs);


Expand Down
1 change: 1 addition & 0 deletions pxr/imaging/lib/hdx/drawTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/imaging/glf/glew.h"
#include "pxr/imaging/hdx/drawTarget.h"
#include "pxr/imaging/hdx/drawTargetAttachmentDescArray.h"
#include "pxr/imaging/hdx/drawTargetTextureResource.h"
Expand Down
12 changes: 10 additions & 2 deletions pxr/imaging/lib/hdx/drawTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
#define HDX_DRAW_TARGET_H

#include "pxr/pxr.h"
#include "pxr/imaging/hdx/api.h"
#include "pxr/imaging/hdx/drawTargetRenderPassState.h"
#include "pxr/imaging/hd/enums.h"
#include "pxr/imaging/hd/rprimCollection.h"
#include "pxr/imaging/hd/sprim.h"
#include "pxr/imaging/hd/textureResource.h"
#include "pxr/imaging/hdx/drawTargetRenderPassState.h"
#include "pxr/imaging/glf/drawTarget.h"

#include "pxr/usd/sdf/path.h"
Expand All @@ -51,7 +52,7 @@ PXR_NAMESPACE_OPEN_SCOPE
(enable) \
(resolution)

TF_DECLARE_PUBLIC_TOKENS(HdxDrawTargetTokens, HDX_DRAW_TARGET_TOKENS);
TF_DECLARE_PUBLIC_TOKENS(HdxDrawTargetTokens, HDX_API, HDX_DRAW_TARGET_TOKENS);

class HdSceneDelegate;
class HdRenderIndex;
Expand All @@ -72,7 +73,9 @@ typedef std::vector<class HdxDrawTarget const *> HdxDrawTargetPtrConstVector;
///
class HdxDrawTarget : public HdSprim {
public:
HDX_API
HdxDrawTarget(SdfPath const & id);
HDX_API
virtual ~HdxDrawTarget();

/// Dirty bits for the HdxDrawTarget object
Expand Down Expand Up @@ -101,16 +104,19 @@ class HdxDrawTarget : public HdSprim {
unsigned int GetVersion() const { return _version; }

/// Synchronizes state from the delegate to this object.
HDX_API
virtual void Sync(HdSceneDelegate *sceneDelegate,
HdRenderParam *renderParam,
HdDirtyBits *dirtyBits) override;

/// Accessor for tasks to get the parameters cached in this object.
HDX_API
virtual VtValue Get(TfToken const &token) const override;

/// Returns the minimal set of dirty bits to place in the
/// change tracker for use in the first sync of this prim.
/// Typically this would be all dirty bits.
HDX_API
virtual HdDirtyBits GetInitialDirtyBitsMask() const override;


Expand All @@ -125,11 +131,13 @@ class HdxDrawTarget : public HdSprim {
}

/// Debug api to output the contents of the draw target to a png file.
HDX_API
bool WriteToFile(const HdRenderIndex &renderIndex,
const std::string &attachment,
const std::string &path) const;

/// returns all HdxDrawTargets in the render index
HDX_API
static void GetDrawTargets(HdSceneDelegate *sceneDelegate,
HdxDrawTargetPtrConstVector *drawTargets);

Expand Down
11 changes: 11 additions & 0 deletions pxr/imaging/lib/hdx/drawTargetAttachmentDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define HDX_DRAW_TARGET_ATTACHMENT_DESC_H

#include "pxr/pxr.h"
#include "pxr/imaging/hdx/api.h"
#include "pxr/imaging/hd/version.h"
#include "pxr/imaging/hd/enums.h"

Expand All @@ -46,9 +47,11 @@ class HdxDrawTargetAttachmentDesc final
{
public:
/// default constructor - only for use by containers.
HDX_API
HdxDrawTargetAttachmentDesc();

/// Construct a draw target attachment description
HDX_API
HdxDrawTargetAttachmentDesc(const std::string &name,
HdFormat format,
const VtValue &clearColor,
Expand All @@ -59,7 +62,9 @@ class HdxDrawTargetAttachmentDesc final
~HdxDrawTargetAttachmentDesc() = default;

// Copy for container support.
HDX_API
HdxDrawTargetAttachmentDesc(const HdxDrawTargetAttachmentDesc &copy);
HDX_API
HdxDrawTargetAttachmentDesc &operator =(const HdxDrawTargetAttachmentDesc &copy);

const std::string &GetName() const { return _name; }
Expand All @@ -71,9 +76,13 @@ class HdxDrawTargetAttachmentDesc final
HdMagFilter GetMagFilter() const { return _magFilter; }

// VtValue requirements
HDX_API
size_t GetHash() const;
HDX_API
void Dump(std::ostream &out) const;
HDX_API
bool operator==(const HdxDrawTargetAttachmentDesc &other) const;
HDX_API
bool operator!=(const HdxDrawTargetAttachmentDesc &other) const;

private:
Expand All @@ -86,7 +95,9 @@ class HdxDrawTargetAttachmentDesc final
HdMagFilter _magFilter;
};

HDX_API
size_t hash_value(HdxDrawTargetAttachmentDesc const &attachment);
HDX_API
std::ostream &operator <<(std::ostream &out, const HdxDrawTargetAttachmentDesc &pv);


Expand Down
15 changes: 15 additions & 0 deletions pxr/imaging/lib/hdx/drawTargetAttachmentDescArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define HDX_DRAW_TARGET_ATTACHMENT_DESC_ARRAY_H

#include "pxr/pxr.h"
#include "pxr/imaging/hdx/api.h"
#include "pxr/imaging/hdx/drawTargetAttachmentDesc.h"

#include <vector>
Expand All @@ -47,15 +48,20 @@ class HdxDrawTargetAttachmentDescArray
{
public:
/// Default constructor for container purposes.
HDX_API
HdxDrawTargetAttachmentDescArray();

HDX_API
HdxDrawTargetAttachmentDescArray(size_t attachmentCount);
virtual ~HdxDrawTargetAttachmentDescArray() = default;

HDX_API
HdxDrawTargetAttachmentDescArray(const HdxDrawTargetAttachmentDescArray &copy);
HDX_API
HdxDrawTargetAttachmentDescArray &operator =(const HdxDrawTargetAttachmentDescArray &copy);

/// Pushes a new attachment onto the end of the list of attachments.
HDX_API
void AddAttachment(const std::string &name,
HdFormat format,
const VtValue &clearColor,
Expand All @@ -65,10 +71,13 @@ class HdxDrawTargetAttachmentDescArray
HdMagFilter magFilter);


HDX_API
size_t GetNumAttachments() const;
HDX_API
const HdxDrawTargetAttachmentDesc &GetAttachment(size_t idx) const;

/// Sampler State for Depth attachment
HDX_API
void SetDepthSampler(HdWrap depthWrapS,
HdWrap depthWrapT,
HdMinFilter depthMinFilter,
Expand All @@ -82,9 +91,13 @@ class HdxDrawTargetAttachmentDescArray


// VtValue requirements
HDX_API
size_t GetHash() const;
HDX_API
void Dump(std::ostream &out) const;
HDX_API
bool operator==(const HdxDrawTargetAttachmentDescArray &other) const;
HDX_API
bool operator!=(const HdxDrawTargetAttachmentDescArray &other) const;

private:
Expand All @@ -99,7 +112,9 @@ class HdxDrawTargetAttachmentDescArray
HdMagFilter _depthMagFilter;
};

HDX_API
size_t hash_value(const HdxDrawTargetAttachmentDescArray &attachments);
HDX_API
std::ostream &operator <<(std::ostream &out, const HdxDrawTargetAttachmentDescArray &pv);


Expand Down
9 changes: 9 additions & 0 deletions pxr/imaging/lib/hdx/drawTargetRenderPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define HDX_DRAW_TARGET_RENDER_PASS_H

#include "pxr/pxr.h"
#include "pxr/imaging/hdx/api.h"
#include "pxr/imaging/hd/renderPass.h"
#include "pxr/imaging/hd/rprimCollection.h"

Expand All @@ -49,27 +50,35 @@ class HdxDrawTargetRenderPassState;
///
class HdxDrawTargetRenderPass : boost::noncopyable {
public:
HDX_API
HdxDrawTargetRenderPass(HdRenderIndex *index);
HDX_API
virtual ~HdxDrawTargetRenderPass();

/// Sets the target draw object of this render pass containing
/// the color buffers and depth buffer to use.
HDX_API
void SetDrawTarget(const GlfDrawTargetRefPtr &drawTarget);

/// Returns the draw target associated to this render pass.
HDX_API
GlfDrawTargetRefPtr GetDrawTarget();

/// Sets the non-context dependent state. The object is expected to
/// live longer than this class.
HDX_API
void SetRenderPassState(const HdxDrawTargetRenderPassState *renderPassState);

/// Sets the collection of rprims associated to this render pass.
HDX_API
void SetRprimCollection(HdRprimCollection const& col);

/// Execute render pass task
HDX_API
void Sync();

/// Sync the render pass resources
HDX_API
void Execute(HdRenderPassStateSharedPtr const &renderPassState);

private:
Expand Down
Loading

0 comments on commit de35592

Please sign in to comment.