fix shader calls, add CurrentAppWrapper

This commit is contained in:
Unixian
2025-01-11 18:48:50 -05:00
parent cea40e5ec8
commit 4b8deabbc6
9 changed files with 293 additions and 10 deletions

View File

@@ -463,7 +463,7 @@ namespace d3d11x
_In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances,
UINT NumClassInstances)
{
m_realDeviceCtx->PSSetShader(pPixelShader, ppClassInstances, NumClassInstances);
m_realDeviceCtx->PSSetShader(pPixelShader, nullptr, 0);
}
virtual void STDMETHODCALLTYPE PSSetSamplers(
@@ -479,7 +479,7 @@ namespace d3d11x
_In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances,
UINT NumClassInstances)
{
m_realDeviceCtx->VSSetShader(pVertexShader, ppClassInstances, NumClassInstances);
m_realDeviceCtx->VSSetShader(pVertexShader, nullptr, 0);
}
virtual void STDMETHODCALLTYPE DrawIndexed(
@@ -681,7 +681,7 @@ namespace d3d11x
_In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances,
UINT NumClassInstances)
{
m_realDeviceCtx->GSSetShader(pShader, ppClassInstances, NumClassInstances);
m_realDeviceCtx->GSSetShader(pShader, nullptr, 0);
}
@@ -1075,7 +1075,7 @@ namespace d3d11x
_In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances,
UINT NumClassInstances)
{
m_realDeviceCtx->HSSetShader(pHullShader, ppClassInstances, NumClassInstances);
m_realDeviceCtx->HSSetShader(pHullShader, nullptr, 0);
}
virtual void STDMETHODCALLTYPE HSSetSamplers(
@@ -1143,7 +1143,7 @@ namespace d3d11x
_In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances,
UINT NumClassInstances)
{
m_realDeviceCtx->DSSetShader(pDomainShader, ppClassInstances, NumClassInstances);
m_realDeviceCtx->DSSetShader(pDomainShader, nullptr, 0);
}
virtual void STDMETHODCALLTYPE DSSetSamplers(
@@ -1221,7 +1221,7 @@ namespace d3d11x
_In_reads_opt_(NumClassInstances) ID3D11ClassInstance* const* ppClassInstances,
UINT NumClassInstances)
{
m_realDeviceCtx->CSSetShader(pComputeShader, ppClassInstances, NumClassInstances);
m_realDeviceCtx->CSSetShader(pComputeShader, nullptr, 0);
}
virtual void STDMETHODCALLTYPE CSSetSamplers(
@@ -2102,7 +2102,7 @@ namespace d3d11x
virtual void (InsertWaitUntilIdle)(
_In_ UINT Flags)
{
printf("[ID3D11DeviceContextX] InsertWaitUntilIdle NOT IMPLEMENTED\n");
//printf("[ID3D11DeviceContextX] InsertWaitUntilIdle NOT IMPLEMENTED\n");
}
virtual UINT64 (InsertFence)(

View File

@@ -19,7 +19,6 @@ public:
{
return m_realFactory->ActivateInstance(instance);
}
public:
// ICoreApplicationX
INT32 _abi_get_Id(HSTRING* value) override;

View File

@@ -51,6 +51,10 @@ INT32 CoreWindowWrapperX::_abi_get_Visible(boolean* value)
INT32 CoreWindowWrapperX::_abi_Activate()
{
auto view = winrt::Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
view.TryEnterFullScreenMode();
view.PreferredLaunchWindowingMode(winrt::Windows::UI::ViewManagement::ApplicationViewWindowingMode::FullScreen);
printf("[CoreWindowWrapperX] --> _abi_Activate\n");
return m_realWindow->Activate();
}

View File

@@ -1,5 +1,7 @@
#pragma once
#include <cstdio>
#include "ICoreWindowX.h"
#include <winrt/Windows.UI.ViewManagement.h>
class CoreWindowWrapperX : public ICoreWindowX

View File

@@ -0,0 +1,99 @@
#include "pch.h"
#include "CurrentAppWrapper.hpp"
HRESULT __stdcall CurrentAppWrapperX::QueryInterface(REFIID riid, void** ppvObject)
{
if (riid == __uuidof(IUnknown) || riid == __uuidof(ABI::Windows::ApplicationModel::Store::ICurrentApp))
{
*ppvObject = reinterpret_cast<ABI::Windows::ApplicationModel::Store::ICurrentApp*>(this);
AddRef();
return S_OK;
}
char iidstr[sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}")];
OLECHAR iidwstr[sizeof(iidstr)];
StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr));
WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr);
printf("[CurrentAppWrapperX] Interface Not Implemented: %s\n", iidstr);
*ppvObject = nullptr;
return E_NOINTERFACE;
}
ULONG __stdcall CurrentAppWrapperX::AddRef()
{
return InterlockedIncrement(&m_RefCount);
}
ULONG __stdcall CurrentAppWrapperX::Release()
{
ULONG refCount = InterlockedDecrement(&m_RefCount);
if (refCount == 0)
{
delete this;
}
return refCount;
}
HRESULT CurrentAppWrapperX::GetIids(ULONG* iidCount, IID** iids)
{
printf("[CurrentAppWrapperX] GetIids\n");
return m_realFactory->GetIids(iidCount, iids);
}
HRESULT CurrentAppWrapperX::GetRuntimeClassName(HSTRING* className)
{
printf("[CurrentAppWrapperX] GetRuntimeClassName\n");
return m_realFactory->GetRuntimeClassName(className);
}
HRESULT CurrentAppWrapperX::GetTrustLevel(TrustLevel* trustLevel)
{
printf("[CurrentAppWrapperX] GetTrustLevel\n");
return m_realFactory->GetTrustLevel(trustLevel);
}
HRESULT CurrentAppWrapperX::get_LicenseInformation(ABI::Windows::ApplicationModel::Store::ILicenseInformation** value)
{
printf("[CurrentAppWrapperX] get_LicenseInformation\n");
return E_NOTIMPL;
}
HRESULT CurrentAppWrapperX::get_LinkUri(ABI::Windows::Foundation::IUriRuntimeClass** value)
{
return m_realCurrentApp->get_LinkUri(value);
}
HRESULT CurrentAppWrapperX::get_AppId(GUID* value)
{
return m_realCurrentApp->get_AppId(value);
}
HRESULT CurrentAppWrapperX::RequestAppPurchaseAsync(boolean includeReceipt,
ABI::Windows::Foundation::__FIAsyncOperation_1_HSTRING_t** requestAppPurchaseOperation)
{
return m_realCurrentApp->RequestAppPurchaseAsync(includeReceipt, requestAppPurchaseOperation);
}
HRESULT CurrentAppWrapperX::RequestProductPurchaseAsync(HSTRING productId, boolean includeReceipt,
ABI::Windows::Foundation::__FIAsyncOperation_1_HSTRING_t** requestProductPurchaseOperation)
{
return E_FAIL;
}
HRESULT CurrentAppWrapperX::LoadListingInformationAsync(
ABI::Windows::Foundation::__FIAsyncOperation_1_Windows__CApplicationModel__CStore__CListingInformation_t**
loadListingOperation)
{
return m_realCurrentApp->LoadListingInformationAsync(loadListingOperation);
}
HRESULT CurrentAppWrapperX::GetAppReceiptAsync(
ABI::Windows::Foundation::__FIAsyncOperation_1_HSTRING_t** appReceiptOperation)
{
return m_realCurrentApp->GetAppReceiptAsync(appReceiptOperation);
}
HRESULT CurrentAppWrapperX::GetProductReceiptAsync(HSTRING productId,
ABI::Windows::Foundation::__FIAsyncOperation_1_HSTRING_t** getProductReceiptOperation)
{
return m_realCurrentApp->GetProductReceiptAsync(productId, getProductReceiptOperation);
}

View File

@@ -0,0 +1,165 @@
#pragma once
#include <windows.applicationmodel.store.h>
MIDL_INTERFACE("d52dc065-da3f-4685-995e-9b482eb5e603")
ICurrentAppX : public IInspectable
{
public:
virtual HRESULT STDMETHODCALLTYPE get_LicenseInformation(
ABI::Windows::ApplicationModel::Store::ILicenseInformation* * value
) = 0;
virtual HRESULT STDMETHODCALLTYPE get_LinkUri(
ABI::Windows::Foundation::IUriRuntimeClass** value
) = 0;
virtual HRESULT STDMETHODCALLTYPE get_AppId(
GUID* value
) = 0;
virtual HRESULT STDMETHODCALLTYPE RequestAppPurchaseAsync(
boolean includeReceipt,
__FIAsyncOperation_1_HSTRING** requestAppPurchaseOperation
) = 0;
virtual HRESULT STDMETHODCALLTYPE RequestProductPurchaseAsync(
HSTRING productId,
boolean includeReceipt,
__FIAsyncOperation_1_HSTRING** requestProductPurchaseOperation
) = 0;
virtual HRESULT STDMETHODCALLTYPE LoadListingInformationAsync(
__FIAsyncOperation_1_Windows__CApplicationModel__CStore__CListingInformation** loadListingOperation
) = 0;
virtual HRESULT STDMETHODCALLTYPE GetAppReceiptAsync(
__FIAsyncOperation_1_HSTRING** appReceiptOperation
) = 0;
virtual HRESULT STDMETHODCALLTYPE GetProductReceiptAsync(
HSTRING productId,
__FIAsyncOperation_1_HSTRING** getProductReceiptOperation
) = 0;
};
MIDL_INTERFACE("8eb7dc30-f170-4ed5-8e21-1516da3fd367")
ILicenseInformationX : public IInspectable
{
public:
virtual HRESULT STDMETHODCALLTYPE get_ProductLicenses(
__FIMapView_2_HSTRING_Windows__CApplicationModel__CStore__CProductLicense * *value
) = 0;
virtual HRESULT STDMETHODCALLTYPE get_IsActive(
boolean* value
) = 0;
virtual HRESULT STDMETHODCALLTYPE get_IsTrial(
boolean* value
) = 0;
virtual HRESULT STDMETHODCALLTYPE get_ExpirationDate(
ABI::Windows::Foundation::DateTime* value
) = 0;
virtual HRESULT STDMETHODCALLTYPE add_LicenseChanged(
ABI::Windows::ApplicationModel::Store::ILicenseChangedEventHandler* handler,
EventRegistrationToken* cookie
) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_LicenseChanged(
EventRegistrationToken cookie
) = 0;
};
//class LicenseInformationWrapperX : public RuntimeClass<IActivationFactory, ILicenseInformationX> {
//public:
// LicenseInformationWrapperX(ComPtr<IActivationFactory> realFactory)
// : m_realFactory(realFactory)
// {
// HRESULT hr = m_realFactory.As(&m_realLicenseInformation);
// if (FAILED(hr)) {
// return;
// }
// }
// HRESULT QueryInterface(const IID& riid, void** ppvObject) override;
// ULONG AddRef() override;
// ULONG Release() override;
// HRESULT GetIids(ULONG* iidCount, IID** iids) override;
// HRESULT GetRuntimeClassName(HSTRING* className) override;
// HRESULT GetTrustLevel(TrustLevel* trustLevel) override;
// HRESULT STDMETHODCALLTYPE get_ProductLicenses(
// __FIMapView_2_HSTRING_Windows__CApplicationModel__CStore__CProductLicense** value
// ) override;
// HRESULT STDMETHODCALLTYPE get_IsActive(
// boolean* value
// ) override;
// HRESULT STDMETHODCALLTYPE get_IsTrial(
// boolean* value
// ) override;
// HRESULT STDMETHODCALLTYPE get_ExpirationDate(
// ABI::Windows::Foundation::DateTime* value
// ) override;
// HRESULT STDMETHODCALLTYPE add_LicenseChanged(
// ABI::Windows::ApplicationModel::Store::ILicenseChangedEventHandler* handler,
// EventRegistrationToken* cookie
// ) override;
// HRESULT STDMETHODCALLTYPE remove_LicenseChanged(
// EventRegistrationToken cookie
// ) override;
//};
class CurrentAppWrapperX : public RuntimeClass<IActivationFactory, ICurrentAppX>
{
public:
CurrentAppWrapperX(ComPtr<IActivationFactory> realFactory)
: m_realFactory(realFactory)
{
HRESULT hr = m_realFactory.As(&m_realCurrentApp);
if (FAILED(hr)) {
return;
}
}
HRESULT STDMETHODCALLTYPE ActivateInstance(__RPC__deref_out_opt IInspectable** instance) override
{
return m_realFactory->ActivateInstance(instance);
}
HRESULT QueryInterface(REFIID riid, void** ppvObject) override;
ULONG AddRef() override;
ULONG Release() override;
HRESULT GetIids(ULONG* iidCount, IID** iids) override;
HRESULT GetRuntimeClassName(HSTRING* className) override;
HRESULT GetTrustLevel(TrustLevel* trustLevel) override;
HRESULT STDMETHODCALLTYPE get_LicenseInformation(
ABI::Windows::ApplicationModel::Store::ILicenseInformation** value
) override;
HRESULT STDMETHODCALLTYPE get_LinkUri(
ABI::Windows::Foundation::IUriRuntimeClass** value
) override;
HRESULT STDMETHODCALLTYPE get_AppId(
GUID* value
) override;
HRESULT STDMETHODCALLTYPE RequestAppPurchaseAsync(
boolean includeReceipt,
__FIAsyncOperation_1_HSTRING** requestAppPurchaseOperation
) override;
HRESULT STDMETHODCALLTYPE RequestProductPurchaseAsync(
HSTRING productId,
boolean includeReceipt,
__FIAsyncOperation_1_HSTRING** requestProductPurchaseOperation
) override;
HRESULT STDMETHODCALLTYPE LoadListingInformationAsync(
__FIAsyncOperation_1_Windows__CApplicationModel__CStore__CListingInformation** loadListingOperation
) override;
HRESULT STDMETHODCALLTYPE GetAppReceiptAsync(
__FIAsyncOperation_1_HSTRING** appReceiptOperation
) override;
HRESULT STDMETHODCALLTYPE GetProductReceiptAsync(
HSTRING productId,
__FIAsyncOperation_1_HSTRING** getProductReceiptOperation
) override;
private:
long m_RefCount = 1;
ComPtr<IActivationFactory> m_realFactory;
ComPtr<ABI::Windows::ApplicationModel::Store::ICurrentApp> m_realCurrentApp;
};

View File

@@ -95,6 +95,7 @@
<ItemGroup>
<ClInclude Include="CoreApplicationWrapperX.h" />
<ClInclude Include="CoreWindowWrapperX.h" />
<ClInclude Include="CurrentAppWrapper.hpp" />
<ClInclude Include="framework.h" />
<ClInclude Include="FrameworkViewSourceWrapper.h" />
<ClInclude Include="FrameworkViewWrapper.h" />
@@ -109,6 +110,7 @@
<ItemGroup>
<ClCompile Include="CoreApplicationWrapperX.cpp" />
<ClCompile Include="CoreWindowWrapperX.cpp" />
<ClCompile Include="CurrentAppWrapper.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="FrameworkViewSourceWrapper.cpp" />
<ClCompile Include="FrameworkViewWrapper.cpp" />

View File

@@ -16,6 +16,9 @@
<ClCompile Include="FrameworkViewSourceWrapper.cpp">
<Filter>Windows.ApplicationModel.Core\FrameworkViewSource</Filter>
</ClCompile>
<ClCompile Include="CurrentAppWrapper.cpp">
<Filter>Windows.ApplicationModel.Store\CurrentApp</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
@@ -44,6 +47,9 @@
<ClInclude Include="FrameworkViewSourceWrapper.h">
<Filter>Windows.ApplicationModel.Core\FrameworkViewSource</Filter>
</ClInclude>
<ClInclude Include="CurrentAppWrapper.hpp">
<Filter>Windows.ApplicationModel.Store\CurrentApp</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Exports.def" />
@@ -69,5 +75,11 @@
<Filter Include="Windows.ApplicationModel.Core\FrameworkViewSource">
<UniqueIdentifier>{c767c192-a92b-4536-b8a9-51f27fa78800}</UniqueIdentifier>
</Filter>
<Filter Include="Windows.ApplicationModel.Store">
<UniqueIdentifier>{0ea04282-48ba-45bf-a20f-e7d51e2651c0}</UniqueIdentifier>
</Filter>
<Filter Include="Windows.ApplicationModel.Store\CurrentApp">
<UniqueIdentifier>{19e1cefa-5dbe-43ed-a9ad-b22278e05c1a}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@@ -116,7 +116,7 @@
</Command>
</PostBuildEvent>
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">xinput.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
@@ -130,7 +130,7 @@
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">xinput.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>