Separate image depth and samples count.
Previously, multisampled images used the 'depth' member of 3D images
or 2D arrays as the number of samples. This caused rendering to a
layer of a 2D array to be interpreted as rendering to a multisampled
render target. This change adds a 'samples' member which is orthogonal
to 'depth'.
Note that write operations put the same color into each of the samples,
while read operations (still) assume multisampled images have been
resolved into the first slice.
Change-Id: Ib33a0cf8194e19fcbb569b0c257ba1e1bd9c4821
Reviewed-on: https://swiftshader-review.googlesource.com/14808
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/D3D9/Direct3DSurface9.cpp b/src/D3D9/Direct3DSurface9.cpp
index f2001b7..e061c87 100644
--- a/src/D3D9/Direct3DSurface9.cpp
+++ b/src/D3D9/Direct3DSurface9.cpp
@@ -77,7 +77,7 @@
}
Direct3DSurface9::Direct3DSurface9(Direct3DDevice9 *device, Unknown *container, int width, int height, D3DFORMAT format, D3DPOOL pool, D3DMULTISAMPLE_TYPE multiSample, unsigned int quality, bool lockableOverride, unsigned long usage)
- : Direct3DResource9(device, D3DRTYPE_SURFACE, pool, memoryUsage(width, height, format)), Surface(getParentResource(container), width, height, sampleCount(multiSample, quality), 0, translateFormat(format), isLockable(pool, usage, lockableOverride), (usage & D3DUSAGE_RENDERTARGET) || (usage & D3DUSAGE_DEPTHSTENCIL)), container(container), width(width), height(height), format(format), pool(pool), multiSample(multiSample), quality(quality), lockable(isLockable(pool, usage, lockableOverride)), usage(usage)
+ : Direct3DResource9(device, D3DRTYPE_SURFACE, pool, memoryUsage(width, height, multiSample, quality, format)), Surface(getParentResource(container), width, height, 1, 0, sampleCount(multiSample, quality), translateFormat(format), isLockable(pool, usage, lockableOverride), (usage & D3DUSAGE_RENDERTARGET) || (usage & D3DUSAGE_DEPTHSTENCIL)), container(container), width(width), height(height), format(format), pool(pool), multiSample(multiSample), quality(quality), lockable(isLockable(pool, usage, lockableOverride)), usage(usage)
{
parentTexture = dynamic_cast<Direct3DBaseTexture9*>(container);
}
@@ -411,8 +411,8 @@
return Surface::bytes(translateFormat(format));
}
- unsigned int Direct3DSurface9::memoryUsage(int width, int height, D3DFORMAT format)
+ unsigned int Direct3DSurface9::memoryUsage(int width, int height, D3DMULTISAMPLE_TYPE multiSample, unsigned int quality, D3DFORMAT format)
{
- return Surface::size(width, height, 1, 0, translateFormat(format));
+ return Surface::size(width, height, 1, 0, sampleCount(multiSample, quality), translateFormat(format));
}
}