light/modules/renderer/private/dx/buffers.hpp

84 lines
1.3 KiB
C++
Raw Normal View History

2022-03-08 21:19:19 +03:30
#pragma once
#include <d3d11.h>
#include <renderer/buffers.hpp>
2022-03-08 21:19:19 +03:30
#include <wrl.h>
2025-07-11 00:05:48 +03:30
namespace lt {
2022-03-08 21:19:19 +03:30
class dxSharedContext;
class dxConstantBuffer: public ConstantBuffer
{
public:
2025-07-05 13:28:41 +03:30
dxConstantBuffer(
ConstantBufferIndex index,
unsigned int size,
Ref<dxSharedContext> sharedContext
);
2022-03-08 21:19:19 +03:30
void bind() override;
2022-03-08 21:19:19 +03:30
void *map() override;
2025-07-05 16:07:51 +03:30
void un_map() override;
2022-03-08 21:19:19 +03:30
private:
Ref<dxSharedContext> m_context;
2022-03-08 21:19:19 +03:30
Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
2025-07-05 16:07:51 +03:30
D3D11_MAPPED_SUBRESOURCE m_map;
2022-03-08 21:19:19 +03:30
2025-07-05 16:07:51 +03:30
unsigned int m_index;
};
2022-03-08 21:19:19 +03:30
2025-07-05 16:07:51 +03:30
class dxVertexBuffer: public VertexBuffer
{
2022-03-08 21:19:19 +03:30
public:
2025-07-05 13:28:41 +03:30
dxVertexBuffer(
float *vertices,
unsigned int stride,
unsigned int count,
Ref<dxSharedContext> sharedContext
);
2025-07-05 16:07:51 +03:30
2022-03-08 21:19:19 +03:30
~dxVertexBuffer();
void bind() override;
2025-07-05 16:07:51 +03:30
void un_bind() override;
2022-03-08 21:19:19 +03:30
2025-07-06 14:02:50 +03:30
auto map() -> void * override;
2025-07-05 16:07:51 +03:30
void un_map() override;
2022-03-08 21:19:19 +03:30
private:
Ref<dxSharedContext> m_context;
2022-03-08 21:19:19 +03:30
Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
2022-03-08 21:19:19 +03:30
2025-07-05 16:07:51 +03:30
D3D11_MAPPED_SUBRESOURCE m_map;
unsigned int m_stride;
};
class dxIndexBuffer: public IndexBuffer
{
2022-03-08 21:19:19 +03:30
public:
2025-07-05 13:28:41 +03:30
dxIndexBuffer(unsigned int *indices, unsigned int count, Ref<dxSharedContext> sharedContext);
2025-07-05 16:07:51 +03:30
2022-03-08 21:19:19 +03:30
~dxIndexBuffer();
void bind() override;
2025-07-05 16:07:51 +03:30
void un_bind() override;
2025-07-05 16:07:51 +03:30
private:
Ref<dxSharedContext> m_context;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_buffer;
2022-03-08 21:19:19 +03:30
};
2025-07-11 00:05:48 +03:30
} // namespace lt