2026-03-24 03:49:13 +08:00
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLResourceView.h"
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLTexture.h"
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLBuffer.h"
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLFramebuffer.h"
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLTextureUnitAllocator.h"
|
|
|
|
|
#include "XCEngine/RHI/OpenGL/OpenGLUniformBufferManager.h"
|
|
|
|
|
|
|
|
|
|
#include <glad/glad.h>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace RHI {
|
|
|
|
|
|
2026-03-26 01:56:10 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
GLenum ResolveFramebufferTextureTarget(OpenGLTextureType textureType, const ResourceViewDesc& desc) {
|
|
|
|
|
switch (textureType) {
|
|
|
|
|
case OpenGLTextureType::Texture1D:
|
|
|
|
|
return GL_TEXTURE_1D;
|
|
|
|
|
case OpenGLTextureType::Texture2D:
|
|
|
|
|
return GL_TEXTURE_2D;
|
|
|
|
|
case OpenGLTextureType::TextureCube: {
|
|
|
|
|
const uint32_t face = desc.firstArraySlice < 6 ? desc.firstArraySlice : 0;
|
|
|
|
|
return GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
|
|
|
|
|
}
|
|
|
|
|
case OpenGLTextureType::Texture2DArray:
|
|
|
|
|
case OpenGLTextureType::Texture3D:
|
|
|
|
|
case OpenGLTextureType::TextureCubeArray:
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
return GL_TEXTURE_2D;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ResolveFramebufferAttachmentLayer(OpenGLTextureType textureType, const ResourceViewDesc& desc) {
|
|
|
|
|
switch (textureType) {
|
|
|
|
|
case OpenGLTextureType::Texture2DArray:
|
|
|
|
|
case OpenGLTextureType::Texture3D:
|
|
|
|
|
case OpenGLTextureType::TextureCubeArray:
|
|
|
|
|
return static_cast<int>(desc.firstArraySlice);
|
|
|
|
|
default:
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Format ResolveViewFormat(OpenGLTexture* texture, const ResourceViewDesc& desc) {
|
|
|
|
|
if (desc.format != 0) {
|
|
|
|
|
return static_cast<Format>(desc.format);
|
|
|
|
|
}
|
|
|
|
|
return texture ? texture->GetFormat() : Format::Unknown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FramebufferAttachmentType ResolveDepthAttachmentType(Format format) {
|
|
|
|
|
return format == Format::D24_UNorm_S8_UInt
|
|
|
|
|
? FramebufferAttachmentType::DepthStencil
|
|
|
|
|
: FramebufferAttachmentType::Depth;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 18:05:00 +08:00
|
|
|
uint32_t ResolveBufferElementStride(OpenGLBuffer* buffer, const ResourceViewDesc& desc) {
|
|
|
|
|
if (desc.dimension == ResourceViewDimension::RawBuffer) {
|
|
|
|
|
return 4u;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc.structureByteStride > 0) {
|
|
|
|
|
return desc.structureByteStride;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buffer != nullptr ? buffer->GetStride() : 0u;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t ResolveBufferByteOffset(OpenGLBuffer* buffer, const ResourceViewDesc& desc) {
|
|
|
|
|
const uint32_t elementStride = ResolveBufferElementStride(buffer, desc);
|
|
|
|
|
if (elementStride == 0) {
|
|
|
|
|
return desc.bufferLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return desc.bufferLocation + static_cast<uint64_t>(desc.firstElement) * elementStride;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t ResolveBufferElementCount(OpenGLBuffer* buffer, const ResourceViewDesc& desc) {
|
|
|
|
|
if (desc.elementCount > 0) {
|
|
|
|
|
return desc.elementCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buffer == nullptr) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t elementStride = ResolveBufferElementStride(buffer, desc);
|
|
|
|
|
if (elementStride == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint64_t byteOffset = ResolveBufferByteOffset(buffer, desc);
|
|
|
|
|
if (byteOffset >= buffer->GetSize()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return static_cast<uint32_t>((buffer->GetSize() - byteOffset) / elementStride);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 01:56:10 +08:00
|
|
|
} // namespace
|
|
|
|
|
|
2026-03-24 03:49:13 +08:00
|
|
|
OpenGLResourceView::OpenGLResourceView()
|
|
|
|
|
: m_viewType(ResourceViewType::RenderTarget)
|
2026-03-24 20:01:54 +08:00
|
|
|
, m_format(Format::Unknown)
|
|
|
|
|
, m_dimension(ResourceViewDimension::Unknown)
|
2026-03-24 03:49:13 +08:00
|
|
|
, m_framebufferID(0)
|
|
|
|
|
, m_textureUnit(-1)
|
|
|
|
|
, m_bindingPoint(-1)
|
|
|
|
|
, m_texture(nullptr)
|
|
|
|
|
, m_buffer(nullptr)
|
|
|
|
|
, m_framebuffer(nullptr)
|
|
|
|
|
, m_textureUnitAllocator(nullptr)
|
2026-03-25 23:07:22 +08:00
|
|
|
, m_uniformBufferManager(nullptr)
|
|
|
|
|
, m_bufferOffset(0)
|
|
|
|
|
, m_bufferSize(0)
|
|
|
|
|
, m_bufferStride(0) {
|
2026-03-24 03:49:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OpenGLResourceView::~OpenGLResourceView() {
|
|
|
|
|
Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OpenGLResourceView::Shutdown() {
|
|
|
|
|
if (m_textureUnit >= 0 && m_textureUnitAllocator) {
|
|
|
|
|
m_textureUnitAllocator->UnbindTexture(m_textureUnit);
|
|
|
|
|
m_textureUnitAllocator->Free(m_textureUnit);
|
|
|
|
|
m_textureUnit = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_bindingPoint >= 0 && m_uniformBufferManager) {
|
|
|
|
|
m_uniformBufferManager->UnbindBuffer(m_bindingPoint);
|
|
|
|
|
m_uniformBufferManager->Free(m_bindingPoint);
|
|
|
|
|
m_bindingPoint = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_framebuffer = nullptr;
|
|
|
|
|
m_textureUnitAllocator = nullptr;
|
|
|
|
|
m_uniformBufferManager = nullptr;
|
2026-03-26 01:56:10 +08:00
|
|
|
m_framebufferAttachment = {};
|
2026-03-24 03:49:13 +08:00
|
|
|
m_framebufferID = 0;
|
|
|
|
|
m_texture = nullptr;
|
|
|
|
|
m_buffer = nullptr;
|
2026-03-25 23:07:22 +08:00
|
|
|
m_bufferOffset = 0;
|
|
|
|
|
m_bufferSize = 0;
|
|
|
|
|
m_bufferStride = 0;
|
2026-03-24 03:49:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void* OpenGLResourceView::GetNativeHandle() {
|
|
|
|
|
switch (m_viewType) {
|
2026-03-25 23:07:22 +08:00
|
|
|
case ResourceViewType::VertexBuffer:
|
|
|
|
|
case ResourceViewType::IndexBuffer:
|
|
|
|
|
return reinterpret_cast<void*>(static_cast<uintptr_t>(m_buffer ? m_buffer->GetID() : 0));
|
2026-03-24 03:49:13 +08:00
|
|
|
case ResourceViewType::RenderTarget:
|
|
|
|
|
case ResourceViewType::DepthStencil:
|
|
|
|
|
return reinterpret_cast<void*>(static_cast<uintptr_t>(m_framebufferID));
|
|
|
|
|
case ResourceViewType::ShaderResource:
|
|
|
|
|
case ResourceViewType::UnorderedAccess:
|
2026-04-08 18:05:00 +08:00
|
|
|
return reinterpret_cast<void*>(static_cast<uintptr_t>(
|
|
|
|
|
m_texture != nullptr ? m_texture->GetID() : (m_buffer != nullptr ? m_buffer->GetID() : 0)));
|
2026-03-24 03:49:13 +08:00
|
|
|
case ResourceViewType::ConstantBuffer:
|
|
|
|
|
return reinterpret_cast<void*>(static_cast<uintptr_t>(m_buffer ? m_buffer->GetID() : 0));
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::IsValid() const {
|
|
|
|
|
switch (m_viewType) {
|
2026-03-25 23:07:22 +08:00
|
|
|
case ResourceViewType::VertexBuffer:
|
|
|
|
|
case ResourceViewType::IndexBuffer:
|
|
|
|
|
return m_buffer != nullptr && m_buffer->GetID() != 0;
|
2026-03-24 03:49:13 +08:00
|
|
|
case ResourceViewType::RenderTarget:
|
|
|
|
|
case ResourceViewType::DepthStencil:
|
|
|
|
|
return m_framebufferID != 0;
|
|
|
|
|
case ResourceViewType::ShaderResource:
|
2026-04-08 18:05:00 +08:00
|
|
|
return (m_texture != nullptr && m_texture->GetID() != 0) ||
|
|
|
|
|
(m_buffer != nullptr && m_buffer->GetID() != 0 && m_bufferSize > 0);
|
2026-03-24 03:49:13 +08:00
|
|
|
case ResourceViewType::UnorderedAccess:
|
2026-04-08 18:05:00 +08:00
|
|
|
return (m_texture != nullptr && m_textureUnit >= 0) ||
|
|
|
|
|
(m_buffer != nullptr && m_buffer->GetID() != 0 && m_bufferSize > 0);
|
2026-03-24 03:49:13 +08:00
|
|
|
case ResourceViewType::ConstantBuffer:
|
|
|
|
|
return m_buffer != nullptr && m_bindingPoint >= 0;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::InitializeAsRenderTarget(
|
|
|
|
|
OpenGLTexture* texture,
|
|
|
|
|
const ResourceViewDesc& desc,
|
|
|
|
|
OpenGLFramebuffer* framebuffer) {
|
|
|
|
|
if (!texture || !framebuffer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::RenderTarget;
|
2026-03-26 01:56:10 +08:00
|
|
|
m_format = ResolveViewFormat(texture, desc);
|
2026-03-24 20:01:54 +08:00
|
|
|
m_dimension = desc.dimension;
|
2026-03-24 03:49:13 +08:00
|
|
|
m_texture = texture;
|
|
|
|
|
m_framebuffer = framebuffer;
|
|
|
|
|
m_framebufferID = framebuffer->GetFramebuffer();
|
2026-03-26 01:56:10 +08:00
|
|
|
m_framebufferAttachment.texture = texture->GetID();
|
|
|
|
|
m_framebufferAttachment.target = ResolveFramebufferTextureTarget(texture->GetOpenGLType(), desc);
|
|
|
|
|
m_framebufferAttachment.mipLevel = static_cast<int>(desc.mipLevel);
|
|
|
|
|
m_framebufferAttachment.layer = ResolveFramebufferAttachmentLayer(texture->GetOpenGLType(), desc);
|
|
|
|
|
m_framebufferAttachment.type = FramebufferAttachmentType::Color;
|
|
|
|
|
m_framebufferAttachment.format = static_cast<uint32_t>(m_format);
|
2026-03-24 03:49:13 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::InitializeAsDepthStencil(
|
|
|
|
|
OpenGLTexture* texture,
|
|
|
|
|
const ResourceViewDesc& desc,
|
|
|
|
|
OpenGLFramebuffer* framebuffer) {
|
|
|
|
|
if (!texture || !framebuffer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::DepthStencil;
|
2026-03-26 01:56:10 +08:00
|
|
|
m_format = ResolveViewFormat(texture, desc);
|
2026-03-24 20:01:54 +08:00
|
|
|
m_dimension = desc.dimension;
|
2026-03-24 03:49:13 +08:00
|
|
|
m_texture = texture;
|
|
|
|
|
m_framebuffer = framebuffer;
|
|
|
|
|
m_framebufferID = framebuffer->GetFramebuffer();
|
2026-03-26 01:56:10 +08:00
|
|
|
m_framebufferAttachment.texture = texture->GetID();
|
|
|
|
|
m_framebufferAttachment.target = ResolveFramebufferTextureTarget(texture->GetOpenGLType(), desc);
|
|
|
|
|
m_framebufferAttachment.mipLevel = static_cast<int>(desc.mipLevel);
|
|
|
|
|
m_framebufferAttachment.layer = ResolveFramebufferAttachmentLayer(texture->GetOpenGLType(), desc);
|
|
|
|
|
m_framebufferAttachment.type = ResolveDepthAttachmentType(m_format);
|
|
|
|
|
m_framebufferAttachment.format = static_cast<uint32_t>(m_format);
|
2026-03-24 03:49:13 +08:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::InitializeAsShaderResource(
|
|
|
|
|
OpenGLTexture* texture,
|
|
|
|
|
const ResourceViewDesc& desc,
|
|
|
|
|
OpenGLTextureUnitAllocator* allocator) {
|
2026-03-26 00:04:51 +08:00
|
|
|
if (!texture) {
|
2026-03-24 03:49:13 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::ShaderResource;
|
2026-03-26 01:56:10 +08:00
|
|
|
m_format = ResolveViewFormat(texture, desc);
|
2026-03-24 20:01:54 +08:00
|
|
|
m_dimension = desc.dimension;
|
2026-03-24 03:49:13 +08:00
|
|
|
m_texture = texture;
|
2026-03-26 00:04:51 +08:00
|
|
|
m_textureUnit = -1;
|
2026-03-24 03:49:13 +08:00
|
|
|
m_textureUnitAllocator = allocator;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::InitializeAsUnorderedAccess(
|
|
|
|
|
OpenGLTexture* texture,
|
|
|
|
|
const ResourceViewDesc& desc,
|
|
|
|
|
OpenGLTextureUnitAllocator* allocator) {
|
|
|
|
|
if (!texture || !allocator) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t unit = allocator->Allocate();
|
|
|
|
|
if (unit < 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::UnorderedAccess;
|
2026-03-26 01:56:10 +08:00
|
|
|
m_format = ResolveViewFormat(texture, desc);
|
2026-03-24 20:01:54 +08:00
|
|
|
m_dimension = desc.dimension;
|
2026-03-24 03:49:13 +08:00
|
|
|
m_texture = texture;
|
|
|
|
|
m_textureUnit = unit;
|
|
|
|
|
m_textureUnitAllocator = allocator;
|
|
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0 + unit);
|
|
|
|
|
glBindTexture(static_cast<GLenum>(texture->GetOpenGLType()), texture->GetID());
|
|
|
|
|
glBindImageTexture(unit, texture->GetID(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 18:05:00 +08:00
|
|
|
bool OpenGLResourceView::InitializeAsShaderResource(
|
|
|
|
|
OpenGLBuffer* buffer,
|
|
|
|
|
const ResourceViewDesc& desc) {
|
|
|
|
|
if (!buffer || !IsBufferResourceViewDimension(desc.dimension)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t elementStride = ResolveBufferElementStride(buffer, desc);
|
|
|
|
|
if (elementStride == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t elementCount = ResolveBufferElementCount(buffer, desc);
|
|
|
|
|
if (elementCount == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::ShaderResource;
|
|
|
|
|
m_format = desc.format != 0 ? static_cast<Format>(desc.format) : Format::Unknown;
|
|
|
|
|
m_dimension =
|
|
|
|
|
desc.dimension != ResourceViewDimension::Unknown ? desc.dimension : ResourceViewDimension::Buffer;
|
|
|
|
|
m_buffer = buffer;
|
|
|
|
|
m_bufferOffset = ResolveBufferByteOffset(buffer, desc);
|
|
|
|
|
m_bufferStride = elementStride;
|
|
|
|
|
m_bufferSize = elementCount * elementStride;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::InitializeAsUnorderedAccess(
|
|
|
|
|
OpenGLBuffer* buffer,
|
|
|
|
|
const ResourceViewDesc& desc) {
|
|
|
|
|
if (!buffer || !IsBufferResourceViewDimension(desc.dimension)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t elementStride = ResolveBufferElementStride(buffer, desc);
|
|
|
|
|
if (elementStride == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t elementCount = ResolveBufferElementCount(buffer, desc);
|
|
|
|
|
if (elementCount == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::UnorderedAccess;
|
|
|
|
|
m_format = desc.format != 0 ? static_cast<Format>(desc.format) : Format::Unknown;
|
|
|
|
|
m_dimension =
|
|
|
|
|
desc.dimension != ResourceViewDimension::Unknown ? desc.dimension : ResourceViewDimension::Buffer;
|
|
|
|
|
m_buffer = buffer;
|
|
|
|
|
m_bufferOffset = ResolveBufferByteOffset(buffer, desc);
|
|
|
|
|
m_bufferStride = elementStride;
|
|
|
|
|
m_bufferSize = elementCount * elementStride;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-24 03:49:13 +08:00
|
|
|
bool OpenGLResourceView::InitializeAsConstantBuffer(
|
|
|
|
|
OpenGLBuffer* buffer,
|
|
|
|
|
const ResourceViewDesc& desc,
|
|
|
|
|
OpenGLUniformBufferManager* manager) {
|
|
|
|
|
if (!buffer || !manager) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t bindingPoint = manager->Allocate();
|
|
|
|
|
if (bindingPoint < 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::ConstantBuffer;
|
2026-03-24 20:01:54 +08:00
|
|
|
m_format = Format::Unknown;
|
|
|
|
|
m_dimension = ResourceViewDimension::Buffer;
|
2026-03-24 03:49:13 +08:00
|
|
|
m_buffer = buffer;
|
|
|
|
|
m_bindingPoint = bindingPoint;
|
|
|
|
|
m_uniformBufferManager = manager;
|
|
|
|
|
manager->BindBuffer(bindingPoint, buffer, 0, static_cast<uint32_t>(desc.bufferLocation));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 23:07:22 +08:00
|
|
|
bool OpenGLResourceView::InitializeAsVertexBuffer(
|
|
|
|
|
OpenGLBuffer* buffer,
|
|
|
|
|
const ResourceViewDesc& desc) {
|
|
|
|
|
if (!buffer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::VertexBuffer;
|
|
|
|
|
m_format = Format::Unknown;
|
|
|
|
|
m_dimension = ResourceViewDimension::Buffer;
|
|
|
|
|
m_buffer = buffer;
|
|
|
|
|
m_bufferOffset = desc.bufferLocation;
|
|
|
|
|
m_bufferSize = static_cast<uint32_t>(buffer->GetSize());
|
|
|
|
|
m_bufferStride = desc.structureByteStride > 0 ? desc.structureByteStride : buffer->GetStride();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool OpenGLResourceView::InitializeAsIndexBuffer(
|
|
|
|
|
OpenGLBuffer* buffer,
|
|
|
|
|
const ResourceViewDesc& desc) {
|
|
|
|
|
if (!buffer) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewType = ResourceViewType::IndexBuffer;
|
|
|
|
|
m_format = desc.format != 0 ? static_cast<Format>(desc.format) : Format::R32_UInt;
|
|
|
|
|
m_dimension = ResourceViewDimension::Buffer;
|
|
|
|
|
m_buffer = buffer;
|
|
|
|
|
m_bufferOffset = desc.bufferLocation;
|
|
|
|
|
m_bufferSize = static_cast<uint32_t>(buffer->GetSize());
|
|
|
|
|
m_bufferStride = buffer->GetStride();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-24 03:49:13 +08:00
|
|
|
unsigned int OpenGLResourceView::GetFramebuffer() const {
|
|
|
|
|
return m_framebuffer ? m_framebuffer->GetFramebuffer() : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int OpenGLResourceView::GetTexture() const {
|
|
|
|
|
return m_texture ? m_texture->GetID() : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int OpenGLResourceView::GetBuffer() const {
|
|
|
|
|
return m_buffer ? m_buffer->GetID() : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace RHI
|
2026-03-25 23:07:22 +08:00
|
|
|
} // namespace XCEngine
|