@@ -178,9 +178,38 @@ namespace dxvk {
178
178
if (pDesc->Usage & D3DUSAGE_WRITEONLY)
179
179
return D3DERR_INVALIDCALL;
180
180
181
+ constexpr DWORD usageRTOrDS = D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL;
182
+
181
183
// RENDERTARGET and DEPTHSTENCIL must be default pool
182
- constexpr DWORD incompatibleUsages = D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL;
183
- if (pDesc->Pool != D3DPOOL_DEFAULT && (pDesc->Usage & incompatibleUsages))
184
+ if (pDesc->Pool != D3DPOOL_DEFAULT && (pDesc->Usage & usageRTOrDS))
185
+ return D3DERR_INVALIDCALL;
186
+
187
+ // RENDERTARGET and DEPTHSTENCIL in D3DPOOL_DEFAULT
188
+ // can not also have DYNAMIC usage
189
+ if (pDesc->Pool == D3DPOOL_DEFAULT &&
190
+ (pDesc->Usage & usageRTOrDS) &&
191
+ (pDesc->Usage & D3DUSAGE_DYNAMIC))
192
+ return D3DERR_INVALIDCALL;
193
+
194
+ const bool isPlainSurface = ResourceType == D3DRTYPE_SURFACE && !(pDesc->Usage & usageRTOrDS);
195
+ const bool isDepthStencilFormat = IsDepthStencilFormat (pDesc->Format );
196
+
197
+ // With the exception of image surfaces (d3d8)
198
+ // or plain offscreen surfaces (d3d9), depth stencil
199
+ // formats can only be used in D3DPOOL_DEFAULT
200
+ if (!isPlainSurface && pDesc->Pool != D3DPOOL_DEFAULT && isDepthStencilFormat)
201
+ return D3DERR_INVALIDCALL;
202
+
203
+ // Depth stencil formats can not have RENDERTARGET
204
+ // usage, and nothing except depth stencil formats
205
+ // can have DEPTHSTENCIL usage
206
+ if (( isDepthStencilFormat && (pDesc->Usage & D3DUSAGE_RENDERTARGET)) ||
207
+ (!isDepthStencilFormat && (pDesc->Usage & D3DUSAGE_DEPTHSTENCIL)))
208
+ return D3DERR_INVALIDCALL;
209
+
210
+ // Volume textures can not be used as render targets
211
+ if (ResourceType == D3DRTYPE_VOLUMETEXTURE &&
212
+ (pDesc->Usage & D3DUSAGE_RENDERTARGET))
184
213
return D3DERR_INVALIDCALL;
185
214
186
215
// Volume textures in D3DPOOL_SCRATCH must not have DYNAMIC usage
@@ -202,13 +231,13 @@ namespace dxvk {
202
231
pDesc->MipLevels = maxMipLevelCount;
203
232
204
233
if (unlikely (pDesc->Discard )) {
205
- if (!IsDepthStencilFormat (pDesc-> Format ) )
234
+ if (!isDepthStencilFormat )
206
235
return D3DERR_INVALIDCALL;
207
236
208
237
if (pDesc->Format == D3D9Format::D32_LOCKABLE
209
- || pDesc->Format == D3D9Format::D32F_LOCKABLE
210
- || pDesc->Format == D3D9Format::D16_LOCKABLE
211
- || pDesc->Format == D3D9Format::S8_LOCKABLE)
238
+ || pDesc->Format == D3D9Format::D32F_LOCKABLE
239
+ || pDesc->Format == D3D9Format::D16_LOCKABLE
240
+ || pDesc->Format == D3D9Format::S8_LOCKABLE)
212
241
return D3DERR_INVALIDCALL;
213
242
}
214
243
0 commit comments