Playstation 5 input and fixes (#734)

This commit is contained in:
Turánszki János
2023-08-20 16:14:46 +02:00
committed by GitHub
parent 8a20963fff
commit 6a86c8a61f
7 changed files with 70 additions and 11 deletions
+2
View File
@@ -79,8 +79,10 @@ struct IndirectDispatchArgs
};
#if defined(__SCE__) || defined(__PSSL__)
static const uint IndirectDrawArgsAlignment = 8u;
static const uint IndirectDispatchArgsAlignment = 32u;
#else
static const uint IndirectDrawArgsAlignment = 4u;
static const uint IndirectDispatchArgsAlignment = 4u;
#endif // __SCE__ || __PSSL__
@@ -97,7 +97,7 @@ static const uint THREADCOUNT_MESH_SHADER = 32;
static const uint ARGUMENTBUFFER_OFFSET_DISPATCHEMIT = 0;
static const uint ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION = wi::graphics::AlignTo(ARGUMENTBUFFER_OFFSET_DISPATCHEMIT + (3 * 4), IndirectDispatchArgsAlignment);
static const uint ARGUMENTBUFFER_OFFSET_DRAWPARTICLES = wi::graphics::AlignTo(ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION + (3 * 4), IndirectDispatchArgsAlignment);
static const uint ARGUMENTBUFFER_OFFSET_DRAWPARTICLES = wi::graphics::AlignTo(ARGUMENTBUFFER_OFFSET_DISPATCHSIMULATION + (3 * 4), IndirectDrawArgsAlignment);
// If this is not defined, SPH will be resolved as N-body simulation (O(n^2) complexity)
@@ -281,9 +281,9 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
ShaderSphere sphere;
sphere.center = (base + tip) * 0.5;
sphere.radius = len;
const bool visible = !distance_culled && GetCamera().frustum.intersects(sphere);
// Optimization: reduce to 1 atomic operation per wave
const uint waveAppendCount = WaveActiveCountBits(visible);
uint waveOffset;
@@ -291,12 +291,12 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint groupIn
{
InterlockedAdd(indirectBuffer[0].IndexCountPerInstance, waveAppendCount * 6, waveOffset);
}
waveOffset = WaveReadLaneFirst(waveOffset) / 6;
waveOffset = WaveReadLaneFirst(waveOffset);
if (visible)
{
uint prevCount = waveOffset + WavePrefixSum(1u);
uint ii0 = prevCount * 6;
uint prevCount = waveOffset + WavePrefixSum(6u);
uint ii0 = prevCount;
culledIndexBuffer[ii0 + 0] = i0 + 0;
culledIndexBuffer[ii0 + 1] = i0 + 1;
culledIndexBuffer[ii0 + 2] = i0 + 2;
+3 -3
View File
@@ -229,9 +229,9 @@ namespace wi
bd.bind_flags = BindFlag::UNORDERED_ACCESS;
bd.misc_flags = ResourceMiscFlag::BUFFER_RAW | ResourceMiscFlag::INDIRECT_ARGS;
bd.size =
sizeof(IndirectDispatchArgs) +
sizeof(IndirectDispatchArgs) +
sizeof(IndirectDrawArgsInstanced);
AlignTo(sizeof(IndirectDispatchArgs), (uint64_t)IndirectDispatchArgsAlignment) +
AlignTo(sizeof(IndirectDispatchArgs), (uint64_t)IndirectDispatchArgsAlignment) +
AlignTo(sizeof(IndirectDrawArgsInstanced), (uint64_t)IndirectDrawArgsAlignment);
device->CreateBuffer(&bd, nullptr, &indirectBuffers);
device->SetName(&indirectBuffers, "EmittedParticleSystem::indirectBuffers");
+57
View File
@@ -24,6 +24,10 @@
#include <winrt/Windows.Devices.Input.h>
#endif // PLATFORM_UWP
#ifdef PLATFORM_PS5
#include "wiInput_PS5.h"
#endif // PLATFORM_PS5
namespace wi::input
{
#ifdef _WIN32
@@ -75,6 +79,7 @@ namespace wi::input
XINPUT,
RAWINPUT,
SDLINPUT,
PS5,
};
DeviceType deviceType;
int deviceIndex;
@@ -90,6 +95,10 @@ namespace wi::input
wi::input::rawinput::Initialize();
wi::input::sdlinput::Initialize();
#ifdef PLATFORM_PS5
wi::input::ps5::Initialize();
#endif // PLATFORM_PS5
wi::backlog::post("wi::input Initialized (" + std::to_string((int)std::round(timer.elapsed())) + " ms)");
initialized.store(true);
}
@@ -109,6 +118,10 @@ namespace wi::input
wi::input::rawinput::Update();
wi::input::sdlinput::Update();
#ifdef PLATFORM_PS5
wi::input::ps5::Update();
#endif // PLATFORM_PS5
#if defined(_WIN32) && !defined(PLATFORM_XBOX)
wi::input::rawinput::GetMouseState(&mouse); // currently only the relative data can be used from this
wi::input::rawinput::GetKeyboardState(&keyboard);
@@ -322,6 +335,39 @@ namespace wi::input
}
}
#ifdef PLATFORM_PS5
// Check if low-level PS5 controller is not registered for playerindex slot and register:
for (int i = 0; i < wi::input::ps5::GetMaxControllerCount(); ++i)
{
if (wi::input::ps5::GetControllerState(nullptr, i))
{
int slot = -1;
for (int j = 0; j < (int)controllers.size(); ++j)
{
if (slot < 0 && controllers[j].deviceType == Controller::DISCONNECTED)
{
// take the first disconnected slot
slot = j;
}
if (controllers[j].deviceType == Controller::PS5 && controllers[j].deviceIndex == i)
{
// it is already registered to this slot
slot = j;
break;
}
}
if (slot == -1)
{
// no disconnected slot was found, and it was not registered
slot = (int)controllers.size();
controllers.emplace_back();
}
controllers[slot].deviceType = Controller::PS5;
controllers[slot].deviceIndex = i;
}
}
#endif // PLATFORM_PS5
// Read low-level controllers:
for (auto& controller : controllers)
{
@@ -337,6 +383,11 @@ namespace wi::input
case Controller::SDLINPUT:
connected = wi::input::sdlinput::GetControllerState(&controller.state, controller.deviceIndex);
break;
#ifdef PLATFORM_PS5
case Controller::PS5:
connected = wi::input::ps5::GetControllerState(&controller.state, controller.deviceIndex);
break;
#endif // PLATFORM_PS5
case Controller::DISCONNECTED:
connected = false;
break;
@@ -664,6 +715,12 @@ namespace wi::input
{
wi::input::sdlinput::SetControllerFeedback(data, controller.deviceIndex);
}
#ifdef PLATFORM_PS5
else if (controller.deviceType == Controller::PS5)
{
wi::input::ps5::SetControllerFeedback(data, controller.deviceIndex);
}
#endif // PLATFORM_PS5
}
}
+1 -1
View File
@@ -9402,7 +9402,7 @@ void ComputeLuminance(
void CreateBloomResources(BloomResources& res, XMUINT2 resolution)
{
TextureDesc desc;
desc.bind_flags = BindFlag::RENDER_TARGET | BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS;
desc.bind_flags = BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS;
desc.format = Format::R11G11B10_FLOAT;
desc.width = resolution.x / 4;
desc.height = resolution.y / 4;
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 274;
const int revision = 275;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);