DRW: Remove DRWTextureFormat in favor or GPUTextureFormat.
Because: - Less redundancy. - Better suffixes. Also a few modification to GPU_texture_create_* to simplify the API: - make the format explicit to the texture creation process. - remove the component count as it's specified in the GPUTextureFormat.
This commit is contained in:
parent
41431eacfa
commit
eb7188802d
|
@ -264,7 +264,7 @@ static struct GPUTexture *load_matcaps(PreviewImage *prv[24], int nbr)
|
|||
BKE_previewimg_free(&prv[i]);
|
||||
}
|
||||
|
||||
tex = DRW_texture_create_2D_array(w, h, nbr, DRW_TEX_RGBA_8, DRW_TEX_FILTER, final_rect);
|
||||
tex = DRW_texture_create_2D_array(w, h, nbr, GPU_RGBA8, DRW_TEX_FILTER, final_rect);
|
||||
MEM_freeN(final_rect);
|
||||
|
||||
return tex;
|
||||
|
@ -343,7 +343,7 @@ static struct GPUTexture *create_jitter_texture(int num_samples)
|
|||
|
||||
UNUSED_VARS(bsdf_split_sum_ggx, btdf_split_sum_ggx, ltc_mag_ggx, ltc_mat_ggx, ltc_disk_integral);
|
||||
|
||||
return DRW_texture_create_2D(64, 64, DRW_TEX_RGB_16, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
|
||||
return DRW_texture_create_2D(64, 64, GPU_RGB16F, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]);
|
||||
}
|
||||
|
||||
static void clay_engine_init(void *vedata)
|
||||
|
@ -460,8 +460,8 @@ static void clay_engine_init(void *vedata)
|
|||
const float *viewport_size = DRW_viewport_size_get();
|
||||
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
|
||||
|
||||
g_data->normal_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RG_8, &draw_engine_clay_type);
|
||||
g_data->id_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_R_16I, &draw_engine_clay_type);
|
||||
g_data->normal_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RG8, &draw_engine_clay_type);
|
||||
g_data->id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16UI, &draw_engine_clay_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->prepass_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
|
||||
|
@ -470,9 +470,9 @@ static void clay_engine_init(void *vedata)
|
|||
});
|
||||
|
||||
/* For FXAA */
|
||||
/* TODO(fclem): OPTI: we could merge normal_tx and id_tx into a DRW_TEX_RGBA_8
|
||||
/* TODO(fclem): OPTI: we could merge normal_tx and id_tx into a GPU_RGBA8
|
||||
* and reuse it for the fxaa target. */
|
||||
g_data->color_copy = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8, &draw_engine_clay_type);
|
||||
g_data->color_copy = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_clay_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->antialias_fb, {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
|
|
@ -111,7 +111,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
|
|||
effects->blit_texel_size[0] = 1.0f / (float)blitsize[0];
|
||||
effects->blit_texel_size[1] = 1.0f / (float)blitsize[1];
|
||||
|
||||
effects->bloom_blit = DRW_texture_pool_query_2D(blitsize[0], blitsize[1], DRW_TEX_RGB_11_11_10,
|
||||
effects->bloom_blit = DRW_texture_pool_query_2D(blitsize[0], blitsize[1], GPU_R11F_G11F_B10F,
|
||||
&draw_engine_eevee_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->bloom_blit_fb, {
|
||||
|
@ -153,7 +153,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
|
|||
effects->downsamp_texel_size[i][0] = 1.0f / (float)texsize[0];
|
||||
effects->downsamp_texel_size[i][1] = 1.0f / (float)texsize[1];
|
||||
|
||||
effects->bloom_downsample[i] = DRW_texture_pool_query_2D(texsize[0], texsize[1], DRW_TEX_RGB_11_11_10,
|
||||
effects->bloom_downsample[i] = DRW_texture_pool_query_2D(texsize[0], texsize[1], GPU_R11F_G11F_B10F,
|
||||
&draw_engine_eevee_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->bloom_down_fb[i], {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
@ -169,7 +169,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
|
|||
texsize[0] = MAX2(texsize[0], 2);
|
||||
texsize[1] = MAX2(texsize[1], 2);
|
||||
|
||||
effects->bloom_upsample[i] = DRW_texture_pool_query_2D(texsize[0], texsize[1], DRW_TEX_RGB_11_11_10,
|
||||
effects->bloom_upsample[i] = DRW_texture_pool_query_2D(texsize[0], texsize[1], GPU_R11F_G11F_B10F,
|
||||
&draw_engine_eevee_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->bloom_accum_fb[i], {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
|
|
@ -103,11 +103,11 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
|
|||
|
||||
int buffer_size[2] = {(int)viewport_size[0] / 2, (int)viewport_size[1] / 2};
|
||||
|
||||
effects->dof_down_near = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], DRW_TEX_RGB_11_11_10,
|
||||
effects->dof_down_near = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], GPU_R11F_G11F_B10F,
|
||||
&draw_engine_eevee_type);
|
||||
effects->dof_down_far = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], DRW_TEX_RGB_11_11_10,
|
||||
effects->dof_down_far = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], GPU_R11F_G11F_B10F,
|
||||
&draw_engine_eevee_type);
|
||||
effects->dof_coc = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], DRW_TEX_RG_16,
|
||||
effects->dof_coc = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], GPU_RG16F,
|
||||
&draw_engine_eevee_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->dof_down_fb, {
|
||||
|
@ -118,7 +118,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
|
|||
});
|
||||
|
||||
/* Go full 32bits for rendering and reduce the color artifacts. */
|
||||
DRWTextureFormat fb_format = DRW_state_is_image_render() ? DRW_TEX_RGBA_32 : DRW_TEX_RGBA_16;
|
||||
GPUTextureFormat fb_format = DRW_state_is_image_render() ? GPU_RGBA32F : GPU_RGBA16F;
|
||||
|
||||
effects->dof_far_blur = DRW_texture_pool_query_2D(buffer_size[0], buffer_size[1], fb_format,
|
||||
&draw_engine_eevee_type);
|
||||
|
|
|
@ -166,7 +166,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
|
|||
* Ping Pong buffer
|
||||
*/
|
||||
if ((effects->enabled_effects & EFFECT_POST_BUFFER) != 0) {
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color_post, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color_post, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->effect_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
|
||||
|
@ -193,10 +193,10 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
|
|||
|
||||
if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
|
||||
/* Intel gpu seems to have problem rendering to only depth format */
|
||||
DRW_texture_ensure_2D(&txl->maxzbuffer, size[0], size[1], DRW_TEX_R_32, DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_2D(&txl->maxzbuffer, size[0], size[1], GPU_R32F, DRW_TEX_MIPMAP);
|
||||
}
|
||||
else {
|
||||
DRW_texture_ensure_2D(&txl->maxzbuffer, size[0], size[1], DRW_TEX_DEPTH_24, DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_2D(&txl->maxzbuffer, size[0], size[1], GPU_DEPTH_COMPONENT24, DRW_TEX_MIPMAP);
|
||||
}
|
||||
|
||||
if (fbl->downsample_fb == NULL) {
|
||||
|
@ -221,7 +221,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
|
|||
* Normal buffer for deferred passes.
|
||||
*/
|
||||
if ((effects->enabled_effects & EFFECT_NORMAL_BUFFER) != 0) {
|
||||
effects->ssr_normal_input = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], DRW_TEX_RG_16,
|
||||
effects->ssr_normal_input = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], GPU_RG16F,
|
||||
&draw_engine_eevee_type);
|
||||
|
||||
GPU_framebuffer_texture_attach(fbl->main_fb, effects->ssr_normal_input, 1, 0);
|
||||
|
@ -235,7 +235,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
|
|||
*/
|
||||
if ((effects->enabled_effects & EFFECT_VELOCITY_BUFFER) != 0) {
|
||||
/* TODO use RG16_UNORM */
|
||||
effects->velocity_tx = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], DRW_TEX_RG_32,
|
||||
effects->velocity_tx = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], GPU_RG32F,
|
||||
&draw_engine_eevee_type);
|
||||
|
||||
/* TODO output objects velocity during the mainpass. */
|
||||
|
@ -254,7 +254,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
|
|||
* Setup depth double buffer.
|
||||
*/
|
||||
if ((effects->enabled_effects & EFFECT_DEPTH_DOUBLE_BUFFER) != 0) {
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->depth_double_buffer, DRW_TEX_DEPTH_24_STENCIL_8, 0);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->depth_double_buffer, GPU_DEPTH24_STENCIL8, 0);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->double_buffer_depth_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(txl->depth_double_buffer)
|
||||
|
@ -270,7 +270,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object
|
|||
* Setup double buffer so we can access last frame as it was before post processes.
|
||||
*/
|
||||
if ((effects->enabled_effects & EFFECT_DOUBLE_BUFFER) != 0) {
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color_double_buffer, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color_double_buffer, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->double_buffer_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
|
||||
|
|
|
@ -70,7 +70,7 @@ static void eevee_engine_init(void *ved)
|
|||
stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL);
|
||||
|
||||
/* Main Buffer */
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->main_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
|
||||
|
|
|
@ -146,7 +146,7 @@ static struct GPUTexture *create_hammersley_sample_texture(int samples)
|
|||
texels[i][1] = sinf(phi);
|
||||
}
|
||||
|
||||
tex = DRW_texture_create_1D(samples, DRW_TEX_RG_16, DRW_TEX_WRAP, (float *)texels);
|
||||
tex = DRW_texture_create_1D(samples, GPU_RG16F, DRW_TEX_WRAP, (float *)texels);
|
||||
MEM_freeN(texels);
|
||||
return tex;
|
||||
}
|
||||
|
@ -172,14 +172,14 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
|
|||
if (!txl->planar_pool) {
|
||||
if (num_planar_ref > 0) {
|
||||
txl->planar_pool = DRW_texture_create_2D_array(width, height, max_ff(1, num_planar_ref),
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
txl->planar_depth = DRW_texture_create_2D_array(width, height, max_ff(1, num_planar_ref),
|
||||
DRW_TEX_DEPTH_24, 0, NULL);
|
||||
GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
}
|
||||
else if (num_planar_ref == 0) {
|
||||
/* Makes Opengl Happy : Create a placeholder texture that will never be sampled but still bound to shader. */
|
||||
txl->planar_pool = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_RGBA_8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
txl->planar_depth = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_DEPTH_24, 0, NULL);
|
||||
txl->planar_pool = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
txl->planar_depth = DRW_texture_create_2D_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,8 +356,8 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(veda
|
|||
|
||||
/* Setup Render Target Cubemap */
|
||||
if (!sldata->probe_rt) {
|
||||
sldata->probe_depth_rt = DRW_texture_create_cube(sldata->probes->target_size, DRW_TEX_DEPTH_24, 0, NULL);
|
||||
sldata->probe_rt = DRW_texture_create_cube(sldata->probes->target_size, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
sldata->probe_depth_rt = DRW_texture_create_cube(sldata->probes->target_size, GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
sldata->probe_rt = DRW_texture_create_cube(sldata->probes->target_size, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
|
@ -369,14 +369,14 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(veda
|
|||
|
||||
/* Placeholder planar pool: used when rendering planar reflections (avoid dependency loop). */
|
||||
if (!e_data.planar_pool_placeholder) {
|
||||
e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_RGBA_8, DRW_TEX_FILTER, NULL);
|
||||
e_data.planar_pool_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_RGBA8, DRW_TEX_FILTER, NULL);
|
||||
}
|
||||
|
||||
if (!e_data.depth_placeholder) {
|
||||
e_data.depth_placeholder = DRW_texture_create_2D(1, 1, DRW_TEX_DEPTH_24, 0, NULL);
|
||||
e_data.depth_placeholder = DRW_texture_create_2D(1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
}
|
||||
if (!e_data.depth_array_placeholder) {
|
||||
e_data.depth_array_placeholder = DRW_texture_create_2D_array(1, 1, 1, DRW_TEX_DEPTH_24, 0, NULL);
|
||||
e_data.depth_array_placeholder = DRW_texture_create_2D_array(1, 1, 1, GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -971,7 +971,7 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
|
|||
|
||||
if (!sldata->probe_pool) {
|
||||
sldata->probe_pool = DRW_texture_create_2D_array(pinfo->cubemap_res, pinfo->cubemap_res, max_ff(1, pinfo->num_cube),
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
|
||||
if (sldata->probe_filter_fb) {
|
||||
GPU_framebuffer_texture_attach(sldata->probe_filter_fb, sldata->probe_pool, 0, 0);
|
||||
}
|
||||
|
@ -991,9 +991,9 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
|
|||
|
||||
#ifdef IRRADIANCE_SH_L2
|
||||
/* we need a signed format for Spherical Harmonics */
|
||||
int irradiance_format = DRW_TEX_RGBA_16;
|
||||
int irradiance_format = GPU_RGBA16F;
|
||||
#else
|
||||
int irradiance_format = DRW_TEX_RGBA_8;
|
||||
int irradiance_format = GPU_RGBA8;
|
||||
#endif
|
||||
|
||||
if (!sldata->irradiance_pool || !sldata->irradiance_rt) {
|
||||
|
|
|
@ -472,7 +472,7 @@ void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, Object
|
|||
void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata)
|
||||
{
|
||||
EEVEE_LampsInfo *linfo = sldata->lamps;
|
||||
DRWTextureFormat shadow_pool_format = DRW_TEX_R_32;
|
||||
GPUTextureFormat shadow_pool_format = GPU_R32F;
|
||||
|
||||
sldata->common_data.la_num_light = linfo->num_light;
|
||||
|
||||
|
@ -485,8 +485,8 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata)
|
|||
}
|
||||
|
||||
switch (linfo->shadow_method) {
|
||||
case SHADOW_ESM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? DRW_TEX_R_32 : DRW_TEX_R_16); break;
|
||||
case SHADOW_VSM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? DRW_TEX_RG_32 : DRW_TEX_RG_16); break;
|
||||
case SHADOW_ESM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? GPU_R32F : GPU_R16F); break;
|
||||
case SHADOW_VSM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? GPU_RG32F : GPU_RG16F); break;
|
||||
default:
|
||||
BLI_assert(!"Incorrect Shadow Method");
|
||||
break;
|
||||
|
@ -496,7 +496,7 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata)
|
|||
/* TODO render everything on the same 2d render target using clip planes and no Geom Shader. */
|
||||
/* Cubemaps */
|
||||
sldata->shadow_cube_target = DRW_texture_create_cube(
|
||||
linfo->shadow_cube_target_size, DRW_TEX_DEPTH_24, 0, NULL);
|
||||
linfo->shadow_cube_target_size, GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
sldata->shadow_cube_blur = DRW_texture_create_cube(
|
||||
linfo->shadow_cube_target_size, shadow_pool_format, DRW_TEX_FILTER, NULL);
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata)
|
|||
if (!sldata->shadow_cascade_target) {
|
||||
/* CSM */
|
||||
sldata->shadow_cascade_target = DRW_texture_create_2D_array(
|
||||
linfo->shadow_size, linfo->shadow_size, MAX_CASCADE_NUM, DRW_TEX_DEPTH_24, 0, NULL);
|
||||
linfo->shadow_size, linfo->shadow_size, MAX_CASCADE_NUM, GPU_DEPTH_COMPONENT24, 0, NULL);
|
||||
sldata->shadow_cascade_blur = DRW_texture_create_2D_array(
|
||||
linfo->shadow_size, linfo->shadow_size, MAX_CASCADE_NUM, shadow_pool_format, DRW_TEX_FILTER, NULL);
|
||||
}
|
||||
|
|
|
@ -133,9 +133,9 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
|
|||
|
||||
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
|
||||
|
||||
tex = DRW_texture_create_2D(w, h, DRW_TEX_RG_16, DRW_TEX_FILTER, (float *)texels);
|
||||
tex = DRW_texture_create_2D(w, h, GPU_RG16F, DRW_TEX_FILTER, (float *)texels);
|
||||
|
||||
DRWFboTexture tex_filter = {&tex, DRW_TEX_RG_16, DRW_TEX_FILTER};
|
||||
DRWFboTexture tex_filter = {&tex, GPU_RG16F, DRW_TEX_FILTER};
|
||||
GPU_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
|
||||
|
||||
GPU_framebuffer_bind(fb);
|
||||
|
@ -195,9 +195,9 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h)
|
|||
|
||||
float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut");
|
||||
|
||||
tex = DRW_texture_create_2D(w, h, DRW_TEX_R_16, DRW_TEX_FILTER, (float *)texels);
|
||||
tex = DRW_texture_create_2D(w, h, GPU_R16F, DRW_TEX_FILTER, (float *)texels);
|
||||
|
||||
DRWFboTexture tex_filter = {&tex, DRW_TEX_R_16, DRW_TEX_FILTER};
|
||||
DRWFboTexture tex_filter = {&tex, GPU_R16F, DRW_TEX_FILTER};
|
||||
GPU_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
|
||||
|
||||
GPU_framebuffer_bind(fb);
|
||||
|
@ -423,7 +423,7 @@ static void create_default_shader(int options)
|
|||
|
||||
static void eevee_init_noise_texture(void)
|
||||
{
|
||||
e_data.noise_tex = DRW_texture_create_2D(64, 64, DRW_TEX_RGBA_16, 0, (float *)blue_noise);
|
||||
e_data.noise_tex = DRW_texture_create_2D(64, 64, GPU_RGBA16F, 0, (float *)blue_noise);
|
||||
}
|
||||
|
||||
static void eevee_init_util_texture(void)
|
||||
|
@ -467,7 +467,7 @@ static void eevee_init_util_texture(void)
|
|||
}
|
||||
|
||||
e_data.util_tex = DRW_texture_create_2D_array(
|
||||
64, 64, layers, DRW_TEX_RGBA_16, DRW_TEX_FILTER | DRW_TEX_WRAP, (float *)texels);
|
||||
64, 64, layers, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_WRAP, (float *)texels);
|
||||
|
||||
MEM_freeN(texels);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
}
|
||||
|
||||
/* Create FrameBuffer. */
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->mist_accum, DRW_TEX_R_32, 0); /* Should be enough precision for many samples. */
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->mist_accum, GPU_R32F, 0); /* Should be enough precision for many samples. */
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->mist_accum_fb, {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
|
|
@ -101,7 +101,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
|
||||
common_data->ao_bounce_fac = (float)BKE_collection_engine_property_value_get_bool(props, "gtao_bounce");
|
||||
|
||||
effects->gtao_horizons = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], DRW_TEX_RGBA_8,
|
||||
effects->gtao_horizons = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA8,
|
||||
&draw_engine_eevee_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->gtao_fb, {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
@ -109,7 +109,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
});
|
||||
|
||||
if (G.debug_value == 6) {
|
||||
effects->gtao_horizons_debug = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], DRW_TEX_RGBA_8,
|
||||
effects->gtao_horizons_debug = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA8,
|
||||
&draw_engine_eevee_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->gtao_debug_fb, {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
@ -147,7 +147,7 @@ void EEVEE_occlusion_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata
|
|||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->ao_accum, DRW_TEX_R_32, 0); /* Should be enough precision for many samples. */
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->ao_accum, GPU_R32F, 0); /* Should be enough precision for many samples. */
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->ao_accum_fb, {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
|
|
@ -62,8 +62,8 @@ void EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph *
|
|||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
/* TODO 32 bit depth */
|
||||
DRW_texture_ensure_fullscreen_2D(&dtxl->depth, DRW_TEX_DEPTH_24_STENCIL_8, 0);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color, DRW_TEX_RGBA_32, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_fullscreen_2D(&dtxl->depth, GPU_DEPTH24_STENCIL8, 0);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->color, GPU_RGBA32F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
|
||||
GPU_framebuffer_ensure_config(&dfbl->default_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(dtxl->depth),
|
||||
|
|
|
@ -125,7 +125,7 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
|
||||
if (use_refraction) {
|
||||
/* TODO: Opti: Could be shared. */
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->refract_color, DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->refract_color, GPU_R11F_G11F_B10F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->refract_fb, {
|
||||
GPU_ATTACHMENT_NONE,
|
||||
|
@ -149,7 +149,7 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
int tracing_res[2] = {(int)viewport_size[0] / divisor, (int)viewport_size[1] / divisor};
|
||||
int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]};
|
||||
const bool high_qual_input = true; /* TODO dither low quality input */
|
||||
const DRWTextureFormat format = (high_qual_input) ? DRW_TEX_RGBA_16 : DRW_TEX_RGBA_8;
|
||||
const GPUTextureFormat format = (high_qual_input) ? GPU_RGBA16F : GPU_RGBA8;
|
||||
|
||||
/* MRT for the shading pass in order to output needed data for the SSR pass. */
|
||||
effects->ssr_specrough_input = DRW_texture_pool_query_2D(size_fs[0], size_fs[1], format,
|
||||
|
@ -158,9 +158,9 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
GPU_framebuffer_texture_attach(fbl->main_fb, effects->ssr_specrough_input, 2, 0);
|
||||
|
||||
/* Raytracing output */
|
||||
effects->ssr_hit_output = DRW_texture_pool_query_2D(tracing_res[0], tracing_res[1], DRW_TEX_RG_16I,
|
||||
effects->ssr_hit_output = DRW_texture_pool_query_2D(tracing_res[0], tracing_res[1], GPU_RG16I,
|
||||
&draw_engine_eevee_type);
|
||||
effects->ssr_pdf_output = DRW_texture_pool_query_2D(tracing_res[0], tracing_res[1], DRW_TEX_R_16,
|
||||
effects->ssr_pdf_output = DRW_texture_pool_query_2D(tracing_res[0], tracing_res[1], GPU_R16F,
|
||||
&draw_engine_eevee_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->screen_tracing_fb, {
|
||||
|
|
|
@ -91,11 +91,11 @@ int EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
* as the depth buffer we are sampling from. This could be avoided if the stencil is
|
||||
* a separate texture but that needs OpenGL 4.4 or ARB_texture_stencil8.
|
||||
* OR OpenGL 4.3 / ARB_ES3_compatibility if using a renderbuffer instead */
|
||||
effects->sss_stencil = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], DRW_TEX_DEPTH_24_STENCIL_8,
|
||||
effects->sss_stencil = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_DEPTH24_STENCIL8,
|
||||
&draw_engine_eevee_type);
|
||||
effects->sss_blur = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], DRW_TEX_RGBA_16,
|
||||
effects->sss_blur = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA16F,
|
||||
&draw_engine_eevee_type);
|
||||
effects->sss_data = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], DRW_TEX_RGBA_16,
|
||||
effects->sss_data = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_RGBA16F,
|
||||
&draw_engine_eevee_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->sss_blur_fb, {
|
||||
|
@ -114,7 +114,7 @@ int EEVEE_subsurface_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
});
|
||||
|
||||
if (effects->sss_separate_albedo) {
|
||||
effects->sss_albedo = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], DRW_TEX_RGB_11_11_10,
|
||||
effects->sss_albedo = DRW_texture_pool_query_2D(fs_size[0], fs_size[1], GPU_R11F_G11F_B10F,
|
||||
&draw_engine_eevee_type);
|
||||
}
|
||||
else {
|
||||
|
@ -151,8 +151,8 @@ void EEVEE_subsurface_output_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
|
|||
IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE);
|
||||
|
||||
if (BKE_collection_engine_property_value_get_bool(props, "sss_enable")) {
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->sss_dir_accum, DRW_TEX_RGBA_16, 0);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->sss_col_accum, DRW_TEX_RGBA_16, 0);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->sss_dir_accum, GPU_RGBA16F, 0);
|
||||
DRW_texture_ensure_fullscreen_2D(&txl->sss_col_accum, GPU_RGBA16F, 0);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->sss_accum_fb, {
|
||||
GPU_ATTACHMENT_TEXTURE(effects->sss_stencil),
|
||||
|
|
|
@ -214,30 +214,30 @@ int EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
/* Volume properties: We evaluate all volumetric objects
|
||||
* and store their final properties into each froxel */
|
||||
txl->volume_prop_scattering = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
txl->volume_prop_extinction = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
txl->volume_prop_emission = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
txl->volume_prop_phase = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RG_16, DRW_TEX_FILTER, NULL);
|
||||
GPU_RG16F, DRW_TEX_FILTER, NULL);
|
||||
|
||||
/* Volume scattering: We compute for each froxel the
|
||||
* Scattered light towards the view. We also resolve temporal
|
||||
* super sampling during this stage. */
|
||||
txl->volume_scatter = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
txl->volume_transmittance = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
|
||||
/* Final integration: We compute for each froxel the
|
||||
* amount of scattered light and extinction coef at this
|
||||
* given depth. We use theses textures as double buffer
|
||||
* for the volumetric history. */
|
||||
txl->volume_scatter_history = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
txl->volume_transmittance_history = DRW_texture_create_3D(tex_size[0], tex_size[1], tex_size[2],
|
||||
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER, NULL);
|
||||
GPU_R11F_G11F_B10F, DRW_TEX_FILTER, NULL);
|
||||
}
|
||||
|
||||
/* Temporal Super sampling jitter */
|
||||
|
|
|
@ -209,12 +209,12 @@ void workbench_materials_engine_init(WORKBENCH_Data *vedata)
|
|||
{
|
||||
const float *viewport_size = DRW_viewport_size_get();
|
||||
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
|
||||
e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_R_32U, &draw_engine_workbench_solid);
|
||||
e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8, &draw_engine_workbench_solid);
|
||||
e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R32UI, &draw_engine_workbench_solid);
|
||||
e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
|
||||
#ifdef WORKBENCH_ENCODE_NORMALS
|
||||
e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RG_8, &draw_engine_workbench_solid);
|
||||
e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RG8, &draw_engine_workbench_solid);
|
||||
#else
|
||||
e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_32, &draw_engine_workbench_solid);
|
||||
e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA32F, &draw_engine_workbench_solid);
|
||||
#endif
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->prepass_fb, {
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "GPU_framebuffer.h"
|
||||
#include "GPU_texture.h"
|
||||
|
||||
#include "draw_common.h"
|
||||
#include "draw_cache.h"
|
||||
|
@ -169,33 +170,6 @@ typedef struct DefaultTextureList {
|
|||
#endif
|
||||
|
||||
/* Textures */
|
||||
/* NOTE naming in this struct is broken.
|
||||
* There should either be suffixes for Normalized int formats or float formats.
|
||||
* Right now every 8bit texture is Normalized int and others are Floating point. */
|
||||
typedef enum {
|
||||
DRW_TEX_RGBA_8,
|
||||
DRW_TEX_RGBA_16,
|
||||
DRW_TEX_RGBA_32,
|
||||
DRW_TEX_RGB_11_11_10,
|
||||
DRW_TEX_RGB_8,
|
||||
DRW_TEX_RGB_16,
|
||||
DRW_TEX_RGB_32,
|
||||
DRW_TEX_RG_8,
|
||||
DRW_TEX_RG_16,
|
||||
DRW_TEX_RG_16I,
|
||||
DRW_TEX_RG_32,
|
||||
DRW_TEX_R_8,
|
||||
DRW_TEX_R_16,
|
||||
DRW_TEX_R_16I,
|
||||
DRW_TEX_R_16U,
|
||||
DRW_TEX_R_32,
|
||||
DRW_TEX_R_32U,
|
||||
DRW_TEX_DEPTH_16,
|
||||
DRW_TEX_DEPTH_24,
|
||||
DRW_TEX_DEPTH_24_STENCIL_8,
|
||||
DRW_TEX_DEPTH_32,
|
||||
} DRWTextureFormat;
|
||||
|
||||
typedef enum {
|
||||
DRW_TEX_FILTER = (1 << 0),
|
||||
DRW_TEX_WRAP = (1 << 1),
|
||||
|
@ -206,23 +180,23 @@ typedef enum {
|
|||
/* Textures from DRW_texture_pool_query_* have the options
|
||||
* DRW_TEX_FILTER for color float textures, and no options
|
||||
* for depth textures and integer textures. */
|
||||
struct GPUTexture *DRW_texture_pool_query_2D(int w, int h, DRWTextureFormat format, DrawEngineType *engine_type);
|
||||
struct GPUTexture *DRW_texture_pool_query_2D(int w, int h, GPUTextureFormat format, DrawEngineType *engine_type);
|
||||
|
||||
struct GPUTexture *DRW_texture_create_1D(
|
||||
int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
int w, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
struct GPUTexture *DRW_texture_create_2D(
|
||||
int w, int h, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
int w, int h, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
struct GPUTexture *DRW_texture_create_2D_array(
|
||||
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
int w, int h, int d, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
struct GPUTexture *DRW_texture_create_3D(
|
||||
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
int w, int h, int d, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
struct GPUTexture *DRW_texture_create_cube(
|
||||
int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
int w, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels);
|
||||
|
||||
void DRW_texture_ensure_fullscreen_2D(
|
||||
struct GPUTexture **tex, DRWTextureFormat format, DRWTextureFlag flags);
|
||||
struct GPUTexture **tex, GPUTextureFormat format, DRWTextureFlag flags);
|
||||
void DRW_texture_ensure_2D(
|
||||
struct GPUTexture **tex, int w, int h, DRWTextureFormat format, DRWTextureFlag flags);
|
||||
struct GPUTexture **tex, int w, int h, GPUTextureFormat format, DRWTextureFlag flags);
|
||||
|
||||
void DRW_texture_generate_mipmaps(struct GPUTexture *tex);
|
||||
void DRW_texture_free(struct GPUTexture *tex);
|
||||
|
|
|
@ -149,7 +149,7 @@ void DRW_globals_update(void)
|
|||
if (globals_ramp) {
|
||||
GPU_texture_free(globals_ramp);
|
||||
}
|
||||
globals_ramp = GPU_texture_create_1D(col_size, colors, NULL);
|
||||
globals_ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL);
|
||||
|
||||
MEM_freeN(colors);
|
||||
}
|
||||
|
|
|
@ -1447,7 +1447,7 @@ static void draw_select_framebuffer_setup(const rcti *rect)
|
|||
}
|
||||
|
||||
if (g_select_buffer.texture_depth == NULL) {
|
||||
g_select_buffer.texture_depth = GPU_texture_create_depth(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), NULL);
|
||||
g_select_buffer.texture_depth = GPU_texture_create_2D(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), GPU_DEPTH_COMPONENT24, NULL, NULL);
|
||||
|
||||
GPU_framebuffer_texture_attach(g_select_buffer.framebuffer, g_select_buffer.texture_depth, 0, 0);
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ extern DRWManager DST; /* TODO : get rid of this and allow multithreaded renderi
|
|||
|
||||
void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags);
|
||||
void drw_texture_get_format(
|
||||
DRWTextureFormat format, bool is_framebuffer,
|
||||
GPUTextureFormat format, bool is_framebuffer,
|
||||
GPUTextureFormat *r_data_type, int *r_channels, bool *r_is_depth);
|
||||
|
||||
void *drw_viewport_engine_data_ensure(void *engine_type);
|
||||
|
|
|
@ -25,97 +25,33 @@
|
|||
|
||||
#include "draw_manager.h"
|
||||
|
||||
void drw_texture_get_format(
|
||||
DRWTextureFormat format, bool is_framebuffer,
|
||||
GPUTextureFormat *r_data_type, int *r_channels, bool *r_is_depth)
|
||||
/* Maybe gpu_texture.c is a better place for this. */
|
||||
static bool drw_texture_format_supports_framebuffer(GPUTextureFormat format)
|
||||
{
|
||||
/* Some formats do not work with framebuffers. */
|
||||
if (is_framebuffer) {
|
||||
switch (format) {
|
||||
/* Only add formats that are COMPATIBLE with FB.
|
||||
* Generally they are multiple of 16bit. */
|
||||
case DRW_TEX_R_16:
|
||||
case DRW_TEX_R_16I:
|
||||
case DRW_TEX_R_16U:
|
||||
case DRW_TEX_R_32:
|
||||
case DRW_TEX_R_32U:
|
||||
case DRW_TEX_RG_8:
|
||||
case DRW_TEX_RG_16:
|
||||
case DRW_TEX_RG_16I:
|
||||
case DRW_TEX_RG_32:
|
||||
case DRW_TEX_RGBA_8:
|
||||
case DRW_TEX_RGBA_16:
|
||||
case DRW_TEX_RGBA_32:
|
||||
case DRW_TEX_DEPTH_16:
|
||||
case DRW_TEX_DEPTH_24:
|
||||
case DRW_TEX_DEPTH_24_STENCIL_8:
|
||||
case DRW_TEX_DEPTH_32:
|
||||
case DRW_TEX_RGB_11_11_10:
|
||||
break;
|
||||
default:
|
||||
BLI_assert(false && "Texture format unsupported as render target!");
|
||||
*r_channels = 4;
|
||||
*r_data_type = GPU_RGBA8;
|
||||
*r_is_depth = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case DRW_TEX_RGBA_8: *r_data_type = GPU_RGBA8; break;
|
||||
case DRW_TEX_RGBA_16: *r_data_type = GPU_RGBA16F; break;
|
||||
case DRW_TEX_RGBA_32: *r_data_type = GPU_RGBA32F; break;
|
||||
case DRW_TEX_RGB_16: *r_data_type = GPU_RGB16F; break;
|
||||
case DRW_TEX_RGB_11_11_10: *r_data_type = GPU_R11F_G11F_B10F; break;
|
||||
case DRW_TEX_RG_8: *r_data_type = GPU_RG8; break;
|
||||
case DRW_TEX_RG_16: *r_data_type = GPU_RG16F; break;
|
||||
case DRW_TEX_RG_16I: *r_data_type = GPU_RG16I; break;
|
||||
case DRW_TEX_RG_32: *r_data_type = GPU_RG32F; break;
|
||||
case DRW_TEX_R_8: *r_data_type = GPU_R8; break;
|
||||
case DRW_TEX_R_16: *r_data_type = GPU_R16F; break;
|
||||
case DRW_TEX_R_16I: *r_data_type = GPU_R16I; break;
|
||||
case DRW_TEX_R_16U: *r_data_type = GPU_R16UI; break;
|
||||
case DRW_TEX_R_32: *r_data_type = GPU_R32F; break;
|
||||
case DRW_TEX_R_32U: *r_data_type = GPU_R32UI; break;
|
||||
#if 0
|
||||
case DRW_TEX_RGB_8: *r_data_type = GPU_RGB8; break;
|
||||
case DRW_TEX_RGB_32: *r_data_type = GPU_RGB32F; break;
|
||||
#endif
|
||||
case DRW_TEX_DEPTH_16: *r_data_type = GPU_DEPTH_COMPONENT16; break;
|
||||
case DRW_TEX_DEPTH_24: *r_data_type = GPU_DEPTH_COMPONENT24; break;
|
||||
case DRW_TEX_DEPTH_24_STENCIL_8: *r_data_type = GPU_DEPTH24_STENCIL8; break;
|
||||
case DRW_TEX_DEPTH_32: *r_data_type = GPU_DEPTH_COMPONENT32F; break;
|
||||
default :
|
||||
/* file type not supported you must uncomment it from above */
|
||||
BLI_assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case DRW_TEX_RGBA_8:
|
||||
case DRW_TEX_RGBA_16:
|
||||
case DRW_TEX_RGBA_32:
|
||||
*r_channels = 4;
|
||||
break;
|
||||
case DRW_TEX_RGB_8:
|
||||
case DRW_TEX_RGB_16:
|
||||
case DRW_TEX_RGB_32:
|
||||
case DRW_TEX_RGB_11_11_10:
|
||||
*r_channels = 3;
|
||||
break;
|
||||
case DRW_TEX_RG_8:
|
||||
case DRW_TEX_RG_16:
|
||||
case DRW_TEX_RG_16I:
|
||||
case DRW_TEX_RG_32:
|
||||
*r_channels = 2;
|
||||
break;
|
||||
/* Only add formats that are COMPATIBLE with FB.
|
||||
* Generally they are multiple of 16bit. */
|
||||
case GPU_R16F:
|
||||
case GPU_R16I:
|
||||
case GPU_R16UI:
|
||||
case GPU_R32F:
|
||||
case GPU_R32UI:
|
||||
case GPU_RG8:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG32F:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return true;
|
||||
default:
|
||||
*r_channels = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (r_is_depth) {
|
||||
*r_is_depth = ELEM(format, DRW_TEX_DEPTH_16, DRW_TEX_DEPTH_24, DRW_TEX_DEPTH_24_STENCIL_8);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,86 +70,57 @@ void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
|
|||
GPU_texture_unbind(tex);
|
||||
}
|
||||
|
||||
GPUTexture *DRW_texture_create_1D(int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
GPUTexture *DRW_texture_create_1D(int w, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
GPUTextureFormat data_type;
|
||||
int channels;
|
||||
|
||||
drw_texture_get_format(format, false, &data_type, &channels, NULL);
|
||||
tex = GPU_texture_create_1D_custom(w, channels, data_type, fpixels, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_1D(w, format, fpixels, NULL);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *DRW_texture_create_2D(int w, int h, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
GPUTexture *DRW_texture_create_2D(int w, int h, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
GPUTextureFormat data_type;
|
||||
int channels;
|
||||
|
||||
drw_texture_get_format(format, false, &data_type, &channels, NULL);
|
||||
tex = GPU_texture_create_2D_custom(w, h, channels, data_type, fpixels, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_2D(w, h, format, fpixels, NULL);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *DRW_texture_create_2D_array(
|
||||
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
int w, int h, int d, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
GPUTextureFormat data_type;
|
||||
int channels;
|
||||
|
||||
drw_texture_get_format(format, false, &data_type, &channels, NULL);
|
||||
tex = GPU_texture_create_2D_array_custom(w, h, d, channels, data_type, fpixels, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_2D_array(w, h, d, format, fpixels, NULL);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *DRW_texture_create_3D(
|
||||
int w, int h, int d, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
int w, int h, int d, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
GPUTextureFormat data_type;
|
||||
int channels;
|
||||
|
||||
drw_texture_get_format(format, false, &data_type, &channels, NULL);
|
||||
tex = GPU_texture_create_3D_custom(w, h, d, channels, data_type, fpixels, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_3D(w, h, d, format, fpixels, NULL);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *DRW_texture_create_cube(int w, DRWTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
GPUTexture *DRW_texture_create_cube(int w, GPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
GPUTextureFormat data_type;
|
||||
int channels;
|
||||
|
||||
drw_texture_get_format(format, false, &data_type, &channels, NULL);
|
||||
tex = GPU_texture_create_cube_custom(w, channels, data_type, fpixels, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_cube(w, format, fpixels, NULL);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *DRW_texture_pool_query_2D(int w, int h, DRWTextureFormat format, DrawEngineType *engine_type)
|
||||
GPUTexture *DRW_texture_pool_query_2D(int w, int h, GPUTextureFormat format, DrawEngineType *engine_type)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
GPUTextureFormat data_type;
|
||||
int channels;
|
||||
|
||||
drw_texture_get_format(format, true, &data_type, &channels, NULL);
|
||||
tex = GPU_viewport_texture_pool_query(DST.viewport, engine_type, w, h, channels, data_type);
|
||||
BLI_assert(drw_texture_format_supports_framebuffer(format));
|
||||
GPUTexture *tex = GPU_viewport_texture_pool_query(DST.viewport, engine_type, w, h, format);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
void DRW_texture_ensure_fullscreen_2D(GPUTexture **tex, DRWTextureFormat format, DRWTextureFlag flags)
|
||||
void DRW_texture_ensure_fullscreen_2D(GPUTexture **tex, GPUTextureFormat format, DRWTextureFlag flags)
|
||||
{
|
||||
if (*(tex) == NULL) {
|
||||
const float *size = DRW_viewport_size_get();
|
||||
|
@ -221,7 +128,7 @@ void DRW_texture_ensure_fullscreen_2D(GPUTexture **tex, DRWTextureFormat format,
|
|||
}
|
||||
}
|
||||
|
||||
void DRW_texture_ensure_2D(GPUTexture **tex, int w, int h, DRWTextureFormat format, DRWTextureFlag flags)
|
||||
void DRW_texture_ensure_2D(GPUTexture **tex, int w, int h, GPUTextureFormat format, DRWTextureFlag flags)
|
||||
{
|
||||
if (*(tex) == NULL) {
|
||||
*(tex) = DRW_texture_create_2D(w, h, format, flags, NULL);
|
||||
|
|
|
@ -144,8 +144,8 @@ static void EDIT_CURVE_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -132,8 +132,8 @@ static void EDIT_LATTICE_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -141,9 +141,9 @@ static void EDIT_MESH_engine_init(void *vedata)
|
|||
const float *viewport_size = DRW_viewport_size_get();
|
||||
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
|
||||
|
||||
e_data.occlude_wire_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_DEPTH_24,
|
||||
e_data.occlude_wire_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24,
|
||||
&draw_engine_edit_mesh_type);
|
||||
e_data.occlude_wire_color_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8,
|
||||
e_data.occlude_wire_color_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8,
|
||||
&draw_engine_edit_mesh_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->occlude_wire_fb, {
|
||||
|
|
|
@ -117,8 +117,8 @@ static void EDIT_SURFACE_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -127,8 +127,8 @@ static void EDIT_TEXT_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -313,12 +313,12 @@ static void OBJECT_engine_init(void *vedata)
|
|||
const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
|
||||
|
||||
if (DRW_state_is_fbo()) {
|
||||
e_data.outlines_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_DEPTH_24,
|
||||
e_data.outlines_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_DEPTH_COMPONENT24,
|
||||
&draw_engine_object_type);
|
||||
/* XXX TODO DRW_TEX_R_16U can overflow, it would cause no harm
|
||||
/* XXX TODO GPU_R16UI can overflow, it would cause no harm
|
||||
* (only bad colored or missing outlines) but we should
|
||||
* use 32bits only if the scene have that many objects */
|
||||
e_data.outlines_id_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_R_16U,
|
||||
e_data.outlines_id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R16UI,
|
||||
&draw_engine_object_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->outlines_fb, {
|
||||
|
@ -326,7 +326,7 @@ static void OBJECT_engine_init(void *vedata)
|
|||
GPU_ATTACHMENT_TEXTURE(e_data.outlines_id_tx)
|
||||
});
|
||||
|
||||
e_data.outlines_color_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8,
|
||||
e_data.outlines_color_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8,
|
||||
&draw_engine_object_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->expand_fb, {
|
||||
|
@ -334,7 +334,7 @@ static void OBJECT_engine_init(void *vedata)
|
|||
GPU_ATTACHMENT_TEXTURE(e_data.outlines_color_tx)
|
||||
});
|
||||
|
||||
e_data.outlines_blur_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_RGBA_8,
|
||||
e_data.outlines_blur_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8,
|
||||
&draw_engine_object_type);
|
||||
|
||||
GPU_framebuffer_ensure_config(&fbl->blur_fb, {
|
||||
|
|
|
@ -140,8 +140,8 @@ static void PAINT_TEXTURE_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -111,8 +111,8 @@ static void PARTICLE_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -123,8 +123,8 @@ static void SCULPT_engine_init(void *vedata)
|
|||
|
||||
/* Init Framebuffers like this: order is attachment order (for color texs) */
|
||||
/*
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, DRW_TEX_DEPTH_24, 0},
|
||||
* {&txl->color, DRW_TEX_RGBA_8, DRW_TEX_FILTER}};
|
||||
* DRWFboTexture tex[2] = {{&txl->depth, GPU_DEPTH_COMPONENT24, 0},
|
||||
* {&txl->color, GPU_RGBA8, DRW_TEX_FILTER}};
|
||||
*/
|
||||
|
||||
/* DRW_framebuffer_init takes care of checking if
|
||||
|
|
|
@ -128,7 +128,7 @@ static GPUTexture *create_transfer_function(int type, const ColorBand *coba)
|
|||
break;
|
||||
}
|
||||
|
||||
GPUTexture *tex = GPU_texture_create_1D(TFUNC_WIDTH, data, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_1D(TFUNC_WIDTH, GPU_RGBA8, data, NULL);
|
||||
|
||||
MEM_freeN(data);
|
||||
|
||||
|
@ -159,7 +159,7 @@ static GPUTexture *create_field_texture(SmokeDomainSettings *sds)
|
|||
default: return NULL;
|
||||
}
|
||||
|
||||
return GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1, GPU_R8, field, NULL);
|
||||
return GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_R8, field, NULL);
|
||||
}
|
||||
|
||||
typedef struct VolumeSlicer {
|
||||
|
|
|
@ -145,26 +145,18 @@ typedef enum GPUTextureFormat {
|
|||
|
||||
unsigned int GPU_texture_memory_usage_get(void);
|
||||
|
||||
GPUTexture *GPU_texture_create_1D(int w, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_1D_custom(
|
||||
int w, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D_custom(
|
||||
int w, int h, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D_multisample(int w, int h, const float *pixels, int samples, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D_custom_multisample(
|
||||
int w, int h, int channels, GPUTextureFormat data_type, const float *pixels, int samples, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D_array_custom(
|
||||
int w, int h, int d, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_3D(int w, int h, int d, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_3D_custom(
|
||||
int w, int h, int d, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_cube_custom(
|
||||
int w, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_depth_with_stencil(int w, int h, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_depth_multisample(int w, int h, int samples, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_depth_with_stencil_multisample(int w, int h, int samples, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_1D(
|
||||
int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D(
|
||||
int w, int h, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D_multisample(
|
||||
int w, int h, GPUTextureFormat data_type, const float *pixels, int samples, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_2D_array(
|
||||
int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_3D(
|
||||
int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
GPUTexture *GPU_texture_create_cube(
|
||||
int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]);
|
||||
|
||||
GPUTexture *GPU_texture_from_blender(
|
||||
struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time, int mipmap);
|
||||
|
|
|
@ -122,7 +122,7 @@ bool GPU_viewport_do_update(GPUViewport *viewport);
|
|||
GPUTexture *GPU_viewport_color_texture(GPUViewport *viewport);
|
||||
|
||||
/* Texture pool */
|
||||
GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int channels, int format);
|
||||
GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int format);
|
||||
|
||||
bool GPU_viewport_engines_data_validate(GPUViewport *viewport, unsigned int hash);
|
||||
void GPU_viewport_cache_release(GPUViewport *viewport);
|
||||
|
|
|
@ -1272,7 +1272,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
|
|||
#if 0
|
||||
input->tex = GPU_texture_create_2D(link->texturesize, link->texturesize, link->ptr2, NULL);
|
||||
#endif
|
||||
input->tex = GPU_texture_create_2D(link->texturesize, 1, link->ptr1, NULL);
|
||||
input->tex = GPU_texture_create_2D(link->texturesize, 1, GPU_RGBA8, link->ptr1, NULL);
|
||||
input->textarget = GL_TEXTURE_2D;
|
||||
|
||||
MEM_freeN(link->ptr1);
|
||||
|
|
|
@ -914,12 +914,12 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
|
|||
if (smoke_has_colors(sds->fluid)) {
|
||||
float *data = MEM_callocN(sizeof(float) * sds->total_cells * 4, "smokeColorTexture");
|
||||
smoke_get_rgba(sds->fluid, data, 0);
|
||||
sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], data, NULL);
|
||||
sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_RGBA8, data, NULL);
|
||||
MEM_freeN(data);
|
||||
}
|
||||
/* density only */
|
||||
else {
|
||||
sds->tex = GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1,
|
||||
sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2],
|
||||
GPU_R8, smoke_get_density(sds->fluid), NULL);
|
||||
|
||||
/* Swizzle the RGBA components to read the Red channel so
|
||||
|
@ -933,7 +933,7 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
|
|||
GPU_texture_unbind(sds->tex);
|
||||
}
|
||||
sds->tex_flame = (smoke_has_fuel(sds->fluid)) ?
|
||||
GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1,
|
||||
GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2],
|
||||
GPU_R8, smoke_get_flame(sds->fluid), NULL) :
|
||||
NULL;
|
||||
}
|
||||
|
@ -942,12 +942,12 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
|
|||
if (smoke_turbulence_has_colors(sds->wt)) {
|
||||
float *data = MEM_callocN(sizeof(float) * smoke_turbulence_get_cells(sds->wt) * 4, "smokeColorTexture");
|
||||
smoke_turbulence_get_rgba(sds->wt, data, 0);
|
||||
sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], data, NULL);
|
||||
sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], GPU_RGBA8, data, NULL);
|
||||
MEM_freeN(data);
|
||||
}
|
||||
/* density only */
|
||||
else {
|
||||
sds->tex = GPU_texture_create_3D_custom(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1,
|
||||
sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
|
||||
GPU_R8, smoke_turbulence_get_density(sds->wt), NULL);
|
||||
|
||||
/* Swizzle the RGBA components to read the Red channel so
|
||||
|
@ -961,12 +961,12 @@ void GPU_create_smoke(SmokeModifierData *smd, int highres)
|
|||
GPU_texture_unbind(sds->tex);
|
||||
}
|
||||
sds->tex_flame = (smoke_turbulence_has_fuel(sds->wt)) ?
|
||||
GPU_texture_create_3D_custom(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], 1,
|
||||
GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
|
||||
GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) :
|
||||
NULL;
|
||||
}
|
||||
|
||||
sds->tex_shadow = GPU_texture_create_3D_custom(sds->res[0], sds->res[1], sds->res[2], 1,
|
||||
sds->tex_shadow = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2],
|
||||
GPU_R8, sds->shadow, NULL);
|
||||
}
|
||||
#else // WITH_SMOKE
|
||||
|
|
|
@ -657,11 +657,11 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
|
|||
|
||||
ofs = MEM_callocN(sizeof(GPUOffScreen), "GPUOffScreen");
|
||||
|
||||
ofs->color = GPU_texture_create_2D_custom_multisample(width, height, 4,
|
||||
ofs->color = GPU_texture_create_2D_multisample(width, height,
|
||||
(high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL, samples, err_out);
|
||||
|
||||
if (depth) {
|
||||
ofs->depth = GPU_texture_create_depth_with_stencil_multisample(width, height, samples, err_out);
|
||||
ofs->depth = GPU_texture_create_2D_multisample(width, height, GPU_DEPTH24_STENCIL8, NULL, samples, err_out);
|
||||
}
|
||||
|
||||
if ((depth && !ofs->depth) || !ofs->color) {
|
||||
|
|
|
@ -523,7 +523,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
|
|||
GPU_texture_free(material->sss_tex_profile);
|
||||
}
|
||||
|
||||
material->sss_tex_profile = GPU_texture_create_1D_custom(64, 4, GPU_RGBA16F, translucence_profile, NULL);
|
||||
material->sss_tex_profile = GPU_texture_create_1D(64, GPU_RGBA16F, translucence_profile, NULL);
|
||||
|
||||
MEM_freeN(translucence_profile);
|
||||
|
||||
|
|
|
@ -252,6 +252,26 @@ static GLenum gpu_texture_get_format(
|
|||
}
|
||||
}
|
||||
|
||||
static int gpu_texture_get_component_count(GPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA32F:
|
||||
return 4;
|
||||
case GPU_RGB16F:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return 3;
|
||||
case GPU_RG8:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG32F:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static float *GPU_texture_3D_rescale(GPUTexture *tex, int w, int h, int d, int channels, const float *fpixels)
|
||||
{
|
||||
const unsigned int xf = w / tex->w, yf = h / tex->h, zf = d / tex->d;
|
||||
|
@ -354,7 +374,7 @@ static bool gpu_texture_try_alloc(
|
|||
|
||||
static GPUTexture *GPU_texture_create_nD(
|
||||
int w, int h, int d, int n, const float *fpixels,
|
||||
GPUTextureFormat data_type, int components, int samples,
|
||||
GPUTextureFormat data_type, int samples,
|
||||
const bool can_rescale, char err_out[256])
|
||||
{
|
||||
if (samples) {
|
||||
|
@ -369,7 +389,7 @@ static GPUTexture *GPU_texture_create_nD(
|
|||
tex->number = -1;
|
||||
tex->refcount = 1;
|
||||
tex->format = data_type;
|
||||
tex->components = components;
|
||||
tex->components = gpu_texture_get_component_count(data_type);
|
||||
tex->format_flag = 0;
|
||||
|
||||
if (n == 2) {
|
||||
|
@ -397,7 +417,7 @@ static GPUTexture *GPU_texture_create_nD(
|
|||
tex->target = GL_TEXTURE_2D_MULTISAMPLE;
|
||||
|
||||
GLenum format, internalformat, data_format;
|
||||
internalformat = gpu_texture_get_format(components, data_type, &format, &data_format,
|
||||
internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format,
|
||||
&tex->format_flag, &tex->bytesize);
|
||||
|
||||
gpu_texture_memory_footprint_add(tex);
|
||||
|
@ -434,7 +454,7 @@ static GPUTexture *GPU_texture_create_nD(
|
|||
}
|
||||
|
||||
float *rescaled_fpixels = NULL;
|
||||
bool valid = gpu_texture_try_alloc(tex, proxy, internalformat, format, data_format, components, can_rescale,
|
||||
bool valid = gpu_texture_try_alloc(tex, proxy, internalformat, format, data_format, tex->components, can_rescale,
|
||||
fpixels, &rescaled_fpixels);
|
||||
if (!valid) {
|
||||
if (err_out)
|
||||
|
@ -506,7 +526,7 @@ static GPUTexture *GPU_texture_cube_create(
|
|||
int w, int d,
|
||||
const float *fpixels_px, const float *fpixels_py, const float *fpixels_pz,
|
||||
const float *fpixels_nx, const float *fpixels_ny, const float *fpixels_nz,
|
||||
GPUTextureFormat data_type, int components,
|
||||
GPUTextureFormat data_type,
|
||||
char err_out[256])
|
||||
{
|
||||
GLenum format, internalformat, data_format;
|
||||
|
@ -519,7 +539,7 @@ static GPUTexture *GPU_texture_cube_create(
|
|||
tex->number = -1;
|
||||
tex->refcount = 1;
|
||||
tex->format = data_type;
|
||||
tex->components = components;
|
||||
tex->components = gpu_texture_get_component_count(data_type);
|
||||
tex->format_flag = GPU_FORMAT_CUBE;
|
||||
|
||||
if (d == 0) {
|
||||
|
@ -530,7 +550,7 @@ static GPUTexture *GPU_texture_cube_create(
|
|||
// tex->target_base = tex->target = GL_TEXTURE_CUBE_MAP_ARRAY;
|
||||
}
|
||||
|
||||
internalformat = gpu_texture_get_format(components, data_type, &format, &data_format,
|
||||
internalformat = gpu_texture_get_format(tex->components, data_type, &format, &data_format,
|
||||
&tex->format_flag, &tex->bytesize);
|
||||
|
||||
gpu_texture_memory_footprint_add(tex);
|
||||
|
@ -692,59 +712,41 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
|
|||
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_1D(int w, const float *pixels, char err_out[256])
|
||||
GPUTexture *GPU_texture_create_1D(
|
||||
int w, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, 0, 0, 1, pixels, GPU_RGBA8, 4, 0, false, err_out);
|
||||
return GPU_texture_create_nD(w, 0, 0, 1, pixels, data_type, 0, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_1D_custom(
|
||||
int w, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
GPUTexture *GPU_texture_create_2D(
|
||||
int w, int h, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, 0, 0, 1, pixels, data_type, channels, 0, false, err_out);
|
||||
return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, 0, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2D(int w, int h, const float *pixels, char err_out[256])
|
||||
GPUTexture *GPU_texture_create_2D_multisample(
|
||||
int w, int h, GPUTextureFormat data_type, const float *pixels, int samples, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, pixels, GPU_RGBA8, 4, 0, false, err_out);
|
||||
return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, samples, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2D_custom(
|
||||
int w, int h, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
GPUTexture *GPU_texture_create_2D_array(
|
||||
int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, channels, 0, false, err_out);
|
||||
return GPU_texture_create_nD(w, h, d, 2, pixels, data_type, 0, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2D_multisample(int w, int h, const float *pixels, int samples, char err_out[256])
|
||||
GPUTexture *GPU_texture_create_3D(
|
||||
int w, int h, int d, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, pixels, GPU_RGBA8, 4, samples, false, err_out);
|
||||
return GPU_texture_create_nD(w, h, d, 3, pixels, data_type, 0, true, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2D_custom_multisample(
|
||||
int w, int h, int channels, GPUTextureFormat data_type, const float *pixels, int samples, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, pixels, data_type, channels, samples, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2D_array_custom(
|
||||
int w, int h, int d, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, d, 2, pixels, data_type, channels, 0, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_3D(int w, int h, int d, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, d, 3, pixels, GPU_RGBA8, 4, 0, true, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_3D_custom(
|
||||
int w, int h, int d, int channels, GPUTextureFormat data_type, const float *pixels, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, d, 3, pixels, data_type, channels, 0, true, err_out);
|
||||
}
|
||||
GPUTexture *GPU_texture_create_cube_custom(
|
||||
int w, int channels, GPUTextureFormat data_type, const float *fpixels, char err_out[256])
|
||||
GPUTexture *GPU_texture_create_cube(
|
||||
int w, GPUTextureFormat data_type, const float *fpixels, char err_out[256])
|
||||
{
|
||||
const float *fpixels_px, *fpixels_py, *fpixels_pz, *fpixels_nx, *fpixels_ny, *fpixels_nz;
|
||||
const int channels = gpu_texture_get_component_count(data_type);
|
||||
|
||||
if (fpixels) {
|
||||
fpixels_px = fpixels + 0 * w * w * channels;
|
||||
|
@ -759,27 +761,7 @@ GPUTexture *GPU_texture_create_cube_custom(
|
|||
}
|
||||
|
||||
return GPU_texture_cube_create(w, 0, fpixels_px, fpixels_py, fpixels_pz, fpixels_nx, fpixels_ny, fpixels_nz,
|
||||
data_type, channels, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, NULL, GPU_DEPTH_COMPONENT24, 1, 0, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_depth_with_stencil(int w, int h, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, NULL, GPU_DEPTH24_STENCIL8, 1, 0, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_depth_multisample(int w, int h, int samples, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, NULL, GPU_DEPTH_COMPONENT24, 1, samples, false, err_out);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_depth_with_stencil_multisample(int w, int h, int samples, char err_out[256])
|
||||
{
|
||||
return GPU_texture_create_nD(w, h, 0, 2, NULL, GPU_DEPTH24_STENCIL8, 1, samples, false, err_out);
|
||||
data_type, err_out);
|
||||
}
|
||||
|
||||
void GPU_texture_update(GPUTexture *tex, const float *pixels)
|
||||
|
@ -817,9 +799,9 @@ void GPU_invalid_tex_init(void)
|
|||
{
|
||||
memory_usage = 0;
|
||||
const float color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
|
||||
GG.invalid_tex_1D = GPU_texture_create_1D(1, color, NULL);
|
||||
GG.invalid_tex_2D = GPU_texture_create_2D(1, 1, color, NULL);
|
||||
GG.invalid_tex_3D = GPU_texture_create_3D(1, 1, 1, color, NULL);
|
||||
GG.invalid_tex_1D = GPU_texture_create_1D(1, GPU_RGBA8, color, NULL);
|
||||
GG.invalid_tex_2D = GPU_texture_create_2D(1, 1, GPU_RGBA8, color, NULL);
|
||||
GG.invalid_tex_3D = GPU_texture_create_3D(1, 1, 1, GPU_RGBA8, color, NULL);
|
||||
}
|
||||
|
||||
void GPU_invalid_tex_bind(int mode)
|
||||
|
|
|
@ -291,7 +291,7 @@ double *GPU_viewport_cache_time_get(GPUViewport *viewport)
|
|||
* Try to find a texture coresponding to params into the texture pool.
|
||||
* If no texture was found, create one and add it to the pool.
|
||||
*/
|
||||
GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int channels, int format)
|
||||
GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int format)
|
||||
{
|
||||
GPUTexture *tex;
|
||||
|
||||
|
@ -314,7 +314,7 @@ GPUTexture *GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine,
|
|||
}
|
||||
}
|
||||
|
||||
tex = GPU_texture_create_2D_custom(width, height, channels, format, NULL, NULL);
|
||||
tex = GPU_texture_create_2D(width, height, format, NULL, NULL);
|
||||
GPU_texture_bind(tex, 0);
|
||||
/* Doing filtering for depth does not make sense when not doing shadow mapping,
|
||||
* and enabling texture filtering on integer texture make them unreadable. */
|
||||
|
@ -391,8 +391,8 @@ static void gpu_viewport_default_fb_create(GPUViewport *viewport)
|
|||
int *size = viewport->size;
|
||||
bool ok = true;
|
||||
|
||||
dtxl->color = GPU_texture_create_2D(size[0], size[1], NULL, NULL);
|
||||
dtxl->depth = GPU_texture_create_depth_with_stencil(size[0], size[1], NULL);
|
||||
dtxl->color = GPU_texture_create_2D(size[0], size[1], GPU_RGBA8, NULL, NULL);
|
||||
dtxl->depth = GPU_texture_create_2D(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
|
||||
|
||||
if (!(dtxl->depth && dtxl->color)) {
|
||||
ok = false;
|
||||
|
@ -436,8 +436,8 @@ static void gpu_viewport_default_multisample_fb_create(GPUViewport *viewport)
|
|||
int samples = viewport->samples;
|
||||
bool ok = true;
|
||||
|
||||
dtxl->multisample_color = GPU_texture_create_2D_multisample(size[0], size[1], NULL, samples, NULL);
|
||||
dtxl->multisample_depth = GPU_texture_create_depth_with_stencil_multisample(size[0], size[1], samples, NULL);
|
||||
dtxl->multisample_color = GPU_texture_create_2D_multisample(size[0], size[1], GPU_RGBA8, NULL, samples, NULL);
|
||||
dtxl->multisample_depth = GPU_texture_create_2D_multisample(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, samples, NULL);
|
||||
|
||||
if (!(dtxl->multisample_depth && dtxl->multisample_color)) {
|
||||
ok = false;
|
||||
|
|
Loading…
Reference in New Issue