Skip to content

Commit

Permalink
Reduce d3d11 size
Browse files Browse the repository at this point in the history
The iostream include adds about 10 MB with mingw-w64-gcc. Also, we
don't log much anymore, so there's no need for the mutex.
  • Loading branch information
pg9182 committed Feb 17, 2022
1 parent 9e5ade4 commit 24d2974
Show file tree
Hide file tree
Showing 35 changed files with 97 additions and 277 deletions.
24 changes: 0 additions & 24 deletions src/d3d11/com_guid.cc

This file was deleted.

8 changes: 0 additions & 8 deletions src/d3d11/com_guid.h

This file was deleted.

31 changes: 0 additions & 31 deletions src/d3d11/com_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,6 @@ namespace dxvk {

};

/**
* \brief Clamped, reference-counted COM object
*
* This version of ComObject ensures that the reference
* count does not wrap around if a release happens at zero.
* eg. [m_refCount = 0]
* Release()
* [m_refCount = 0]
* This is a notable quirk of D3D9's COM implementation
* and is relied upon by some games.
*/
template<typename Base>
class ComObjectClamp : public ComObject<Base> {

public:

ULONG STDMETHODCALLTYPE Release() {
ULONG refCount = this->m_refCount;
if (likely(refCount != 0ul)) {
this->m_refCount--;
refCount--;

if (refCount == 0ul)
this->ReleasePrivate();
}

return refCount;
}

};

template<typename T>
inline void InitReturnPtr(T** ptr) {
if (ptr != nullptr)
Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_blend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
6 changes: 3 additions & 3 deletions src/d3d11/d3d11_class_linkage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand All @@ -40,7 +40,7 @@ namespace dxvk {
UINT SamplerOffset,
ID3D11ClassInstance **ppInstance) {
InitReturnPtr(ppInstance);
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand All @@ -49,7 +49,7 @@ namespace dxvk {
LPCSTR pClassInstanceName,
UINT InstanceIndex,
ID3D11ClassInstance **ppInstance) {
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_cmdlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
4 changes: 2 additions & 2 deletions src/d3d11/d3d11_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down Expand Up @@ -849,7 +849,7 @@ namespace dxvk {
auto shader = static_cast<D3D11GeometryShader*>(pShader);

if (NumClassInstances != 0)
log("err", "D3D11: Class instances not supported");
DXVK_LOG("err", "Class instances not supported");

if (m_state.gs.shader != shader) {
m_state.gs.shader = shader;
Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_depth_stencil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
20 changes: 10 additions & 10 deletions src/d3d11/d3d11_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ namespace dxvk {
desc.ContextType = D3D11_CONTEXT_TYPE_ALL;

if (desc.Query != D3D11_QUERY_OCCLUSION_PREDICATE) {
log("warn", str::format("D3D11: Unhandled predicate type: ", pPredicateDesc->Query));
DXVK_LOG("warn", "Unhandled predicate type: %d", pPredicateDesc->Query);
return E_INVALIDARG;
}

Expand All @@ -740,7 +740,7 @@ namespace dxvk {
ID3D11Counter** ppCounter) {
InitReturnPtr(ppCounter);

log("err", str::format("D3D11: Unsupported counter: ", pCounterDesc->Counter));
DXVK_LOG("err", "Unsupported counter: %d", pCounterDesc->Counter);
return E_INVALIDARG;
}

Expand Down Expand Up @@ -823,7 +823,7 @@ namespace dxvk {
REFIID ReturnedInterface,
void** ppFence) {
InitReturnPtr(ppFence);
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand Down Expand Up @@ -853,7 +853,7 @@ namespace dxvk {
REFIID ReturnedInterface,
void** ppResource) {
InitReturnPtr(ppResource);
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand All @@ -863,7 +863,7 @@ namespace dxvk {
REFIID ReturnedInterface,
void** ppResource) {
InitReturnPtr(ppResource);
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand All @@ -874,7 +874,7 @@ namespace dxvk {
REFIID returnedInterface,
void** ppResource) {
InitReturnPtr(ppResource);
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand All @@ -884,7 +884,7 @@ namespace dxvk {
REFIID ReturnedInterface,
void** ppFence) {
InitReturnPtr(ppFence);
log("stub", __func__);
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand Down Expand Up @@ -1094,7 +1094,7 @@ namespace dxvk {
if (riid == GUID{0xd56e2a4c,0x5127,0x8437,{0x65,0x8a,0x98,0xc5,0xbb,0x78,0x94,0x98}})
return E_NOINTERFACE;

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down Expand Up @@ -1166,7 +1166,7 @@ namespace dxvk {

// We don't support shared resources
if (NumSurfaces && pSharedResource)
log("err", "D3D11: CreateSurface: Shared surfaces not supported");
DXVK_LOG("err", "CreateSurface: Shared surfaces not supported");

// Try to create the given number of surfaces
uint32_t surfacesCreated = 0;
Expand Down Expand Up @@ -1296,7 +1296,7 @@ namespace dxvk {


HRESULT STDMETHODCALLTYPE D3D11DXGIDevice::EnqueueSetEvent(HANDLE hEvent) {
log("stub", __func__);
DXVK_LOG_STUB();
return DXGI_ERROR_UNSUPPORTED;
}

Expand Down
2 changes: 2 additions & 0 deletions src/d3d11/d3d11_device_child.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <atomic>

#include "com_private_data.h"
#include "d3d11_include.h"

Expand Down
3 changes: 0 additions & 3 deletions src/d3d11/d3d11_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
#define DLLEXPORT __declspec(dllexport)
#endif

#include "com_guid.h"
#include "com_object.h"
#include "com_pointer.h"

#include "log.h"

#include "util_likely.h"
#include "util_math.h"
#include "util_string.h"

#include <dxgi1_6.h>
#include <d3d11_4.h>
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_input_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
12 changes: 6 additions & 6 deletions src/d3d11/d3d11_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
}

if (flId == FeatureLevels) {
log("err", "D3D11CoreCreateDevice: Requested feature level not supported");
DXVK_LOG_FUNC("err", "Requested feature level not supported");
return E_INVALIDARG;
}

Expand Down Expand Up @@ -76,19 +76,19 @@ extern "C" {
hr = (new DxgiFactory(0))->QueryInterface(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory));

if (FAILED(hr)) {
log("err", "D3D11CreateDevice: Failed to create a DXGI factory");
DXVK_LOG_FUNC("err", "Failed to create a DXGI factory");
return hr;
}

hr = dxgiFactory->EnumAdapters(0, &dxgiAdapter);

if (FAILED(hr)) {
log("err", "D3D11CreateDevice: No default adapter available");
DXVK_LOG_FUNC("err", "No default adapter available");
return hr;
}
} else {
if (FAILED(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory)))) {
log("err", "D3D11CreateDevice: Failed to query DXGI factory from DXGI adapter");
DXVK_LOG_FUNC("err", "Failed to query DXGI factory from DXGI adapter");
return E_INVALIDARG;
}

Expand All @@ -110,7 +110,7 @@ extern "C" {
hr = dxgiFactory->CreateSwapChain(device.ptr(), &desc, ppSwapChain);

if (FAILED(hr)) {
log("err", "D3D11CreateDevice: Failed to create swap chain");
DXVK_LOG_FUNC("err", "Failed to create swap chain");
return hr;
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ extern "C" {
ID3D11Device** ppDevice,
D3D_FEATURE_LEVEL* pFeatureLevel,
ID3D11DeviceContext** ppImmediateContext) {
dxvk::log("d3d11", "initializing d3d11 stub for northstar (github.com/R2Northstar/NorthstarStubs)");
DXVK_LOG("D3D11CreateDevice", "initializing d3d11 stub for northstar (github.com/R2Northstar/NorthstarStubs)");

return D3D11InternalCreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags,
Expand Down
7 changes: 3 additions & 4 deletions src/d3d11/d3d11_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ namespace dxvk {
}
}

log("warn", "D3D11Query: Unknown interface query");
log("warn", str::format(riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down Expand Up @@ -79,7 +78,7 @@ namespace dxvk {
return sizeof(BOOL);
}

log("err", "D3D11Query: Failed to query data size");
DXVK_LOG_FUNC("err", "Failed to query data size");
return 0;
}

Expand Down Expand Up @@ -146,7 +145,7 @@ namespace dxvk {
} return S_OK;

default:
log("err", str::format("D3D11: Unhandled query type in GetData: ", m_desc.Query));
DXVK_LOG_FUNC("err", "Unhandled query type: %d", m_desc.Query);
return E_INVALIDARG;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
6 changes: 3 additions & 3 deletions src/d3d11/d3d11_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11DXGIResource::GetSharedHandle(
HANDLE* pSharedHandle) {
InitReturnPtr(pSharedHandle);
log("err", "D3D11DXGIResource::GetSharedHandle: Stub");
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand Down Expand Up @@ -133,7 +133,7 @@ namespace dxvk {
LPCWSTR lpName,
HANDLE* pHandle) {
InitReturnPtr(pHandle);
log("err", "D3D11DXGIResource::CreateSharedHandle: Stub");
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand All @@ -142,7 +142,7 @@ namespace dxvk {
UINT index,
IDXGISurface2** ppSurface) {
InitReturnPtr(ppSurface);
log("err", "D3D11DXGIResource::CreateSubresourceSurface: Stub");
DXVK_LOG_STUB();
return E_NOTIMPL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace dxvk {
return S_OK;
}

log("warn", str::format(__func__, " Unknown interface query ", riid));
DXVK_LOG_UNK_IFACE(riid);
return E_NOINTERFACE;
}

Expand Down
Loading

0 comments on commit 24d2974

Please sign in to comment.