Reduce the amount of state in CxbxVertexBufferConverter
Also removes some legacy code in XbVertexBuffer
This commit is contained in:
parent
977fdd360c
commit
dd5196f3ca
|
@ -111,11 +111,6 @@ void CxbxPatchedStream::Activate(CxbxDrawContext *pDrawContext, UINT HostStreamN
|
|||
}
|
||||
}
|
||||
|
||||
CxbxPatchedStream::CxbxPatchedStream()
|
||||
{
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
void CxbxPatchedStream::Clear()
|
||||
{
|
||||
if (bCachedHostVertexStreamZeroDataIsAllocated) {
|
||||
|
@ -136,12 +131,6 @@ CxbxPatchedStream::~CxbxPatchedStream()
|
|||
Clear();
|
||||
}
|
||||
|
||||
CxbxVertexBufferConverter::CxbxVertexBufferConverter()
|
||||
{
|
||||
m_uiNbrStreams = 0;
|
||||
m_pCxbxVertexDeclaration = nullptr;
|
||||
}
|
||||
|
||||
// TODO: CountActiveD3DStreams must be removed once we can rely on CxbxGetVertexDeclaration always being set
|
||||
int CountActiveD3DStreams()
|
||||
{
|
||||
|
@ -155,7 +144,7 @@ int CountActiveD3DStreams()
|
|||
return StreamCount;
|
||||
}
|
||||
|
||||
UINT CxbxVertexBufferConverter::GetNbrStreams(CxbxDrawContext *pDrawContext)
|
||||
UINT CxbxVertexBufferConverter::GetNbrStreams(CxbxDrawContext *pDrawContext) const
|
||||
{
|
||||
// Draw..Up always have one stream
|
||||
if (pDrawContext->pXboxVertexStreamZeroData != xbox::zeroptr) {
|
||||
|
@ -237,6 +226,7 @@ void CxbxVertexBufferConverter::PrintStats()
|
|||
void CxbxVertexBufferConverter::ConvertStream
|
||||
(
|
||||
CxbxDrawContext *pDrawContext,
|
||||
CxbxVertexDeclaration* pCxbxVertexDeclaration,
|
||||
UINT uiStream
|
||||
)
|
||||
{
|
||||
|
@ -245,13 +235,13 @@ void CxbxVertexBufferConverter::ConvertStream
|
|||
|
||||
CxbxVertexShaderStreamInfo *pVertexShaderStreamInfo = nullptr;
|
||||
UINT XboxStreamNumber = uiStream;
|
||||
if (m_pCxbxVertexDeclaration != nullptr) {
|
||||
if (uiStream > m_pCxbxVertexDeclaration->NumberOfVertexStreams) {
|
||||
if (pCxbxVertexDeclaration != nullptr) {
|
||||
if (uiStream > pCxbxVertexDeclaration->NumberOfVertexStreams) {
|
||||
LOG_TEST_CASE("uiStream > NumberOfVertexStreams");
|
||||
return;
|
||||
}
|
||||
|
||||
pVertexShaderStreamInfo = &(m_pCxbxVertexDeclaration->VertexStreams[uiStream]);
|
||||
pVertexShaderStreamInfo = &(pCxbxVertexDeclaration->VertexStreams[uiStream]);
|
||||
XboxStreamNumber = pVertexShaderStreamInfo->XboxStreamIndex;
|
||||
}
|
||||
|
||||
|
@ -631,7 +621,7 @@ void CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
|||
if ((pDrawContext->XboxPrimitiveType < xbox::X_D3DPT_POINTLIST) || (pDrawContext->XboxPrimitiveType > xbox::X_D3DPT_POLYGON))
|
||||
CxbxKrnlCleanup("Unknown primitive type: 0x%.02X\n", pDrawContext->XboxPrimitiveType);
|
||||
|
||||
m_pCxbxVertexDeclaration = CxbxGetVertexDeclaration();
|
||||
CxbxVertexDeclaration* pCxbxVertexDeclaration = CxbxGetVertexDeclaration();
|
||||
|
||||
// When this is an indexed draw, take the index buffer into account
|
||||
if (pDrawContext->pXboxIndexData) {
|
||||
|
@ -652,14 +642,14 @@ void CxbxVertexBufferConverter::Apply(CxbxDrawContext *pDrawContext)
|
|||
}
|
||||
|
||||
// Get the number of streams
|
||||
m_uiNbrStreams = GetNbrStreams(pDrawContext);
|
||||
if (m_uiNbrStreams > X_VSH_MAX_STREAMS) {
|
||||
LOG_TEST_CASE("m_uiNbrStreams count > max number of streams");
|
||||
m_uiNbrStreams = X_VSH_MAX_STREAMS;
|
||||
UINT nbrStreams = GetNbrStreams(pDrawContext);
|
||||
if (nbrStreams > X_VSH_MAX_STREAMS) {
|
||||
LOG_TEST_CASE("nbrStreams count > max number of streams");
|
||||
nbrStreams = X_VSH_MAX_STREAMS;
|
||||
}
|
||||
|
||||
for(UINT i = 0; i < m_uiNbrStreams; i++) {
|
||||
ConvertStream(pDrawContext, i);
|
||||
for(UINT i = 0; i < nbrStreams; i++) {
|
||||
ConvertStream(pDrawContext, pCxbxVertexDeclaration, i);
|
||||
}
|
||||
|
||||
if (pDrawContext->XboxPrimitiveType == xbox::X_D3DPT_QUADSTRIP) {
|
||||
|
|
|
@ -55,7 +55,7 @@ CxbxDrawContext;
|
|||
class CxbxPatchedStream
|
||||
{
|
||||
public:
|
||||
CxbxPatchedStream();
|
||||
CxbxPatchedStream() = default;
|
||||
~CxbxPatchedStream();
|
||||
void Clear();
|
||||
void Activate(CxbxDrawContext *pDrawContext, UINT HostStreamNumber) const;
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
class CxbxVertexBufferConverter
|
||||
{
|
||||
public:
|
||||
CxbxVertexBufferConverter();
|
||||
CxbxVertexBufferConverter() = default;
|
||||
void Apply(CxbxDrawContext *pPatchDesc);
|
||||
void PrintStats();
|
||||
private:
|
||||
|
@ -97,25 +97,21 @@ class CxbxVertexBufferConverter
|
|||
}
|
||||
};
|
||||
|
||||
UINT m_uiNbrStreams;
|
||||
|
||||
// Stack tracking
|
||||
ULONG m_TotalCacheHits = 0;
|
||||
ULONG m_TotalCacheMisses = 0;
|
||||
|
||||
UINT m_MaxCacheSize = 10000; // Maximum number of entries in the cache
|
||||
UINT m_CacheElasticity = 200; // Cache is allowed to grow this much more than maximum before being purged to maximum
|
||||
const UINT m_MaxCacheSize = 10000; // Maximum number of entries in the cache
|
||||
const UINT m_CacheElasticity = 200; // Cache is allowed to grow this much more than maximum before being purged to maximum
|
||||
std::unordered_map<StreamKey, std::list<CxbxPatchedStream>::iterator, StreamKeyHash> m_PatchedStreams; // Stores references to patched streams for fast lookup
|
||||
std::list<CxbxPatchedStream> m_PatchedStreamUsageList; // Linked list of vertex streams, least recently used is last in the list
|
||||
CxbxPatchedStream& GetPatchedStream(uint64_t dataKey, uint64_t streamInfoKey); // Fetches (or inserts) a patched stream associated with the given key
|
||||
|
||||
CxbxVertexDeclaration *m_pCxbxVertexDeclaration;
|
||||
|
||||
// Returns the number of streams of a patch
|
||||
UINT GetNbrStreams(CxbxDrawContext *pPatchDesc);
|
||||
UINT GetNbrStreams(CxbxDrawContext *pPatchDesc) const;
|
||||
|
||||
// Patches the types of the stream
|
||||
void ConvertStream(CxbxDrawContext *pPatchDesc, UINT uiStream);
|
||||
void ConvertStream(CxbxDrawContext *pPatchDesc, CxbxVertexDeclaration* pCxbxVertexDeclaration, UINT uiStream);
|
||||
};
|
||||
|
||||
// Inline vertex buffer emulation
|
||||
|
|
Loading…
Reference in New Issue