Skip to content

Instantly share code, notes, and snippets.

@ChaosPaladin
Forked from drdaxxy/automata_gi_fix.cpp
Created March 23, 2017 18:51
Show Gist options
  • Save ChaosPaladin/3866a3a3115a63e4448d510747904786 to your computer and use it in GitHub Desktop.
Save ChaosPaladin/3866a3a3115a63e4448d510747904786 to your computer and use it in GitHub Desktop.
/*
* If you're an end user (i.e. you don't know what to do with this file):
* You'll probably want to download Kaldaien's mod, which includes these changes.
*
* http://steamcommunity.com/app/524220/discussions/0/135512104777399045/?ctp=66#c135512305397679122
*
* See the OP of that thread for where to obtain SKIM64.exe (the automated installer).
*/
HRESULT __stdcall CreateBufferHook(void *This, D3D11_BUFFER_DESC *pDesc,
D3D11_SUBRESOURCE_DATA *pInitialData,
ID3D11Buffer **ppBuffer) {
if (pDesc != NULL && pDesc->StructureByteStride == 96 &&
pDesc->ByteWidth == 96 * 128) {
pDesc->ByteWidth = 96 * 16;
}
return CreateBufferOriginal(This, pDesc, pInitialData, ppBuffer);
}
HRESULT __stdcall CreateShaderResourceViewHook(
void *This, ID3D11Resource *pResource,
D3D11_SHADER_RESOURCE_VIEW_DESC *pDesc,
ID3D11ShaderResourceView **ppSRView) {
if (pDesc != NULL && pDesc->ViewDimension == D3D_SRV_DIMENSION_BUFFEREX &&
pDesc->BufferEx.NumElements == 128) {
ID3D11Buffer *pBuf;
HRESULT res =
pResource->QueryInterface(__uuidof(ID3D11Buffer), (void **)&pBuf);
if (SUCCEEDED(res)) {
D3D11_BUFFER_DESC bufferDesc;
pBuf->GetDesc(&bufferDesc);
if (bufferDesc.ByteWidth == 96 * 16) {
pDesc->BufferEx.NumElements = 16;
}
}
}
return CreateShaderResourceViewOriginal(This, pResource, pDesc, ppSRView);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment