tighter packing for ShaderMeshInstancePointer
This commit is contained in:
@@ -311,28 +311,30 @@ struct ShaderMeshInstance
|
||||
};
|
||||
struct ShaderMeshInstancePointer
|
||||
{
|
||||
uint instanceIndex;
|
||||
uint userdata;
|
||||
uint instanceIndex_frustumIndex_dither;
|
||||
|
||||
void init()
|
||||
{
|
||||
instanceIndex = ~0;
|
||||
userdata = 0;
|
||||
instanceIndex_frustumIndex_dither = ~0;
|
||||
}
|
||||
void Create(uint _instanceIndex, uint frustum_index, float dither)
|
||||
void Create(uint _instanceIndex, uint frustum_index = 0, float dither = 0)
|
||||
{
|
||||
instanceIndex = _instanceIndex;
|
||||
userdata = 0;
|
||||
userdata |= frustum_index & 0xF;
|
||||
userdata |= (uint(dither * 255.0f) & 0xFF) << 4u;
|
||||
instanceIndex_frustumIndex_dither = 0;
|
||||
instanceIndex_frustumIndex_dither |= _instanceIndex & 0xFFFFFF;
|
||||
instanceIndex_frustumIndex_dither |= (frustum_index & 0xF) << 24u;
|
||||
instanceIndex_frustumIndex_dither |= (uint(dither * 15.0f) & 0xF) << 28u;
|
||||
}
|
||||
uint GetInstanceIndex()
|
||||
{
|
||||
return instanceIndex_frustumIndex_dither & 0xFFFFFF;
|
||||
}
|
||||
uint GetFrustumIndex()
|
||||
{
|
||||
return userdata & 0xF;
|
||||
return (instanceIndex_frustumIndex_dither >> 24u) & 0xF;
|
||||
}
|
||||
float GetDither()
|
||||
{
|
||||
return ((userdata >> 4u) & 0xFF) / 255.0f;
|
||||
return float((instanceIndex_frustumIndex_dither >> 28u) & 0xF) / 15.0f;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ VSOut main(uint fakeIndex : SV_VERTEXID)
|
||||
const uint instanceID = fakeIndex / 6;
|
||||
|
||||
ShaderMeshInstancePointer poi = impostorBuffer.Load<ShaderMeshInstancePointer>(push.instanceOffset + instanceID * sizeof(ShaderMeshInstancePointer));
|
||||
ShaderMeshInstance instance = load_instance(poi.instanceIndex);
|
||||
ShaderMeshInstance instance = load_instance(poi.GetInstanceIndex());
|
||||
ShaderGeometry geometry = load_geometry(instance.geometryOffset);
|
||||
float3 extents = geometry.aabb_max - geometry.aabb_min;
|
||||
float radius = max(extents.x, max(extents.y, extents.z)) * 0.5;
|
||||
@@ -61,7 +61,7 @@ VSOut main(uint fakeIndex : SV_VERTEXID)
|
||||
Out.uv = uv;
|
||||
Out.slice = slice;
|
||||
Out.dither = poi.GetDither();
|
||||
Out.instanceID = poi.instanceIndex;
|
||||
Out.instanceID = poi.GetInstanceIndex();
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ struct VertexInput
|
||||
ShaderMeshInstance GetInstance()
|
||||
{
|
||||
if (push.instances >= 0)
|
||||
return load_instance(GetInstancePointer().instanceIndex);
|
||||
return load_instance(GetInstancePointer().GetInstanceIndex());
|
||||
|
||||
ShaderMeshInstance inst;
|
||||
inst.init();
|
||||
@@ -940,7 +940,7 @@ PixelInput main(VertexInput input)
|
||||
PixelInput Out;
|
||||
|
||||
#ifdef OBJECTSHADER_USE_INSTANCEINDEX
|
||||
Out.instanceIndex = input.GetInstancePointer().instanceIndex;
|
||||
Out.instanceIndex = input.GetInstancePointer().GetInstanceIndex();
|
||||
#endif // OBJECTSHADER_USE_INSTANCEINDEX
|
||||
|
||||
VertexSurface surface;
|
||||
|
||||
@@ -872,6 +872,9 @@ namespace wi::gui
|
||||
sprites_knob[i].params.siz.y = scale.y - knob_inset_border.y * 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsScrollbarRequired())
|
||||
state = IDLE;
|
||||
}
|
||||
void ScrollBar::Render(const wi::Canvas& canvas, CommandList cmd) const
|
||||
{
|
||||
|
||||
@@ -5965,8 +5965,7 @@ void DrawDebugWorld(
|
||||
|
||||
GraphicsDevice::GPUAllocation mem = device->AllocateGPU(sizeof(ShaderMeshInstancePointer), cmd);
|
||||
ShaderMeshInstancePointer poi;
|
||||
poi.init();
|
||||
poi.instanceIndex = (uint)scene.objects.GetIndex(x.objectEntity);
|
||||
poi.Create((uint)scene.objects.GetIndex(x.objectEntity));
|
||||
std::memcpy(mem.data, &poi, sizeof(poi));
|
||||
|
||||
device->BindIndexBuffer(&mesh.generalBuffer, mesh.GetIndexFormat(), mesh.ib.offset, cmd);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 60;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 90;
|
||||
const int revision = 91;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user