add usd-21-11-win64_py39

This commit is contained in:
Sébastien Albert committed 2021-12-07 17:43:55 +01:00
1 parent 41d23e71ba
commit ba5e1f7e67
15684 files changed
+3069957

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
//
// 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_HGI_GL_API_H
#define PXR_IMAGING_HGI_GL_API_H
#include "pxr/base/arch/export.h"
#if defined(PXR_STATIC)
# define HGIGL_API
# define HGIGL_API_TEMPLATE_CLASS(...)
# define HGIGL_API_TEMPLATE_STRUCT(...)
# define HGIGL_LOCAL
#else
# if defined(HGIGL_EXPORTS)
# define HGIGL_API ARCH_EXPORT
# define HGIGL_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
# define HGIGL_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
# else
# define HGIGL_API ARCH_IMPORT
# define HGIGL_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
# define HGIGL_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
# endif
# define HGIGL_LOCAL ARCH_HIDDEN
#endif
#endif
+100
View File
@@ -0,0 +1,100 @@
//
// 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_HGI_GL_BLIT_CMDS_H
#define PXR_IMAGING_HGI_GL_BLIT_CMDS_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/blitCmds.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/hgi.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLBlitCmds
///
/// OpenGL implementation of HgiBlitCmds.
///
class HgiGLBlitCmds final : public HgiBlitCmds
{
public:
HGIGL_API
~HgiGLBlitCmds() override;
HGIGL_API
void PushDebugGroup(const char* label) override;
HGIGL_API
void PopDebugGroup() override;
HGIGL_API
void CopyTextureGpuToCpu(HgiTextureGpuToCpuOp const& copyOp) override;
HGIGL_API
void CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const& copyOp) override;
HGIGL_API
void CopyBufferGpuToGpu(HgiBufferGpuToGpuOp const& copyOp) override;
HGIGL_API
void CopyBufferCpuToGpu(HgiBufferCpuToGpuOp const& copyOp) override;
HGIGL_API
void CopyBufferGpuToCpu(HgiBufferGpuToCpuOp const& copyOp) override;
HGIGL_API
void CopyTextureToBuffer(HgiTextureToBufferOp const& copyOp) override;
HGIGL_API
void CopyBufferToTexture(HgiBufferToTextureOp const& copyOp) override;
HGIGL_API
void GenerateMipMaps(HgiTextureHandle const& texture) override;
HGIGL_API
void MemoryBarrier(HgiMemoryBarrier barrier) override;
protected:
friend class HgiGL;
HGIGL_API
HgiGLBlitCmds();
HGIGL_API
bool _Submit(Hgi* hgi, HgiSubmitWaitType wait) override;
private:
HgiGLBlitCmds & operator=(const HgiGLBlitCmds&) = delete;
HgiGLBlitCmds(const HgiGLBlitCmds&) = delete;
HgiGLOpsVector _ops;
int _pushStack;
// BlitCmds is used only one frame so storing multi-frame state here will
// not survive.
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+79
View File
@@ -0,0 +1,79 @@
//
// 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_HGI_GL_BUFFER_H
#define PXR_IMAGING_HGI_GL_BUFFER_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgi/buffer.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLBuffer
///
/// Represents an OpenGL GPU buffer resource.
///
class HgiGLBuffer final : public HgiBuffer
{
public:
HGIGL_API
~HgiGLBuffer() override;
HGIGL_API
size_t GetByteSizeOfResource() const override;
HGIGL_API
uint64_t GetRawResource() const override;
HGIGL_API
void* GetCPUStagingAddress() override;
uint32_t GetBufferId() const {return _bufferId;}
/// Returns the bindless gpu address (caller must verify extension support)
HGIGL_API
uint64_t GetBindlessGPUAddress();
protected:
friend class HgiGL;
HGIGL_API
HgiGLBuffer(HgiBufferDesc const & desc);
private:
HgiGLBuffer() = delete;
HgiGLBuffer & operator=(const HgiGLBuffer&) = delete;
HgiGLBuffer(const HgiGLBuffer&) = delete;
uint32_t _bufferId;
void* _mapped;
void* _cpuStaging;
uint64_t _bindlessGPUAddress;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+52
View File
@@ -0,0 +1,52 @@
//
// 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_HGI_GL_CAPABILITIES_H
#define PXR_IMAGING_HGI_GL_CAPABILITIES_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgi/capabilities.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLCapabilities
///
/// Reports the capabilities of the HgiGL device.
///
class HgiGLCapabilities final : public HgiCapabilities
{
public:
HGIGL_API
~HgiGLCapabilities() override;
public:
friend class HgiGL;
HGIGL_API
HgiGLCapabilities();
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+94
View File
@@ -0,0 +1,94 @@
//
// 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_HGI_GL_COMPUTE_CMDS_H
#define PXR_IMAGING_HGI_GL_COMPUTE_CMDS_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/computeCmds.h"
#include "pxr/imaging/hgi/computePipeline.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/hgi.h"
#include <cstdint>
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLComputeCmds
///
/// OpenGL implementation of HgiComputeCmds.
///
class HgiGLComputeCmds final : public HgiComputeCmds
{
public:
HGIGL_API
~HgiGLComputeCmds() override;
HGIGL_API
void PushDebugGroup(const char* label) override;
HGIGL_API
void PopDebugGroup() override;
HGIGL_API
void BindPipeline(HgiComputePipelineHandle pipeline) override;
HGIGL_API
void BindResources(HgiResourceBindingsHandle resources) override;
HGIGL_API
void SetConstantValues(
HgiComputePipelineHandle pipeline,
uint32_t bindIndex,
uint32_t byteSize,
const void* data) override;
HGIGL_API
void Dispatch(int dimX, int dimY) override;
HGIGL_API
void MemoryBarrier(HgiMemoryBarrier barrier) override;
protected:
friend class HgiGL;
HGIGL_API
HgiGLComputeCmds(HgiGLDevice* device);
HGIGL_API
bool _Submit(Hgi* hgi, HgiSubmitWaitType wait) override;
private:
HgiGLComputeCmds() = delete;
HgiGLComputeCmds & operator=(const HgiGLComputeCmds&) = delete;
HgiGLComputeCmds(const HgiGLComputeCmds&) = delete;
HgiGLOpsVector _ops;
int _pushStack;
// Cmds is used only one frame so storing multi-frame state on will not
// survive.
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,64 @@
//
// 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_HGIGL_COMPUTE_PIPELINE_H
#define PXR_IMAGING_HGIGL_COMPUTE_PIPELINE_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/computePipeline.h"
#include "pxr/imaging/hgiGL/api.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLComputePipeline
///
/// OpenGL implementation of HgiComputePipeline.
///
class HgiGLComputePipeline final : public HgiComputePipeline
{
public:
HGIGL_API
~HgiGLComputePipeline() override;
/// Apply pipeline state
HGIGL_API
void BindPipeline();
protected:
friend class HgiGL;
HGIGL_API
HgiGLComputePipeline(HgiComputePipelineDesc const& desc);
private:
HgiGLComputePipeline() = delete;
HgiGLComputePipeline & operator=(const HgiGLComputePipeline&) = delete;
HgiGLComputePipeline(const HgiGLComputePipeline&) = delete;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+82
View File
@@ -0,0 +1,82 @@
//
// 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_HGIGL_DEVICE_H
#define PXR_IMAGING_HGIGL_DEVICE_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/graphicsCmdsDesc.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/framebufferCache.h"
#include "pxr/imaging/hgiGL/hgi.h"
#include <fstream>
#include <ostream>
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGlDevice
///
/// OpenGL implementation of GPU device.
/// Note that there is only one global opengl context / device.
///
class HgiGLDevice final {
public:
HGIGL_API
HgiGLDevice();
HGIGL_API
~HgiGLDevice();
/// Get a framebuffer that matches the descriptor.
/// Do not hold onto the framebuffer Id. Instead re-acquire it every frame.
/// Framebuffer are internally managed in a framebuffer cache.
///
/// When the cmds descriptor has resolved textures, two framebuffers are
/// created for the MSAA and for the resolved textures. The bool flag can
/// be used to access the respective ones.
HGIGL_API
uint32_t AcquireFramebuffer(
HgiGraphicsCmdsDesc const& desc,
bool resolved = false);
/// Execute the provided functions / ops. This will emit the GL calls.
HGIGL_API
void SubmitOps(HgiGLOpsVector const& ops);
private:
HgiGLDevice & operator=(const HgiGLDevice&) = delete;
HgiGLDevice(const HgiGLDevice&) = delete;
friend std::ofstream& operator<<(
std::ofstream& out,
const HgiGLDevice& dev);
HgiGLFramebufferCache _framebufferCache;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,81 @@
//
// 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_HGI_GL_FRAMEBUFFER_CACHE_H
#define PXR_IMAGING_HGI_GL_FRAMEBUFFER_CACHE_H
#include <ostream>
#include <fstream>
#include <vector>
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/graphicsCmdsDesc.h"
#include "pxr/imaging/hgiGL/api.h"
PXR_NAMESPACE_OPEN_SCOPE
using HgiGLDescriptorCacheVec = std::vector<struct HgiGLDescriptorCacheItem*>;
/// \class HgiGLFramebufferCache
///
/// Manages a cache of framebuffers based on graphics cmds descriptors.
///
class HgiGLFramebufferCache final
{
public:
HGIGL_API
HgiGLFramebufferCache();
HGIGL_API
~HgiGLFramebufferCache();
/// Get a framebuffer that matches the descriptor.
/// If the framebuffer exists in the cache, it will be returned.
/// If none exist that match the descriptor, it will be created.
/// Do not hold onto the returned id. Re-acquire it every frame.
///
/// When the cmds descriptor has resolved textures, two framebuffers are
/// created for the MSAA and for the resolved textures. The bool flag can
/// be used to access the respective ones.
HGIGL_API
uint32_t AcquireFramebuffer(HgiGraphicsCmdsDesc const& desc,
bool resolved = false);
/// Clears all framebuffersfrom cache.
/// This should generally only be called when the device is being destroyed.
HGIGL_API
void Clear();
private:
friend std::ostream& operator<<(
std::ostream& out,
const HgiGLFramebufferCache& fbc);
HgiGLDescriptorCacheVec _descriptorCache;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,105 @@
//
// 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_HGI_GL_GARBAGE_COLLECTOR_H
#define PXR_IMAGING_HGI_GL_GARBAGE_COLLECTOR_H
#include "pxr/pxr.h"
#include "pxr/base/tf/diagnostic.h"
#include "pxr/imaging/hgi/hgi.h"
#include "pxr/imaging/hgiGL/api.h"
#include <mutex>
#include <vector>
PXR_NAMESPACE_OPEN_SCOPE
class HgiGL;
/// \class HgiGLGarbageCollector
///
/// Handles garbage collection of opengl objects by delaying their destruction
/// until those objects are no longer used.
///
class HgiGLGarbageCollector final
{
public:
HGIGL_API
HgiGLGarbageCollector(HgiGL* hgi);
HGIGL_API
~HgiGLGarbageCollector();
/// Destroys the objects inside the garbage collector.
/// Thread safety: This call is not thread safe and must be called from
/// the thread that has the opengl context bound while no other threads are
/// destroying objects (e.g. during EndFrame).
HGIGL_API
void PerformGarbageCollection();
/// Returns a garbage collection vector for a type of handle.
/// Thread safety: The returned vector is a thread_local vector so this call
/// is thread safe as long as the vector is only used by the calling thread.
HgiBufferHandleVector* GetBufferList();
HgiTextureHandleVector* GetTextureList();
HgiSamplerHandleVector* GetSamplerList();
HgiShaderFunctionHandleVector* GetShaderFunctionList();
HgiShaderProgramHandleVector* GetShaderProgramList();
HgiResourceBindingsHandleVector* GetResourceBindingsList();
HgiGraphicsPipelineHandleVector* GetGraphicsPipelineList();
HgiComputePipelineHandleVector* GetComputePipelineList();
private:
HgiGLGarbageCollector & operator =
(const HgiGLGarbageCollector&) = delete;
HgiGLGarbageCollector(const HgiGLGarbageCollector&) = delete;
/// Returns a thread_local vector in which to store a object handle.
/// Thread safety: The returned vector is a thread_local vector so this call
/// is thread safe as long as the vector is only used by the calling thread.
template<class T>
T* _GetThreadLocalStorageList(std::vector<T*>* collector);
HgiGL* _hgi;
// List of all the per-thread-vectors of objects that need to be destroyed.
// The vectors are static (shared across HGIs), because we use thread_local
// in _GetThreadLocalStorageList which makes us share the garbage collector
// vectors across Hgi instances.
static std::vector<HgiBufferHandleVector*> _bufferList;
static std::vector<HgiTextureHandleVector*> _textureList;
static std::vector<HgiSamplerHandleVector*> _samplerList;
static std::vector<HgiShaderFunctionHandleVector*> _shaderFunctionList;
static std::vector<HgiShaderProgramHandleVector*> _shaderProgramList;
static std::vector<HgiResourceBindingsHandleVector*> _resourceBindingsList;
static std::vector<HgiGraphicsPipelineHandleVector*> _graphicsPipelineList;
static std::vector<HgiComputePipelineHandleVector*> _computePipelineList;
bool _isDestroying;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+152
View File
@@ -0,0 +1,152 @@
//
// 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_HGI_GL_GRAPHICS_CMDS_H
#define PXR_IMAGING_HGI_GL_GRAPHICS_CMDS_H
#include "pxr/pxr.h"
#include "pxr/base/gf/vec4i.h"
#include "pxr/imaging/hgi/graphicsCmds.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/hgi.h"
#include <cstdint>
PXR_NAMESPACE_OPEN_SCOPE
struct HgiGraphicsCmdsDesc;
class HgiGLDevice;
/// \class HgiGLGraphicsCmds
///
/// OpenGL implementation of HgiGraphicsCmds.
///
class HgiGLGraphicsCmds final : public HgiGraphicsCmds
{
public:
HGIGL_API
~HgiGLGraphicsCmds() override;
/// XXX This function is exposed temporarily for Hgi transition.
/// It allows code that is not yet converted to Hgi (e.g. HdSt) to insert
/// its opengl calls into the ops-stack of HgiGL to ensure that all commands
/// execute in the correct order. Once HdSt has transition fully to Hgi we
/// should remove this function.
HGIGL_API
void InsertFunctionOp(std::function<void(void)> const& fn);
HGIGL_API
void PushDebugGroup(const char* label) override;
HGIGL_API
void PopDebugGroup() override;
HGIGL_API
void SetViewport(GfVec4i const& vp) override;
HGIGL_API
void SetScissor(GfVec4i const& sc) override;
HGIGL_API
void BindPipeline(HgiGraphicsPipelineHandle pipeline) override;
HGIGL_API
void BindResources(HgiResourceBindingsHandle resources) override;
HGIGL_API
void SetConstantValues(
HgiGraphicsPipelineHandle pipeline,
HgiShaderStage stages,
uint32_t bindIndex,
uint32_t byteSize,
const void* data) override;
HGIGL_API
void BindVertexBuffers(
uint32_t firstBinding,
HgiBufferHandleVector const& buffers,
std::vector<uint32_t> const& byteOffsets) override;
HGIGL_API
void Draw(
uint32_t vertexCount,
uint32_t firstVertex,
uint32_t instanceCount) override;
HGIGL_API
void DrawIndirect(
HgiBufferHandle const& drawParameterBuffer,
uint32_t drawBufferOffset,
uint32_t drawCount,
uint32_t stride) override;
HGIGL_API
void DrawIndexed(
HgiBufferHandle const& indexBuffer,
uint32_t indexCount,
uint32_t indexBufferByteOffset,
uint32_t vertexOffset,
uint32_t instanceCount) override;
HGIGL_API
void DrawIndexedIndirect(
HgiBufferHandle const& indexBuffer,
HgiBufferHandle const& drawParameterBuffer,
uint32_t drawBufferOffset,
uint32_t drawCount,
uint32_t stride) override;
HGIGL_API
void MemoryBarrier(HgiMemoryBarrier barrier) override;
protected:
friend class HgiGL;
HGIGL_API
HgiGLGraphicsCmds(
HgiGLDevice* device,
HgiGraphicsCmdsDesc const& desc);
HGIGL_API
bool _Submit(Hgi* hgi, HgiSubmitWaitType wait) override;
private:
HgiGLGraphicsCmds() = delete;
HgiGLGraphicsCmds & operator=(const HgiGLGraphicsCmds&) = delete;
HgiGLGraphicsCmds(const HgiGLGraphicsCmds&) = delete;
/// This performs multisample resolve when needed at the end of recording.
void _AddResolveToOps(HgiGLDevice* device);
bool _recording;
HgiGraphicsCmdsDesc _descriptor;
HgiPrimitiveType _primitiveType;
HgiGLOpsVector _ops;
int _pushStack;
// Cmds is used only one frame so storing multi-frame state on will not
// survive.
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,66 @@
//
// 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_HGIGL_PIPELINE_H
#define PXR_IMAGING_HGIGL_PIPELINE_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/graphicsPipeline.h"
#include "pxr/imaging/hgiGL/api.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLPipeline
///
/// OpenGL implementation of HgiGraphicsPipeline.
///
class HgiGLGraphicsPipeline final : public HgiGraphicsPipeline
{
public:
HGIGL_API
~HgiGLGraphicsPipeline() override;
/// Apply pipeline state
HGIGL_API
void BindPipeline();
protected:
friend class HgiGL;
HGIGL_API
HgiGLGraphicsPipeline(HgiGraphicsPipelineDesc const& desc);
private:
HgiGLGraphicsPipeline() = delete;
HgiGLGraphicsPipeline & operator=(const HgiGLGraphicsPipeline&) = delete;
HgiGLGraphicsPipeline(const HgiGLGraphicsPipeline&) = delete;
uint32_t _vao;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+183
View File
@@ -0,0 +1,183 @@
//
// 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_HGI_GL_HGI_H
#define PXR_IMAGING_HGI_GL_HGI_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/capabilities.h"
#include "pxr/imaging/hgiGL/garbageCollector.h"
#include "pxr/imaging/hgi/hgi.h"
#include "pxr/imaging/hgi/tokens.h"
#include <functional>
#include <memory>
#include <vector>
PXR_NAMESPACE_OPEN_SCOPE
class HgiGLDevice;
using HgiGLOpsFn = std::function<void(void)>;
using HgiGLOpsVector = std::vector<HgiGLOpsFn>;
/// \class HgiGL
///
/// OpenGL implementation of the Hydra Graphics Interface.
///
/// HgiGL expects the GL context to be externally managed.
/// When HgiGL is constructed and during any of its resource create / destroy
/// calls and during command recording operations it expects that the OpenGL
/// context is valid and current.
///
class HgiGL final : public Hgi
{
public:
HGIGL_API
HgiGL();
HGIGL_API
~HgiGL() override;
HGIGL_API
HgiGraphicsCmdsUniquePtr CreateGraphicsCmds(
HgiGraphicsCmdsDesc const& desc) override;
HGIGL_API
HgiBlitCmdsUniquePtr CreateBlitCmds() override;
HGIGL_API
HgiComputeCmdsUniquePtr CreateComputeCmds() override;
HGIGL_API
HgiTextureHandle CreateTexture(HgiTextureDesc const & desc) override;
HGIGL_API
void DestroyTexture(HgiTextureHandle* texHandle) override;
HGIGL_API
HgiTextureViewHandle CreateTextureView(
HgiTextureViewDesc const& desc) override;
HGIGL_API
void DestroyTextureView(HgiTextureViewHandle* viewHandle) override;
HGIGL_API
HgiSamplerHandle CreateSampler(HgiSamplerDesc const & desc) override;
HGIGL_API
void DestroySampler(HgiSamplerHandle* smpHandle) override;
HGIGL_API
HgiBufferHandle CreateBuffer(HgiBufferDesc const & desc) override;
HGIGL_API
void DestroyBuffer(HgiBufferHandle* bufHandle) override;
HGIGL_API
HgiShaderFunctionHandle CreateShaderFunction(
HgiShaderFunctionDesc const& desc) override;
HGIGL_API
void DestroyShaderFunction(
HgiShaderFunctionHandle* shaderFunctionHandle) override;
HGIGL_API
HgiShaderProgramHandle CreateShaderProgram(
HgiShaderProgramDesc const& desc) override;
HGIGL_API
void DestroyShaderProgram(
HgiShaderProgramHandle* shaderProgramHandle) override;
HGIGL_API
HgiResourceBindingsHandle CreateResourceBindings(
HgiResourceBindingsDesc const& desc) override;
HGIGL_API
void DestroyResourceBindings(HgiResourceBindingsHandle* resHandle) override;
HGIGL_API
HgiGraphicsPipelineHandle CreateGraphicsPipeline(
HgiGraphicsPipelineDesc const& pipeDesc) override;
HGIGL_API
void DestroyGraphicsPipeline(
HgiGraphicsPipelineHandle* pipeHandle) override;
HGIGL_API
HgiComputePipelineHandle CreateComputePipeline(
HgiComputePipelineDesc const& pipeDesc) override;
HGIGL_API
void DestroyComputePipeline(HgiComputePipelineHandle* pipeHandle) override;
HGIGL_API
TfToken const& GetAPIName() const override;
HGIGL_API
HgiGLCapabilities const* GetCapabilities() const override;
HGIGL_API
void StartFrame() override;
HGIGL_API
void EndFrame() override;
//
// HgiGL specific
//
/// Returns the opengl device.
HGIGL_API
HgiGLDevice* GetPrimaryDevice() const;
protected:
HGIGL_API
bool _SubmitCmds(HgiCmds* cmds, HgiSubmitWaitType wait) override;
private:
HgiGL & operator=(const HgiGL&) = delete;
HgiGL(const HgiGL&) = delete;
// Invalidates the resource handle and places the object in the garbage
// collector vector for future destruction.
// This is helpful to avoid destroying GPU resources still in-flight.
template<class T>
void _TrashObject(
HgiHandle<T>* handle, std::vector<HgiHandle<T>>* collector) {
collector->push_back(HgiHandle<T>(handle->Get(), /*id*/0));
*handle = HgiHandle<T>();
}
HgiGLDevice* _device;
std::unique_ptr<HgiGLCapabilities> _capabilities;
HgiGLGarbageCollector _garbageCollector;
int _frameDepth;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+192
View File
@@ -0,0 +1,192 @@
//
// 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_HGIGL_OPS_H
#define PXR_IMAGING_HGIGL_OPS_H
#include "pxr/pxr.h"
#include "pxr/base/gf/vec4i.h"
#include "pxr/imaging/hgi/buffer.h"
#include "pxr/imaging/hgi/blitCmdsOps.h"
#include "pxr/imaging/hgi/graphicsCmdsDesc.h"
#include "pxr/imaging/hgi/graphicsPipeline.h"
#include "pxr/imaging/hgi/resourceBindings.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/device.h"
#include <cstdint>
#include <functional>
#include <vector>
PXR_NAMESPACE_OPEN_SCOPE
using HgiGLOpsFn = std::function<void(void)>;
/// \class HgiGLOps
///
/// A collection of functions used by cmds objects to do deferred cmd recording.
/// Modern API's support command buffer recording of gfx commands ('deferred').
/// Meaning: No commands are executed on the GPU until we Submit the cmd buffer.
///
/// OpenGL uses 'immediate' mode instead where gfx commands are immediately
/// processed and given to the GPU at a time of the drivers choosing.
/// We use 'Ops' functions to record our OpenGL function in a list and only
/// execute them in OpenGL during the SubmitCmds phase.
///
/// This has two benefits:
///
/// 1. OpenGL behaves more like Metal and Vulkan. So when clients write Hgi code
/// they get similar behavior in gpu command execution across all backends.
/// For example, if you are running with HgiGL and recording commands into a
/// Hgi***Cmds object and forget to call 'SubmitCmds' you will notice that
/// your commands are not executed on the GPU, just like what would happen if
/// you were running with HgiMetal.
///
/// 2. It lets us satisfy the Hgi requirement that Hgi***Cmds objects must be
/// able to do their recording on secondary threads.
///
class HgiGLOps
{
public:
HGIGL_API
static HgiGLOpsFn PushDebugGroup(const char* label);
HGIGL_API
static HgiGLOpsFn PopDebugGroup();
HGIGL_API
static HgiGLOpsFn CopyTextureGpuToCpu(HgiTextureGpuToCpuOp const& copyOp);
HGIGL_API
static HgiGLOpsFn CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const& copyOp);
HGIGL_API
static HgiGLOpsFn CopyBufferGpuToGpu(HgiBufferGpuToGpuOp const& copyOp);
HGIGL_API
static HgiGLOpsFn CopyBufferCpuToGpu(HgiBufferCpuToGpuOp const& copyOp);
HGIGL_API
static HgiGLOpsFn CopyBufferGpuToCpu(HgiBufferGpuToCpuOp const& copyOp);
HGIGL_API
static HgiGLOpsFn CopyTextureToBuffer(HgiTextureToBufferOp const& copyOp);
HGIGL_API
static HgiGLOpsFn CopyBufferToTexture(HgiBufferToTextureOp const& copyOp);
HGIGL_API
static HgiGLOpsFn ResolveFramebuffer(
HgiGLDevice* device,
HgiGraphicsCmdsDesc const &graphicsCmds);
HGIGL_API
static HgiGLOpsFn SetViewport(GfVec4i const& vp);
HGIGL_API
static HgiGLOpsFn SetScissor(GfVec4i const& sc);
HGIGL_API
static HgiGLOpsFn BindPipeline(HgiGraphicsPipelineHandle pipeline);
HGIGL_API
static HgiGLOpsFn BindPipeline(HgiComputePipelineHandle pipeline);
HGIGL_API
static HgiGLOpsFn BindResources(HgiResourceBindingsHandle resources);
HGIGL_API
static HgiGLOpsFn SetConstantValues(
HgiGraphicsPipelineHandle pipeline,
HgiShaderStage stages,
uint32_t bindIndex,
uint32_t byteSize,
const void* data);
HGIGL_API
static HgiGLOpsFn SetConstantValues(
HgiComputePipelineHandle pipeline,
uint32_t bindIndex,
uint32_t byteSize,
const void* data);
HGIGL_API
static HgiGLOpsFn BindVertexBuffers(
uint32_t firstBinding,
HgiBufferHandleVector const& buffers,
std::vector<uint32_t> const& byteOffsets);
HGIGL_API
static HgiGLOpsFn Draw(
HgiPrimitiveType primitiveType,
uint32_t vertexCount,
uint32_t firstVertex,
uint32_t instanceCount);
HGIGL_API
static HgiGLOpsFn DrawIndirect(
HgiPrimitiveType primitiveType,
HgiBufferHandle const& drawParameterBuffer,
uint32_t drawBufferOffset,
uint32_t drawCount,
uint32_t stride);
HGIGL_API
static HgiGLOpsFn DrawIndexed(
HgiPrimitiveType primitiveType,
HgiBufferHandle const& indexBuffer,
uint32_t indexCount,
uint32_t indexBufferByteOffset,
uint32_t vertexOffset,
uint32_t instanceCount);
HGIGL_API
static HgiGLOpsFn DrawIndexedIndirect(
HgiPrimitiveType primitiveType,
HgiBufferHandle const& indexBuffer,
HgiBufferHandle const& drawParameterBuffer,
uint32_t drawBufferOffset,
uint32_t drawCount,
uint32_t stride);
HGIGL_API
static HgiGLOpsFn BindFramebufferOp(
HgiGLDevice* device,
HgiGraphicsCmdsDesc const& desc);
HGIGL_API
static HgiGLOpsFn Dispatch(int dimX, int dimY);
HGIGL_API
static HgiGLOpsFn GenerateMipMaps(HgiTextureHandle const& texture);
HGIGL_API
static HgiGLOpsFn MemoryBarrier(HgiMemoryBarrier barrier);
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,67 @@
//
// 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_HGIGL_RESOURCEBINDINGS_H
#define PXR_IMAGING_HGIGL_RESOURCEBINDINGS_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgi/resourceBindings.h"
#include "pxr/imaging/hgiGL/api.h"
#include <vector>
PXR_NAMESPACE_OPEN_SCOPE
///
/// \class HgiGLResourceBindings
///
/// OpenGL implementation of HgiResourceBindings.
///
///
class HgiGLResourceBindings final : public HgiResourceBindings
{
public:
HGIGL_API
~HgiGLResourceBindings() override;
/// Binds the resources to GPU.
HGIGL_API
void BindResources();
protected:
friend class HgiGL;
HGIGL_API
HgiGLResourceBindings(HgiResourceBindingsDesc const& desc);
private:
HgiGLResourceBindings() = delete;
HgiGLResourceBindings & operator=(const HgiGLResourceBindings&) = delete;
HgiGLResourceBindings(const HgiGLResourceBindings&) = delete;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+79
View File
@@ -0,0 +1,79 @@
//
// 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_HGIGL_SAMPLER_H
#define PXR_IMAGING_HGIGL_SAMPLER_H
#include "pxr/imaging/hgi/sampler.h"
#include "pxr/imaging/hgiGL/api.h"
PXR_NAMESPACE_OPEN_SCOPE
using HgiTextureHandle = HgiHandle<class HgiTexture>;
///
/// \class HgiGLSampler
///
/// OpenGL implementation of HgiSampler
///
class HgiGLSampler final : public HgiSampler
{
public:
HGIGL_API
~HgiGLSampler() override;
HGIGL_API
uint64_t GetRawResource() const override;
/// Returns the gl resource id of the sampler.
HGIGL_API
uint32_t GetSamplerId() const;
/// Returns the bindless gpu handle (caller must verify extension support)
HGIGL_API
uint64_t GetBindlessHandle(HgiTextureHandle const &textureHandle);
protected:
friend class HgiGL;
HGIGL_API
HgiGLSampler(HgiSamplerDesc const& desc);
private:
HgiGLSampler() = delete;
HgiGLSampler & operator=(const HgiGLSampler&) = delete;
HgiGLSampler(const HgiGLSampler&) = delete;
private:
uint32_t _samplerId;
uint32_t _bindlessTextureId;
uint64_t _bindlessHandle;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
@@ -0,0 +1,79 @@
//
// 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_HGIGL_SHADERFUNCTION_H
#define PXR_IMAGING_HGIGL_SHADERFUNCTION_H
#include "pxr/imaging/hgi/shaderFunction.h"
#include "pxr/imaging/hgiGL/api.h"
PXR_NAMESPACE_OPEN_SCOPE
///
/// \class HgiGLShaderFunction
///
/// OpenGL implementation of HgiShaderFunction
///
class HgiGLShaderFunction final : public HgiShaderFunction
{
public:
HGIGL_API
~HgiGLShaderFunction() override;
HGIGL_API
bool IsValid() const override;
HGIGL_API
std::string const& GetCompileErrors() override;
HGIGL_API
size_t GetByteSizeOfResource() const override;
HGIGL_API
uint64_t GetRawResource() const override;
/// Returns the gl resource id of the shader.
HGIGL_API
uint32_t GetShaderId() const;
protected:
friend class HgiGL;
HGIGL_API
HgiGLShaderFunction(HgiShaderFunctionDesc const& desc);
private:
HgiGLShaderFunction() = delete;
HgiGLShaderFunction & operator=(const HgiGLShaderFunction&) = delete;
HgiGLShaderFunction(const HgiGLShaderFunction&) = delete;
private:
std::string _errors;
uint32_t _shaderId;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+98
View File
@@ -0,0 +1,98 @@
//
// 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_HGIGL_SHADERPROGRAM_H
#define PXR_IMAGING_HGIGL_SHADERPROGRAM_H
#include "pxr/imaging/hgi/shaderProgram.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgiGL/shaderFunction.h"
#include <vector>
PXR_NAMESPACE_OPEN_SCOPE
///
/// \class HgiGLShaderProgram
///
/// OpenGL implementation of HgiShaderProgram
///
class HgiGLShaderProgram final : public HgiShaderProgram
{
public:
HGIGL_API
~HgiGLShaderProgram() override;
HGIGL_API
bool IsValid() const override;
HGIGL_API
std::string const& GetCompileErrors() override;
HGIGL_API
HgiShaderFunctionHandleVector const& GetShaderFunctions() const override;
HGIGL_API
size_t GetByteSizeOfResource() const override;
HGIGL_API
uint64_t GetRawResource() const override;
/// Returns the gl resource id of the program.
HGIGL_API
uint32_t GetProgramId() const;
/// Returns the gl resource for the uniform block of this shader program.
/// This uniform block is used to store some per-shader values, such as
/// indices or offsets into other buffers.
/// See also Hgi::SetConstantValues.
/// 'sizeHint' is used to store the byte size of the uniform buffer, but
/// this fn does not actually allocate the data storage for the buffer.
HGIGL_API
uint32_t GetUniformBuffer(size_t sizeHint);
protected:
friend class HgiGL;
HGIGL_API
HgiGLShaderProgram(HgiShaderProgramDesc const& desc);
private:
HgiGLShaderProgram() = delete;
HgiGLShaderProgram & operator=(const HgiGLShaderProgram&) = delete;
HgiGLShaderProgram(const HgiGLShaderProgram&) = delete;
private:
std::string _errors;
uint32_t _programId;
size_t _programByteSize;
uint32_t _uniformBuffer;
size_t _uboByteSize;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif
+78
View File
@@ -0,0 +1,78 @@
//
// 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_HGI_GL_TEXTURE_H
#define PXR_IMAGING_HGI_GL_TEXTURE_H
#include "pxr/pxr.h"
#include "pxr/imaging/hgiGL/api.h"
#include "pxr/imaging/hgi/texture.h"
PXR_NAMESPACE_OPEN_SCOPE
/// \class HgiGLTexture
///
/// Represents a OpenGL GPU texture resource.
///
class HgiGLTexture final : public HgiTexture
{
public:
HGIGL_API
~HgiGLTexture() override;
HGIGL_API
size_t GetByteSizeOfResource() const override;
HGIGL_API
uint64_t GetRawResource() const override;
/// Returns the OpenGL id / name of the texture.
uint32_t GetTextureId() const {return _textureId;}
/// Returns the bindless gpu handle (caller must verify extension support)
HGIGL_API
uint64_t GetBindlessHandle();
protected:
friend class HgiGL;
HGIGL_API
HgiGLTexture(HgiTextureDesc const & desc);
HGIGL_API
HgiGLTexture(HgiTextureViewDesc const & desc);
private:
HgiGLTexture() = delete;
HgiGLTexture & operator=(const HgiGLTexture&) = delete;
HgiGLTexture(const HgiGLTexture&) = delete;
uint32_t _textureId;
uint64_t _bindlessHandle;
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif