Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
engine
Commits
7a03eb9a
Commit
7a03eb9a
authored
Nov 29, 2020
by
D-AIRY
Browse files
Options
Downloads
Patches
Plain Diff
UINT16 indices when possible
parent
9d7806cb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/anim/DynamicModelShared.cpp
+32
-4
32 additions, 4 deletions
source/anim/DynamicModelShared.cpp
source/anim/DynamicModelShared.h
+1
-0
1 addition, 0 deletions
source/anim/DynamicModelShared.h
with
33 additions
and
4 deletions
source/anim/DynamicModelShared.cpp
+
32
−
4
View file @
7a03eb9a
...
...
@@ -138,6 +138,7 @@ bool CDynamicModelShared::init(IXResourceModelStatic *pResource)
if
(
!
m_pProvider
->
getCore
()
->
isOnMainThread
())
{
m_ppTempIndices
=
new
UINT
*
[
uLodCount
];
m_ppTempIndices16
=
new
USHORT
*
[
uLodCount
];
m_ppTempVertices
=
new
XResourceModelStaticVertexGPU
*
[
uLodCount
];
m_puTempTotalIndices
=
new
UINT
[
uLodCount
];
m_puTempTotalVertices
=
new
UINT
[
uLodCount
];
...
...
@@ -150,6 +151,8 @@ bool CDynamicModelShared::init(IXResourceModelStatic *pResource)
UINT
uTotalIndices
=
0
;
UINT
uTotalVertices
=
0
;
GXINDEXTYPE
indexType
=
GXIT_UINT32
;
for
(
UINT
j
=
0
,
jl
=
m_pResource
->
getSubsetCount
(
i
);
j
<
jl
;
++
j
)
{
auto
pSubset
=
m_pResource
->
getSubset
(
i
,
j
);
...
...
@@ -157,8 +160,22 @@ bool CDynamicModelShared::init(IXResourceModelStatic *pResource)
uTotalVertices
+=
pSubset
->
iVertexCount
;
}
if
(
uTotalVertices
<=
USHRT_MAX
)
{
indexType
=
GXIT_UINT16
;
}
XResourceModelStaticVertexGPU
*
pVertices
=
new
XResourceModelStaticVertexGPU
[
uTotalVertices
];
UINT
*
pIndices
=
new
UINT
[
uTotalIndices
];
UINT
*
pIndices
=
NULL
;
USHORT
*
pIndices16
=
NULL
;
if
(
indexType
==
GXIT_UINT16
)
{
pIndices16
=
new
USHORT
[
uTotalIndices
];
}
else
{
pIndices
=
new
UINT
[
uTotalIndices
];
}
subset_t
subset
;
for
(
UINT
uMaterial
=
0
;
uMaterial
<
m_uMaterialCount
;
++
uMaterial
)
...
...
@@ -193,7 +210,17 @@ bool CDynamicModelShared::init(IXResourceModelStatic *pResource)
dst
.
vBinorm
[
2
]
=
TO_SHORT
(
src
.
vBinorm
.
z
);
#undef TO_SHORT
}
if
(
indexType
==
GXIT_UINT16
)
{
for
(
UINT
k
=
0
;
k
<
pSubset
->
iIndexCount
;
++
k
)
{
(
pIndices16
+
subset
.
uStartIndex
)[
k
]
=
pSubset
->
pIndices
[
k
];
}
}
else
{
memcpy
(
pIndices
+
subset
.
uStartIndex
,
pSubset
->
pIndices
,
sizeof
(
UINT
)
*
pSubset
->
iIndexCount
);
}
m_aLods
[
i
][
uMaterial
]
=
subset
;
...
...
@@ -221,7 +248,7 @@ bool CDynamicModelShared::init(IXResourceModelStatic *pResource)
if
(
m_pProvider
->
getCore
()
->
isOnMainThread
())
{
m_ppIndexBuffer
[
i
]
=
m_pDevice
->
createIndexBuffer
(
sizeof
(
UINT
)
*
uTotalIndices
,
GXBUFFER_USAGE_STATIC
,
GXIT_UINT32
,
pIndices
);
m_ppIndexBuffer
[
i
]
=
m_pDevice
->
createIndexBuffer
(
(
indexType
==
GXIT_UINT16
?
sizeof
(
USHORT
)
:
sizeof
(
UINT
)
)
*
uTotalIndices
,
GXBUFFER_USAGE_STATIC
,
indexType
,
indexType
==
GXIT_UINT16
?
(
void
*
)
pIndices16
:
(
void
*
)
pIndices
);
IGXVertexBuffer
*
pVertexBuffer
=
m_pDevice
->
createVertexBuffer
(
sizeof
(
XResourceModelStaticVertexGPU
)
*
uTotalVertices
,
GXBUFFER_USAGE_STATIC
,
pVertices
);
m_ppRenderBuffer
[
i
]
=
m_pDevice
->
createRenderBuffer
(
1
,
&
pVertexBuffer
,
m_pProvider
->
getVertexDeclaration
());
mem_release
(
pVertexBuffer
);
...
...
@@ -240,6 +267,7 @@ bool CDynamicModelShared::init(IXResourceModelStatic *pResource)
m_ppRenderBuffer
[
i
]
=
NULL
;
m_ppTempIndices
[
i
]
=
pIndices
;
m_ppTempIndices16
[
i
]
=
pIndices16
;
m_ppTempVertices
[
i
]
=
pVertices
;
m_puTempTotalIndices
[
i
]
=
uTotalIndices
;
m_puTempTotalVertices
[
i
]
=
uTotalVertices
;
...
...
@@ -375,7 +403,7 @@ void CDynamicModelShared::initGPUresources()
for
(
UINT
i
=
0
,
l
=
m_aLods
.
size
();
i
<
l
;
++
i
)
{
m_ppIndexBuffer
[
i
]
=
m_pDevice
->
createIndexBuffer
(
sizeof
(
UINT
)
*
m_puTempTotalIndices
[
i
],
GXBUFFER_USAGE_STATIC
,
GXIT_UINT32
,
m_ppTempIndices
[
i
]);
m_ppIndexBuffer
[
i
]
=
m_pDevice
->
createIndexBuffer
(
(
m_ppTempIndices
[
i
]
?
sizeof
(
UINT
)
:
sizeof
(
USHORT
))
*
m_puTempTotalIndices
[
i
],
GXBUFFER_USAGE_STATIC
,
m_ppTempIndices
[
i
]
?
GXIT_UINT32
:
GXIT_UINT16
,
m_ppTempIndices
[
i
]
?
(
void
*
)
m_ppTempIndices
[
i
]
:
(
void
*
)
m_ppTempIndices16
[
i
]);
IGXVertexBuffer
*
pVertexBuffer
=
m_pDevice
->
createVertexBuffer
(
sizeof
(
XResourceModelStaticVertexGPU
)
*
m_puTempTotalVertices
[
i
],
GXBUFFER_USAGE_STATIC
,
m_ppTempVertices
[
i
]);
m_ppRenderBuffer
[
i
]
=
m_pDevice
->
createRenderBuffer
(
1
,
&
pVertexBuffer
,
m_pProvider
->
getVertexDeclaration
());
mem_release
(
pVertexBuffer
);
...
...
This diff is collapsed.
Click to expand it.
source/anim/DynamicModelShared.h
+
1
−
0
View file @
7a03eb9a
...
...
@@ -63,6 +63,7 @@ protected:
IGXIndexBuffer
**
m_ppIndexBuffer
=
NULL
;
UINT
**
m_ppTempIndices
=
NULL
;
USHORT
**
m_ppTempIndices16
=
NULL
;
XResourceModelStaticVertexGPU
**
m_ppTempVertices
=
NULL
;
UINT
*
m_puTempTotalIndices
=
0
;
UINT
*
m_puTempTotalVertices
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment