parent
bde036fc45
commit
605647aecc
|
@ -189,7 +189,7 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
|
|||
|
||||
void main() {
|
||||
const ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
const ivec2 res = ivec2(imageSize(out_indirect_diffuse)) / INDIRECT_SCALE;
|
||||
const ivec2 res = ubo.ubo.res / INDIRECT_SCALE;
|
||||
if (any(greaterThanEqual(pix, res))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -176,8 +176,8 @@ Components blurSamples(const ivec2 res, const ivec2 pix) {
|
|||
}
|
||||
|
||||
void main() {
|
||||
ivec2 res = ivec2(imageSize(base_color_a));
|
||||
ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
const ivec2 res = ubo.ubo.res;
|
||||
const ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
|
||||
if (any(greaterThanEqual(pix, res))) {
|
||||
return;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define vec4 vec4_t
|
||||
#define mat4 matrix4x4
|
||||
typedef int ivec3[3];
|
||||
typedef int ivec2[2];
|
||||
#define TOKENPASTE(x, y) x ## y
|
||||
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
|
||||
#define PAD(x) float TOKENPASTE2(pad_, __LINE__)[x];
|
||||
|
@ -196,6 +197,7 @@ struct PushConstants {
|
|||
struct UniformBuffer {
|
||||
mat4 inv_proj, inv_view;
|
||||
mat4 prev_inv_proj, prev_inv_view;
|
||||
ivec2 res;
|
||||
float ray_cone_width;
|
||||
uint random_seed;
|
||||
uint frame_counter;
|
||||
|
|
|
@ -17,7 +17,7 @@ void main() {
|
|||
const ivec2 pix = ivec2(gl_LaunchIDEXT.xy);
|
||||
#elif defined(RAY_QUERY)
|
||||
const ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
const ivec2 res = ivec2(imageSize(material_rmxx));
|
||||
const ivec2 res = ubo.ubo.res;
|
||||
if (any(greaterThanEqual(pix, res))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ Ray getPrimaryRay(in vec2 uv) {
|
|||
|
||||
void main() {
|
||||
const ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
const ivec2 res = ivec2(imageSize(out_position_t));
|
||||
const ivec2 res = ubo.ubo.res;
|
||||
if (any(greaterThanEqual(pix, res))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "vk_devmem.h"
|
||||
#include "alolcator.h"
|
||||
|
||||
#define MAX_DEVMEM_ALLOCS 16
|
||||
#define MAX_DEVMEM_ALLOCS 32
|
||||
#define DEFAULT_ALLOCATION_SIZE (64 * 1024 * 1024)
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -270,6 +270,14 @@ static int VK_RefGetParm( int parm, int arg )
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
case PARM_WIDESCREEN:
|
||||
return gpGlobals->wideScreen;
|
||||
case PARM_FULLSCREEN:
|
||||
return gpGlobals->fullScreen;
|
||||
case PARM_SCREEN_WIDTH:
|
||||
return gpGlobals->width;
|
||||
case PARM_SCREEN_HEIGHT:
|
||||
return gpGlobals->height;
|
||||
}
|
||||
|
||||
PRINT_NOT_IMPLEMENTED_ARGS("(%s(%d), %d)", getParmName(parm), parm, arg);
|
||||
|
|
|
@ -31,16 +31,8 @@
|
|||
#define MAX_FRAMES_IN_FLIGHT 2
|
||||
|
||||
// TODO settings/realtime modifiable/adaptive
|
||||
#if 1
|
||||
#define FRAME_WIDTH 1280
|
||||
#define FRAME_HEIGHT 800
|
||||
#elif 0
|
||||
#define FRAME_WIDTH 2560
|
||||
#define FRAME_HEIGHT 1440
|
||||
#else
|
||||
#define FRAME_WIDTH 1920
|
||||
#define FRAME_HEIGHT 1080
|
||||
#endif
|
||||
#define MAX_FRAME_WIDTH 3840
|
||||
#define MAX_FRAME_HEIGHT 2160
|
||||
|
||||
// TODO each of these should be registered by the provider of the resource:
|
||||
#define EXTERNAL_RESOUCES(X) \
|
||||
|
@ -100,6 +92,7 @@ static struct {
|
|||
} g_rtx = {0};
|
||||
|
||||
static int findResource(const char *name) {
|
||||
// TODO hash table
|
||||
// Find the exact match if exists
|
||||
// There might be gaps, so we need to check everything
|
||||
for (int i = 0; i < MAX_RESOURCES; ++i) {
|
||||
|
@ -200,7 +193,7 @@ static uint32_t getRandomSeed( void ) {
|
|||
return (uint32_t)gEngine.COM_RandomLong(0, INT32_MAX);
|
||||
}
|
||||
|
||||
static void prepareUniformBuffer( const vk_ray_frame_render_args_t *args, int frame_index, uint32_t frame_counter, float fov_angle_y ) {
|
||||
static void prepareUniformBuffer( const vk_ray_frame_render_args_t *args, int frame_index, uint32_t frame_counter, float fov_angle_y, int frame_width, int frame_height ) {
|
||||
struct UniformBuffer *ubo = (struct UniformBuffer*)((char*)g_rtx.uniform_buffer.mapped + frame_index * g_rtx.uniform_unit_size);
|
||||
|
||||
matrix4x4 proj_inv, view_inv;
|
||||
|
@ -218,7 +211,9 @@ static void prepareUniformBuffer( const vk_ray_frame_render_args_t *args, int fr
|
|||
Matrix4x4_Copy(g_rtx.prev_inv_view, view_inv);
|
||||
Matrix4x4_Copy(g_rtx.prev_inv_proj, proj_inv);
|
||||
|
||||
ubo->ray_cone_width = atanf((2.0f*tanf(DEG2RAD(fov_angle_y) * 0.5f)) / (float)FRAME_HEIGHT);
|
||||
ubo->res[0] = frame_width;
|
||||
ubo->res[1] = frame_height;
|
||||
ubo->ray_cone_width = atanf((2.0f*tanf(DEG2RAD(fov_angle_y) * 0.5f)) / (float)frame_height);
|
||||
ubo->frame_counter = frame_counter;
|
||||
|
||||
parseDebugDisplayValue();
|
||||
|
@ -237,6 +232,7 @@ typedef struct {
|
|||
uint32_t frame_counter;
|
||||
float fov_angle_y;
|
||||
const vk_lights_bindings_t *light_bindings;
|
||||
int frame_width, frame_height;
|
||||
} perform_tracing_args_t;
|
||||
|
||||
static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* args) {
|
||||
|
@ -342,7 +338,7 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
|
|||
// TODO move this to "TLAS producer"
|
||||
g_rtx.res[ExternalResource_tlas].resource = RT_VkAccelPrepareTlas(combuf);
|
||||
|
||||
prepareUniformBuffer(args->render_args, args->frame_index, args->frame_counter, args->fov_angle_y);
|
||||
prepareUniformBuffer(args->render_args, args->frame_index, args->frame_counter, args->fov_angle_y, args->frame_width, args->frame_height);
|
||||
|
||||
{ // FIXME this should be done automatically inside meatpipe, TODO
|
||||
//const uint32_t size = sizeof(struct Lights);
|
||||
|
@ -378,8 +374,8 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
|
|||
|
||||
R_VkMeatpipePerform(g_rtx.mainpipe, combuf, (vk_meatpipe_perfrom_args_t) {
|
||||
.frame_set_slot = args->frame_index,
|
||||
.width = FRAME_WIDTH,
|
||||
.height = FRAME_HEIGHT,
|
||||
.width = args->frame_width,
|
||||
.height = args->frame_height,
|
||||
.resources = g_rtx.mainpipe_resources,
|
||||
});
|
||||
|
||||
|
@ -388,8 +384,8 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
|
|||
.in_stage = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
.src = {
|
||||
.image = g_rtx.mainpipe_out->image.image,
|
||||
.width = FRAME_WIDTH,
|
||||
.height = FRAME_HEIGHT,
|
||||
.width = args->frame_width,
|
||||
.height = args->frame_height,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
||||
},
|
||||
|
@ -495,8 +491,8 @@ static void reloadMainpipe(void) {
|
|||
}
|
||||
const r_vk_image_create_t create = {
|
||||
.debug_name = mr->name,
|
||||
.width = FRAME_WIDTH,
|
||||
.height = FRAME_HEIGHT,
|
||||
.width = MAX_FRAME_WIDTH,
|
||||
.height = MAX_FRAME_HEIGHT,
|
||||
.depth = 1,
|
||||
.mips = 1,
|
||||
.layers = 1,
|
||||
|
@ -619,6 +615,9 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
|
|||
// Feed tlas with dynamic data
|
||||
RT_DynamicModelProcessFrame();
|
||||
|
||||
const int frame_width = Q_min(args->dst.width, MAX_FRAME_WIDTH);
|
||||
const int frame_height = Q_min(args->dst.height, MAX_FRAME_HEIGHT);
|
||||
|
||||
// Do not draw when we have no swapchain
|
||||
if (args->dst.image_view == VK_NULL_HANDLE)
|
||||
goto tail;
|
||||
|
@ -628,8 +627,8 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
|
|||
.in_stage = VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
.src = {
|
||||
.image = g_rtx.mainpipe_out->image.image,
|
||||
.width = FRAME_WIDTH,
|
||||
.height = FRAME_HEIGHT,
|
||||
.width = frame_width,
|
||||
.height = frame_height,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||
},
|
||||
|
@ -651,6 +650,8 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
|
|||
.frame_counter = g_rtx.frame_number,
|
||||
.fov_angle_y = args->fov_angle_y,
|
||||
.light_bindings = &light_bindings,
|
||||
.frame_width = frame_width,
|
||||
.frame_height = frame_height,
|
||||
};
|
||||
performTracing( args->combuf, &trace_args );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue