Skip to content

Commit 681bff1

Browse files
committed
D3D9: drop D3DPOOL_MANAGED for buffers & discard HBU_DETAIL_DISCARDABLE
D3DPOOL_MANAGED, does not give us anything after the multi-monitor rework and is not available with D3D9Ex - thus only complicating code. Consequently *_DISCARDABLE usage was only needed to punch through D3DPOOL_MANAGED and is now gone too.
1 parent da0f536 commit 681bff1

10 files changed

+12
-145
lines changed

OgreMain/include/OgreHardwareBuffer.h

+4-24
Original file line numberDiff line numberDiff line change
@@ -120,34 +120,14 @@ namespace Ogre {
120120
HBU_DYNAMIC = HBU_CPU_ONLY,
121121
/// @deprecated use #HBU_DETAIL_WRITE_ONLY
122122
HBU_WRITE_ONLY = HBU_DETAIL_WRITE_ONLY,
123-
/** Indicates that the application will be refilling the contents
124-
of the buffer regularly (not just updating, but generating the
125-
contents from scratch), and therefore does not mind if the contents
126-
of the buffer are lost somehow and need to be recreated. This
127-
allows and additional level of optimisation on the buffer.
128-
This option only really makes sense when combined with
129-
#HBU_CPU_TO_GPU.
130-
*/
131-
HBU_DETAIL_DISCARDABLE = 8,
132-
/// @deprecated use HBU_DETAIL_DISCARDABLE
133-
HBU_DISCARDABLE = HBU_DETAIL_DISCARDABLE,
123+
/// @deprecated do not use
124+
HBU_DISCARDABLE = 8,
134125
/// same as #HBU_GPU_ONLY
135126
HBU_STATIC_WRITE_ONLY = HBU_GPU_ONLY,
136127
/// same as #HBU_CPU_TO_GPU
137128
HBU_DYNAMIC_WRITE_ONLY = HBU_CPU_TO_GPU,
138-
/** Indicates that the application replaces the entire contents of the buffer on an
139-
regular basis.
140-
Combination of #HBU_CPU_TO_GPU and #HBU_DETAIL_DISCARDABLE.
141-
142-
By selecting this option, you
143-
free the system up from having to be concerned about losing the existing contents
144-
of the buffer at any time, because if it does lose them, you will be replacing them
145-
next frame anyway. On D3D9 this can make a significant performance
146-
difference, so you should try to use this whenever you have a buffer you need to
147-
update regularly. Note that if you create a buffer this way, you should use the
148-
HBL_DISCARD flag when locking the contents of it for writing.
149-
*/
150-
HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HBU_CPU_TO_GPU | HBU_DETAIL_DISCARDABLE,
129+
/// @deprecated do not use
130+
HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HBU_CPU_TO_GPU,
151131
};
152132
/// Locking options
153133
enum LockOptions

OgreMain/include/OgreTexture.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ namespace Ogre {
5757
TU_STATIC_WRITE_ONLY = HBU_GPU_ONLY,
5858
/// same as #HBU_CPU_TO_GPU
5959
TU_DYNAMIC_WRITE_ONLY = HBU_CPU_TO_GPU,
60-
/// same as HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE
61-
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
60+
/// @deprecated do not use
61+
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE = HBU_CPU_TO_GPU,
6262
/// Mipmaps will be automatically generated for this texture
6363
TU_AUTOMIPMAP = 0x10,
6464
/** This texture will be a render target, i.e. used as a target for render to texture

OgreMain/src/OgreVertexIndexData.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,8 @@ namespace Ogre {
461461
for (unsigned short b = 0; b <= newDeclaration->getMaxSource(); ++b)
462462
{
463463
VertexDeclaration::VertexElementList destElems = newDeclaration->findElementsBySource(b);
464-
// Initialise with most restrictive version
465-
// (not really a usable option, but these flags will be removed)
466-
int final = HardwareBuffer::HBU_STATIC_WRITE_ONLY | HardwareBuffer::HBU_DETAIL_DISCARDABLE;
464+
// Initialise with most restrictive version
465+
int final = HardwareBuffer::HBU_STATIC_WRITE_ONLY;
467466
for (VertexElement& destelem : destElems)
468467
{
469468
// get source
@@ -486,12 +485,6 @@ namespace Ogre {
486485
// remove write only
487486
final &= ~HBU_DETAIL_WRITE_ONLY;
488487
}
489-
if (!(srcbuf->getUsage() & HardwareBuffer::HBU_DETAIL_DISCARDABLE))
490-
{
491-
// remove discardable
492-
final &= ~HardwareBuffer::HBU_DETAIL_DISCARDABLE;
493-
}
494-
495488
}
496489
usages.push_back(static_cast<HardwareBuffer::Usage>(final));
497490
}

RenderSystems/Direct3D9/include/OgreD3D9Prerequisites.h

-5
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ namespace Ogre
100100
typedef SharedPtr<D3D9HLSLProgram> D3D9HLSLProgramPtr;
101101
typedef SharedPtr<D3D9Texture> D3D9TexturePtr;
102102

103-
// Should we ask D3D to manage vertex/index buffers automatically?
104-
// Doing so avoids lost devices, but also has a performance impact
105-
// which is unacceptably bad when using very large buffers
106-
#define OGRE_D3D_MANAGE_BUFFERS 1
107-
108103
//-------------------------------------------
109104
// Windows setttings
110105
//-------------------------------------------

RenderSystems/Direct3D9/src/OgreD3D9HardwareBufferManager.cpp

-58
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,6 @@ namespace Ogre {
5252
bool useShadowBuffer)
5353
{
5454
assert (numVerts > 0);
55-
#if OGRE_D3D_MANAGE_BUFFERS
56-
// Override shadow buffer setting; managed buffers are automatically
57-
// backed by system memory
58-
// Don't override shadow buffer if discardable, since then we use
59-
// unmanaged buffers for speed (avoids write-through overhead)
60-
// Don't override if we use directX9EX, since then we don't have managed
61-
// pool. And creating non-write only default pool causes a performance warning.
62-
if (useShadowBuffer && !(usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE) &&
63-
!D3D9RenderSystem::isDirectX9Ex())
64-
{
65-
useShadowBuffer = false;
66-
// Also drop any WRITE_ONLY so we can read direct
67-
if (usage == HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY)
68-
{
69-
usage = HardwareBuffer::HBU_DYNAMIC;
70-
}
71-
else if (usage == HardwareBuffer::HBU_STATIC_WRITE_ONLY)
72-
{
73-
usage = HardwareBuffer::HBU_STATIC;
74-
}
75-
}
76-
//If we have write only buffers in DirectX9Ex we will turn on the discardable flag.
77-
//Otherwise Ogre will operates in far less framerate
78-
if (D3D9RenderSystem::isDirectX9Ex() && (usage & HBU_DETAIL_WRITE_ONLY))
79-
{
80-
usage = (HardwareBuffer::Usage)
81-
((unsigned int)usage | (unsigned int)HardwareBuffer::HBU_DETAIL_DISCARDABLE);
82-
}
83-
#endif
8455
D3D9HardwareVertexBuffer* vbuf = OGRE_NEW D3D9HardwareVertexBuffer(
8556
this, vertexSize, numVerts, usage, useShadowBuffer);
8657
{
@@ -96,35 +67,6 @@ namespace Ogre {
9667
HardwareBuffer::Usage usage, bool useShadowBuffer)
9768
{
9869
assert (numIndexes > 0);
99-
#if OGRE_D3D_MANAGE_BUFFERS
100-
// Override shadow buffer setting; managed buffers are automatically
101-
// backed by system memory
102-
// Don't override shadow buffer if discardable, since then we use
103-
// unmanaged buffers for speed (avoids write-through overhead)
104-
// Don't override if we use directX9EX, since then we don't have managed
105-
// pool. And creating non-write only default pool causes a performance warning.
106-
if (useShadowBuffer && !(usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE) &&
107-
!D3D9RenderSystem::isDirectX9Ex())
108-
{
109-
useShadowBuffer = false;
110-
// Also drop any WRITE_ONLY so we can read direct
111-
if (usage == HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY)
112-
{
113-
usage = HardwareBuffer::HBU_DYNAMIC;
114-
}
115-
else if (usage == HardwareBuffer::HBU_STATIC_WRITE_ONLY)
116-
{
117-
usage = HardwareBuffer::HBU_STATIC;
118-
}
119-
}
120-
//If we have write only buffers in DirectX9Ex we will turn on the discardable flag.
121-
//Otherwise Ogre will operates in far less framerate
122-
if (D3D9RenderSystem::isDirectX9Ex() && (usage & HBU_DETAIL_WRITE_ONLY))
123-
{
124-
usage = (HardwareBuffer::Usage)
125-
((unsigned int)usage | (unsigned int)HardwareBuffer::HBU_DETAIL_DISCARDABLE);
126-
}
127-
#endif
12870
D3D9HardwareIndexBuffer* idx = OGRE_NEW D3D9HardwareIndexBuffer(
12971
this, itype, numIndexes, usage, useShadowBuffer);
13072
{

RenderSystems/Direct3D9/src/OgreD3D9HardwareIndexBuffer.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,8 @@ namespace Ogre {
4848
{
4949
D3D9_DEVICE_ACCESS_CRITICAL_SECTION
5050

51-
D3DPOOL eResourcePool;
52-
53-
#if OGRE_D3D_MANAGE_BUFFERS
54-
eResourcePool = usage == HBU_CPU_ONLY ? D3DPOOL_SYSTEMMEM :
55-
// If not system mem, use managed pool UNLESS buffer is discardable
56-
// if discardable, keeping the software backing is expensive
57-
((usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE) || (D3D9RenderSystem::isDirectX9Ex())) ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
58-
#else
59-
eResourcePool = usage == HBU_CPU_ONLY ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
60-
#endif
61-
6251
// Set the desired memory pool.
63-
mBufferDesc.Pool = eResourcePool;
52+
mBufferDesc.Pool = usage == HBU_CPU_ONLY ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
6453

6554
// Set source buffer to NULL.
6655
mSourceBuffer = NULL;

RenderSystems/Direct3D9/src/OgreD3D9HardwareVertexBuffer.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,8 @@ namespace Ogre {
4848
{
4949
D3D9_DEVICE_ACCESS_CRITICAL_SECTION
5050

51-
D3DPOOL eResourcePool;
52-
53-
#if OGRE_D3D_MANAGE_BUFFERS
54-
eResourcePool = usage == HBU_CPU_ONLY ? D3DPOOL_SYSTEMMEM :
55-
// If not system mem, use managed pool UNLESS buffer is discardable
56-
// if discardable, keeping the software backing is expensive
57-
((usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE) || (D3D9RenderSystem::isDirectX9Ex())) ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
58-
#else
59-
eResourcePool = usage == HBU_CPU_ONLY ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
60-
#endif
61-
6251
// Set the desired memory pool.
63-
mBufferDesc.Pool = eResourcePool;
52+
mBufferDesc.Pool = usage == HBU_CPU_ONLY ? D3DPOOL_SYSTEMMEM : D3DPOOL_DEFAULT;
6453

6554
// Set source buffer to NULL.
6655
mSourceBuffer = NULL;

RenderSystems/Direct3D9/src/OgreD3D9Mappings.cpp

-21
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,7 @@ namespace Ogre
468468
DWORD ret = 0;
469469
if (usage & HardwareBuffer::HBU_DYNAMIC)
470470
{
471-
#if OGRE_D3D_MANAGE_BUFFERS
472-
// Only add the dynamic flag for default pool, and
473-
// we use default pool when buffer is discardable
474-
if (usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE)
475-
ret |= D3DUSAGE_DYNAMIC;
476-
#else
477471
ret |= D3DUSAGE_DYNAMIC;
478-
#endif
479472
}
480473
if (usage & HBU_DETAIL_WRITE_ONLY)
481474
{
@@ -489,16 +482,9 @@ namespace Ogre
489482
DWORD ret = 0;
490483
if (options == HardwareBuffer::HBL_DISCARD)
491484
{
492-
#if OGRE_D3D_MANAGE_BUFFERS
493-
// Only add the discard flag for dynamic usgae and default pool
494-
if ((usage & HardwareBuffer::HBU_DYNAMIC) &&
495-
(usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE))
496-
ret |= D3DLOCK_DISCARD;
497-
#else
498485
// D3D doesn't like discard or no_overwrite on non-dynamic buffers
499486
if (usage & HardwareBuffer::HBU_DYNAMIC)
500487
ret |= D3DLOCK_DISCARD;
501-
#endif
502488
}
503489
if (options == HardwareBuffer::HBL_READ_ONLY)
504490
{
@@ -511,16 +497,9 @@ namespace Ogre
511497
}
512498
if (options == HardwareBuffer::HBL_NO_OVERWRITE)
513499
{
514-
#if OGRE_D3D_MANAGE_BUFFERS
515-
// Only add the nooverwrite flag for dynamic usgae and default pool
516-
if ((usage & HardwareBuffer::HBU_DYNAMIC) &&
517-
(usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE))
518-
ret |= D3DLOCK_NOOVERWRITE;
519-
#else
520500
// D3D doesn't like discard or no_overwrite on non-dynamic buffers
521501
if (usage & HardwareBuffer::HBU_DYNAMIC)
522502
ret |= D3DLOCK_NOOVERWRITE;
523-
#endif
524503
}
525504

526505
return ret;

RenderSystems/Direct3D9/src/OgreD3D9RenderSystem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ namespace Ogre
430430
optMultiDeviceMemHint.name = "Multi device memory hint";
431431
optMultiDeviceMemHint.possibleValues.push_back("Use minimum system memory");
432432
optMultiDeviceMemHint.possibleValues.push_back("Auto hardware buffers management");
433-
optMultiDeviceMemHint.currentValue = "Use minimum system memory";
433+
optMultiDeviceMemHint.currentValue = optMultiDeviceMemHint.possibleValues[1];
434434
optMultiDeviceMemHint.immutable = false;
435435

436436
optEnableFixedPipeline.name = "Fixed Pipeline Enabled";

RenderSystems/Metal/src/OgreMetalHardwareBufferCommon.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ of this software and associated documentation files (the "Software"), to deal
6565
resourceOptions |= MTLResourceStorageModeShared;
6666
}
6767

68-
if( !(usage & HardwareBuffer::HBU_DETAIL_DISCARDABLE) )
68+
if( true )
6969
{
7070
mBuffer = [mDevice->mDevice newBufferWithLength:alignToNextMultiple( sizeBytes, 4u )
7171
options:resourceOptions];

0 commit comments

Comments
 (0)