Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
Geometry11.h
Go to the documentation of this file.
1
#pragma once
2
#include "
FixedFunction11.h
"
3
#include <vector>
4
#include <map>
5
#include <cstdint>
6
7
namespace
Rendering
8
{
9
// The authored layouts are retained on the CPU for mesh editing and physics.
10
// Their GPU representation belongs exclusively to the D3D11 device.
11
struct
VertexLayout11
12
{
13
static
constexpr
UINT
Absent
=UINT(-1);
14
UINT
stride
=0,
position
=0,
normal
=
Absent
,
pointSize
=
Absent
,
diffuse
=
Absent
,
specular
=
Absent
;
15
UINT
uv
[2]{
Absent
,
Absent
},
uvDimensions
[2]{2,2};
16
bool
transformed
=
false
;
17
bool
Valid
()
const
;
18
std::vector<D3D11_INPUT_ELEMENT_DESC>
Elements
()
const
;
19
UINT
PackedColors
()
const
{
return
(
diffuse
!=
Absent
? 1u : 0u)|(
specular
!=
Absent
? 2u : 0u);}
20
bool
operator<
(
const
VertexLayout11
& other)
const
;
21
};
22
23
class
Geometry11
24
{
25
public
:
26
Geometry11
()=
default
;
27
Geometry11
(
const
Geometry11
&)=
delete
;
28
Geometry11
&
operator=
(
const
Geometry11
&)=
delete
;
29
Geometry11
(
Geometry11
&&)=
default
;
30
Geometry11
&
operator=
(
Geometry11
&&)=
default
;
31
HRESULT
Create
(ID3D11Device*
device
,UINT
bytes
,
bool
dynamic
,
bool
index
=
false
,
bool
indices32
=
false
);
32
HRESULT
Lock
(UINT offset,UINT size,
void
** destination,
bool
readOnly
=
false
,
bool
discard=
false
);
33
HRESULT
Unlock
();
34
HRESULT
BindVertices
(ID3D11DeviceContext* context,
const
VertexLayout11
& layout,UINT byteOffset,
bool
canonical);
35
HRESULT
BindIndices
(ID3D11DeviceContext* context);
36
HRESULT
NativeBuffer
(ID3D11DeviceContext* context,ID3D11Buffer** result);
37
const
std::vector<uint8_t>&
Bytes
()
const
{
return
bytes
;}
38
UINT
Size
()
const
{
return
UINT(
bytes
.size());}
39
bool
Indices32
()
const
{
return
indices32
;}
40
bool
Locked
()
const
{
return
locked
;}
41
uint64_t
Revision
()
const
{
return
revision
;}
42
// Keep authored CPU data while releasing every reference to a lost device.
43
void
ReleaseDevice
();
44
HRESULT
RestoreDevice
(ID3D11Device*
device
);
45
void
Reset
();
46
private
:
47
struct
Converted
48
{
49
Microsoft::WRL::ComPtr<ID3D11Buffer>
buffer
;
50
uint64_t
revision
=0;
51
};
52
HRESULT
Upload
(ID3D11DeviceContext* context);
53
Microsoft::WRL::ComPtr<ID3D11Device>
device
;
54
Microsoft::WRL::ComPtr<ID3D11Buffer>
native
;
55
std::vector<uint8_t>
bytes
;
56
std::map<VertexLayout11,Converted>
converted
;
57
uint64_t
revision
=1,
uploaded
=0;
58
bool
dynamic
=
false
,
index
=
false
,
indices32
=
false
,
locked
=
false
,
readOnly
=
false
;
59
};
60
}
HRESULT
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
FixedFunction11.h
Rendering::Geometry11::Create
HRESULT Create(ID3D11Device *device, UINT bytes, bool dynamic, bool index=false, bool indices32=false)
Definition
Geometry11.cpp:44
Rendering::Geometry11::Indices32
bool Indices32() const
Definition
Geometry11.h:39
Rendering::Geometry11::ReleaseDevice
void ReleaseDevice()
Definition
Geometry11.cpp:51
Rendering::Geometry11::revision
uint64_t revision
Definition
Geometry11.h:57
Rendering::Geometry11::NativeBuffer
HRESULT NativeBuffer(ID3D11DeviceContext *context, ID3D11Buffer **result)
Definition
Geometry11.cpp:94
Rendering::Geometry11::RestoreDevice
HRESULT RestoreDevice(ID3D11Device *device)
Definition
Geometry11.cpp:55
Rendering::Geometry11::Geometry11
Geometry11(Geometry11 &&)=default
Rendering::Geometry11::Reset
void Reset()
Definition
Geometry11.cpp:39
Rendering::Geometry11::device
Microsoft::WRL::ComPtr< ID3D11Device > device
Definition
Geometry11.h:53
Rendering::Geometry11::operator=
Geometry11 & operator=(Geometry11 &&)=default
Rendering::Geometry11::BindIndices
HRESULT BindIndices(ID3D11DeviceContext *context)
Definition
Geometry11.cpp:99
Rendering::Geometry11::converted
std::map< VertexLayout11, Converted > converted
Definition
Geometry11.h:56
Rendering::Geometry11::locked
bool locked
Definition
Geometry11.h:58
Rendering::Geometry11::indices32
bool indices32
Definition
Geometry11.h:58
Rendering::Geometry11::Lock
HRESULT Lock(UINT offset, UINT size, void **destination, bool readOnly=false, bool discard=false)
Definition
Geometry11.cpp:65
Rendering::Geometry11::native
Microsoft::WRL::ComPtr< ID3D11Buffer > native
Definition
Geometry11.h:54
Rendering::Geometry11::Geometry11
Geometry11(const Geometry11 &)=delete
Rendering::Geometry11::bytes
std::vector< uint8_t > bytes
Definition
Geometry11.h:55
Rendering::Geometry11::Upload
HRESULT Upload(ID3D11DeviceContext *context)
Definition
Geometry11.cpp:80
Rendering::Geometry11::Locked
bool Locked() const
Definition
Geometry11.h:40
Rendering::Geometry11::index
bool index
Definition
Geometry11.h:58
Rendering::Geometry11::Revision
uint64_t Revision() const
Definition
Geometry11.h:41
Rendering::Geometry11::Geometry11
Geometry11()=default
Rendering::Geometry11::Size
UINT Size() const
Definition
Geometry11.h:38
Rendering::Geometry11::BindVertices
HRESULT BindVertices(ID3D11DeviceContext *context, const VertexLayout11 &layout, UINT byteOffset, bool canonical)
Definition
Geometry11.cpp:104
Rendering::Geometry11::Unlock
HRESULT Unlock()
Definition
Geometry11.cpp:75
Rendering::Geometry11::dynamic
bool dynamic
Definition
Geometry11.h:58
Rendering::Geometry11::readOnly
bool readOnly
Definition
Geometry11.h:58
Rendering::Geometry11::Bytes
const std::vector< uint8_t > & Bytes() const
Definition
Geometry11.h:37
Rendering::Geometry11::uploaded
uint64_t uploaded
Definition
Geometry11.h:57
Rendering::Geometry11::operator=
Geometry11 & operator=(const Geometry11 &)=delete
Rendering
Definition
AdDiagnostics11.cpp:16
Rendering::Geometry11::Converted
Definition
Geometry11.h:48
Rendering::Geometry11::Converted::revision
uint64_t revision
Definition
Geometry11.h:50
Rendering::Geometry11::Converted::buffer
Microsoft::WRL::ComPtr< ID3D11Buffer > buffer
Definition
Geometry11.h:49
Rendering::VertexLayout11
Definition
Geometry11.h:12
Rendering::VertexLayout11::operator<
bool operator<(const VertexLayout11 &other) const
Definition
Geometry11.cpp:19
Rendering::VertexLayout11::uvDimensions
UINT uvDimensions[2]
Definition
Geometry11.h:15
Rendering::VertexLayout11::transformed
bool transformed
Definition
Geometry11.h:16
Rendering::VertexLayout11::uv
UINT uv[2]
Definition
Geometry11.h:15
Rendering::VertexLayout11::position
UINT position
Definition
Geometry11.h:14
Rendering::VertexLayout11::normal
UINT normal
Definition
Geometry11.h:14
Rendering::VertexLayout11::Absent
static constexpr UINT Absent
Definition
Geometry11.h:13
Rendering::VertexLayout11::Valid
bool Valid() const
Definition
Geometry11.cpp:10
Rendering::VertexLayout11::diffuse
UINT diffuse
Definition
Geometry11.h:14
Rendering::VertexLayout11::stride
UINT stride
Definition
Geometry11.h:14
Rendering::VertexLayout11::PackedColors
UINT PackedColors() const
Definition
Geometry11.h:19
Rendering::VertexLayout11::specular
UINT specular
Definition
Geometry11.h:14
Rendering::VertexLayout11::Elements
std::vector< D3D11_INPUT_ELEMENT_DESC > Elements() const
Definition
Geometry11.cpp:24
Rendering::VertexLayout11::pointSize
UINT pointSize
Definition
Geometry11.h:14
Rendering
Geometry11.h
Generated on
for Rise by
1.18.0