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