path tracing texture streaming fixes
This commit is contained in:
@@ -323,13 +323,11 @@ inline void write_mipmap_feedback(uint materialIndex, float4 uvsets_dx, float4 u
|
||||
InterlockedOr(bindless_rwbuffers_uint[GetScene().texturestreamingbuffer][materialIndex], mask);
|
||||
}
|
||||
}
|
||||
inline void write_mipmap_feedback(uint materialIndex, float lod_uvset0, float lod_uvset1)
|
||||
inline void write_mipmap_feedback(uint materialIndex, uint resolution0, uint resolution1)
|
||||
{
|
||||
[branch]
|
||||
if(WaveIsFirstLane() && GetScene().texturestreamingbuffer >= 0)
|
||||
{
|
||||
const uint resolution0 = 65536u >> uint(max(0, lod_uvset0));
|
||||
const uint resolution1 = 65536u >> uint(max(0, lod_uvset1));
|
||||
const uint mask = resolution0 | (resolution1 << 16u);
|
||||
InterlockedOr(bindless_rwbuffers_uint[GetScene().texturestreamingbuffer][materialIndex], mask);
|
||||
}
|
||||
@@ -1505,16 +1503,19 @@ float twice_uv_area(float2 t0, float2 t1, float2 t2)
|
||||
return abs((t1.x - t0.x) * (t2.y - t0.y) - (t2.x - t0.x) * (t1.y - t0.y));
|
||||
}
|
||||
// https://media.contentapi.ea.com/content/dam/ea/seed/presentations/2019-ray-tracing-gems-chapter-20-akenine-moller-et-al.pdf
|
||||
float compute_texture_lod(uint width, uint height, float triangle_constant, float3 ray_direction, float3 surf_normal, float cone_width)
|
||||
{
|
||||
float lambda = triangle_constant;
|
||||
lambda += log2(abs(cone_width));
|
||||
lambda += 0.5 * log2(float(width) * float(height));
|
||||
lambda -= log2(abs(dot(normalize(ray_direction), surf_normal)));
|
||||
return lambda;
|
||||
}
|
||||
float compute_texture_lod(Texture2D tex, float triangle_constant, float3 ray_direction, float3 surf_normal, float cone_width)
|
||||
{
|
||||
uint w, h;
|
||||
tex.GetDimensions(w, h);
|
||||
|
||||
float lambda = triangle_constant;
|
||||
lambda += log2(abs(cone_width));
|
||||
lambda += 0.5 * log2(float(w) * float(h));
|
||||
lambda -= log2(abs(dot(normalize(ray_direction), surf_normal)));
|
||||
return lambda;
|
||||
return compute_texture_lod(w, h, triangle_constant, ray_direction, surf_normal, cone_width);
|
||||
}
|
||||
float pixel_cone_spread_angle_from_image_height(float image_height)
|
||||
{
|
||||
|
||||
@@ -419,7 +419,12 @@ struct Surface
|
||||
#ifdef SURFACE_LOAD_MIPCONE
|
||||
lod_constant0 = 0.5 * log2(twice_uv_area(uv0.xy, uv1.xy, uv2.xy) * triangle_constant);
|
||||
lod_constant1 = 0.5 * log2(twice_uv_area(uv0.zw, uv1.zw, uv2.zw) * triangle_constant);
|
||||
write_mipmap_feedback(geometry.materialIndex, lod_constant0, lod_constant1);
|
||||
|
||||
const float lod_uvset0 = compute_texture_lod(65536, 65536, lod_constant0, ray_direction, surf_normal, cone_width);
|
||||
const float lod_uvset1 = compute_texture_lod(65536, 65536, lod_constant1, ray_direction, surf_normal, cone_width);
|
||||
const uint resolution0 = 65536u >> uint(max(0, lod_uvset0));
|
||||
const uint resolution1 = 65536u >> uint(max(0, lod_uvset1));
|
||||
write_mipmap_feedback(geometry.materialIndex, resolution0, resolution1);
|
||||
#endif // SURFACE_LOAD_MIPCONE
|
||||
|
||||
#ifdef SURFACE_LOAD_QUAD_DERIVATIVES
|
||||
|
||||
@@ -352,6 +352,8 @@ namespace wi
|
||||
|
||||
RenderPath2D::Update(dt);
|
||||
|
||||
float update_speed = 0;
|
||||
|
||||
const bool hw_raytrace = device->CheckCapability(GraphicsDeviceCapability::RAYTRACING);
|
||||
if (getSceneUpdateEnabled())
|
||||
{
|
||||
@@ -365,11 +367,12 @@ namespace wi
|
||||
{
|
||||
scene->SetAccelerationStructureUpdateRequested(true);
|
||||
}
|
||||
|
||||
scene->camera = *camera;
|
||||
scene->Update(dt * wi::renderer::GetGameSpeed());
|
||||
update_speed = dt * wi::renderer::GetGameSpeed();
|
||||
}
|
||||
|
||||
scene->Update(update_speed);
|
||||
|
||||
// Frustum culling for main camera:
|
||||
visibility_main.layerMask = getLayerMask();
|
||||
visibility_main.scene = scene;
|
||||
|
||||
@@ -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 = 472;
|
||||
const int revision = 473;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user