mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[d3d9] Clip plane compaction
Compact clip planes to the smallest amount that are enabled. Signed-off-by: Autumn Ashton <misyl@froggi.es>
This commit is contained in:
parent
8c4c814fb7
commit
d956b188ed
@ -5933,17 +5933,21 @@ namespace dxvk {
|
|||||||
auto mapPtr = m_vsClipPlanes.AllocSlice();
|
auto mapPtr = m_vsClipPlanes.AllocSlice();
|
||||||
auto dst = reinterpret_cast<D3D9ClipPlane*>(mapPtr);
|
auto dst = reinterpret_cast<D3D9ClipPlane*>(mapPtr);
|
||||||
|
|
||||||
uint32_t clipPlaneMask = 0u;
|
uint32_t clipPlaneCount = 0u;
|
||||||
for (uint32_t i = 0; i < caps::MaxClipPlanes; i++) {
|
for (uint32_t i = 0; i < caps::MaxClipPlanes; i++) {
|
||||||
dst[i] = (m_state.renderStates[D3DRS_CLIPPLANEENABLE] & (1 << i))
|
D3D9ClipPlane clipPlane = (m_state.renderStates[D3DRS_CLIPPLANEENABLE] & (1 << i))
|
||||||
? m_state.clipPlanes[i]
|
? m_state.clipPlanes[i]
|
||||||
: D3D9ClipPlane();
|
: D3D9ClipPlane();
|
||||||
|
|
||||||
if (dst[i] != D3D9ClipPlane())
|
if (clipPlane != D3D9ClipPlane())
|
||||||
clipPlaneMask |= 1u << i;
|
dst[clipPlaneCount++] = clipPlane;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_specInfo.set<SpecClipPlaneMask>(clipPlaneMask))
|
// Write the rest to 0 for GPL.
|
||||||
|
for (uint32_t i = clipPlaneCount; i < caps::MaxClipPlanes; i++)
|
||||||
|
dst[i] = D3D9ClipPlane();
|
||||||
|
|
||||||
|
if (m_specInfo.set<SpecClipPlaneCount>(clipPlaneCount))
|
||||||
m_flags.set(D3D9DeviceFlag::DirtySpecializationEntries);
|
m_flags.set(D3D9DeviceFlag::DirtySpecializationEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2407,6 +2407,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
m_module.decorateBuiltIn(clipDistArray, spv::BuiltInClipDistance);
|
m_module.decorateBuiltIn(clipDistArray, spv::BuiltInClipDistance);
|
||||||
|
|
||||||
|
// Always consider clip planes enabled when doing GPL by forcing 6 for the quick value.
|
||||||
|
uint32_t clipPlaneCount = m_spec.get(m_module, m_specUbo, SpecClipPlaneCount, 0, 32, m_module.constu32(caps::MaxClipPlanes));
|
||||||
|
|
||||||
// Compute clip distances
|
// Compute clip distances
|
||||||
for (uint32_t i = 0; i < caps::MaxClipPlanes; i++) {
|
for (uint32_t i = 0; i < caps::MaxClipPlanes; i++) {
|
||||||
std::array<uint32_t, 2> blockMembers = {{
|
std::array<uint32_t, 2> blockMembers = {{
|
||||||
@ -2421,9 +2424,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
uint32_t distId = m_module.opDot(floatType, worldPos, planeId);
|
uint32_t distId = m_module.opDot(floatType, worldPos, planeId);
|
||||||
|
|
||||||
// Always consider clip planes enabled when doing GPL by forcing a mask of 0xffffffff for the quick value.
|
uint32_t clipPlaneEnabled = m_module.opULessThan(boolType, m_module.constu32(i), clipPlaneCount);
|
||||||
uint32_t clipPlaneEnabledBit = m_spec.get(m_module, m_specUbo, SpecClipPlaneMask, i, 1, m_module.constu32(0xffffffff));
|
|
||||||
uint32_t clipPlaneEnabled = m_module.opINotEqual(boolType, clipPlaneEnabledBit, m_module.constu32(0));
|
|
||||||
|
|
||||||
uint32_t value = m_module.opSelect(floatType, clipPlaneEnabled, distId, m_module.constf32(0.0f));
|
uint32_t value = m_module.opSelect(floatType, clipPlaneEnabled, distId, m_module.constf32(0.0f));
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ namespace dxvk {
|
|||||||
SpecDrefClamp, // 1 bit for 16 PS samplers | Bits: 16
|
SpecDrefClamp, // 1 bit for 16 PS samplers | Bits: 16
|
||||||
SpecFetch4, // 1 bit for 16 PS samplers | Bits: 16
|
SpecFetch4, // 1 bit for 16 PS samplers | Bits: 16
|
||||||
|
|
||||||
SpecClipPlaneMask, // 6 bits for 6 clip planes | Bits : 6
|
SpecClipPlaneCount, // 3 bits for 6 clip planes | Bits : 3
|
||||||
|
|
||||||
SpecConstantCount,
|
SpecConstantCount,
|
||||||
};
|
};
|
||||||
@ -71,7 +71,7 @@ namespace dxvk {
|
|||||||
{ 4, 0, 16 }, // DrefClamp
|
{ 4, 0, 16 }, // DrefClamp
|
||||||
{ 4, 16, 16 }, // Fetch4
|
{ 4, 16, 16 }, // Fetch4
|
||||||
|
|
||||||
{ 5, 0, 6 }, // ClipPlaneEnabled
|
{ 5, 0, 3 }, // ClipPlaneCount
|
||||||
}};
|
}};
|
||||||
|
|
||||||
template <D3D9SpecConstantId Id, typename T>
|
template <D3D9SpecConstantId Id, typename T>
|
||||||
|
@ -3538,6 +3538,9 @@ void DxsoCompiler::emitControlFlowGenericLoop(
|
|||||||
position.type = { DxsoScalarType::Float32, 4 };
|
position.type = { DxsoScalarType::Float32, 4 };
|
||||||
position.id = m_module.opLoad(vec4Type, positionPtr);
|
position.id = m_module.opLoad(vec4Type, positionPtr);
|
||||||
|
|
||||||
|
// Always consider clip planes enabled when doing GPL by forcing 6 for the quick value.
|
||||||
|
uint32_t clipPlaneCount = m_spec.get(m_module, m_specUbo, SpecClipPlaneCount, 0, 32, m_module.constu32(caps::MaxClipPlanes));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < caps::MaxClipPlanes; i++) {
|
for (uint32_t i = 0; i < caps::MaxClipPlanes; i++) {
|
||||||
std::array<uint32_t, 2> blockMembers = {{
|
std::array<uint32_t, 2> blockMembers = {{
|
||||||
m_module.constu32(0),
|
m_module.constu32(0),
|
||||||
@ -3552,9 +3555,7 @@ void DxsoCompiler::emitControlFlowGenericLoop(
|
|||||||
|
|
||||||
DxsoRegisterValue dist = emitDot(position, plane);
|
DxsoRegisterValue dist = emitDot(position, plane);
|
||||||
|
|
||||||
// Always consider clip planes enabled when doing GPL by forcing a mask of 0xffffffff for the quick value.
|
uint32_t clipPlaneEnabled = m_module.opULessThan(boolType, m_module.constu32(i), clipPlaneCount);
|
||||||
uint32_t clipPlaneEnabledBit = m_spec.get(m_module, m_specUbo, SpecClipPlaneMask, i, 1, m_module.constu32(0xffffffff));
|
|
||||||
uint32_t clipPlaneEnabled = m_module.opINotEqual(boolType, clipPlaneEnabledBit, m_module.constu32(0));
|
|
||||||
|
|
||||||
uint32_t value = m_module.opSelect(floatType, clipPlaneEnabled, dist.id, m_module.constf32(0.0f));
|
uint32_t value = m_module.opSelect(floatType, clipPlaneEnabled, dist.id, m_module.constf32(0.0f));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user