Cleanup: GPUTexture: Remove _ex suffix from texture creation

It isn't relevant anymore now that usage flags are mandatory.

Pull Request #105197
This commit is contained in:
2023-02-25 01:52:27 +01:00
committed by Gitea
parent 3d6578b33e
commit 9fb1f32f06
43 changed files with 358 additions and 370 deletions

View File

@@ -216,13 +216,13 @@ class DisplayGPUTexture {
height = texture_height; height = texture_height;
/* Texture must have a minimum size of 1x1. */ /* Texture must have a minimum size of 1x1. */
gpu_texture = GPU_texture_create_2d_ex("CyclesBlitTexture", gpu_texture = GPU_texture_create_2d("CyclesBlitTexture",
max(width, 1), max(width, 1),
max(height, 1), max(height, 1),
1, 1,
GPU_RGBA16F, GPU_RGBA16F,
GPU_TEXTURE_USAGE_GENERAL, GPU_TEXTURE_USAGE_GENERAL,
nullptr); nullptr);
if (!gpu_texture) { if (!gpu_texture) {
LOG(ERROR) << "Error creating texture."; LOG(ERROR) << "Error creating texture.";

View File

@@ -337,11 +337,11 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
* It depends on more than height. So check instead by looking at the source. */ * It depends on more than height. So check instead by looking at the source. */
std::string sampler1D_name = std::string("sampler1D ") + sampler_name; std::string sampler1D_name = std::string("sampler1D ") + sampler_name;
if (strstr(shader_desc->getShaderText(), sampler1D_name.c_str()) != nullptr) { if (strstr(shader_desc->getShaderText(), sampler1D_name.c_str()) != nullptr) {
lut.texture = GPU_texture_create_1d_ex( lut.texture = GPU_texture_create_1d(
texture_name, width, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values); texture_name, width, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
} }
else { else {
lut.texture = GPU_texture_create_2d_ex( lut.texture = GPU_texture_create_2d(
texture_name, width, height, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values); texture_name, width, height, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
} }
if (lut.texture == nullptr) { if (lut.texture == nullptr) {
@@ -374,14 +374,14 @@ static bool addGPULut3D(OCIO_GPUTextures &textures,
} }
OCIO_GPULutTexture lut; OCIO_GPULutTexture lut;
lut.texture = GPU_texture_create_3d_ex(texture_name, lut.texture = GPU_texture_create_3d(texture_name,
edgelen, edgelen,
edgelen, edgelen,
edgelen, edgelen,
1, 1,
GPU_RGB16F, GPU_RGB16F,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
values); values);
if (lut.texture == nullptr) { if (lut.texture == nullptr) {
return false; return false;
} }
@@ -450,7 +450,7 @@ static bool createGPUCurveMapping(OCIO_GPUCurveMappping &curvemap,
if (curve_mapping_settings) { if (curve_mapping_settings) {
int lut_size = curve_mapping_settings->lut_size; int lut_size = curve_mapping_settings->lut_size;
curvemap.texture = GPU_texture_create_1d_ex( curvemap.texture = GPU_texture_create_1d(
"OCIOCurveMap", lut_size, 1, GPU_RGBA16F, GPU_TEXTURE_USAGE_SHADER_READ, nullptr); "OCIOCurveMap", lut_size, 1, GPU_RGBA16F, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
GPU_texture_filter_mode(curvemap.texture, false); GPU_texture_filter_mode(curvemap.texture, false);
GPU_texture_wrap_mode(curvemap.texture, false, true); GPU_texture_wrap_mode(curvemap.texture, false, true);

View File

@@ -1199,7 +1199,7 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x,
if (gc->texture) { if (gc->texture) {
GPU_texture_free(gc->texture); GPU_texture_free(gc->texture);
} }
gc->texture = GPU_texture_create_2d_ex( gc->texture = GPU_texture_create_2d(
__func__, w, h, 1, GPU_R8, GPU_TEXTURE_USAGE_SHADER_READ, NULL); __func__, w, h, 1, GPU_R8, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
gc->bitmap_len_landed = 0; gc->bitmap_len_landed = 0;

View File

@@ -111,7 +111,7 @@ static GPUTexture *gpu_texture_create_tile_mapping(Image *ima, const int multivi
tile_info[3] = tile_runtime->tilearray_size[1] / array_h; tile_info[3] = tile_runtime->tilearray_size[1] / array_h;
} }
GPUTexture *tex = GPU_texture_create_1d_array_ex( GPUTexture *tex = GPU_texture_create_1d_array(
ima->id.name + 2, width, 2, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_SHADER_READ, data); ima->id.name + 2, width, 2, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_SHADER_READ, data);
GPU_texture_mipmap_mode(tex, false, false); GPU_texture_mipmap_mode(tex, false, false);

View File

@@ -478,13 +478,13 @@ static void studiolight_create_equirect_radiance_gputexture(StudioLight *sl)
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
ImBuf *ibuf = sl->equirect_radiance_buffer; ImBuf *ibuf = sl->equirect_radiance_buffer;
sl->equirect_radiance_gputexture = GPU_texture_create_2d_ex("studiolight_radiance", sl->equirect_radiance_gputexture = GPU_texture_create_2d("studiolight_radiance",
ibuf->x, ibuf->x,
ibuf->y, ibuf->y,
1, 1,
GPU_RGBA16F, GPU_RGBA16F,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
ibuf->rect_float); ibuf->rect_float);
GPUTexture *tex = sl->equirect_radiance_gputexture; GPUTexture *tex = sl->equirect_radiance_gputexture;
GPU_texture_filter_mode(tex, true); GPU_texture_filter_mode(tex, true);
GPU_texture_wrap_mode(tex, true, true); GPU_texture_wrap_mode(tex, true, true);
@@ -504,7 +504,7 @@ static void studiolight_create_matcap_gputexture(StudioLightImage *sli)
copy_v3_v3(*offset3, *offset4); copy_v3_v3(*offset3, *offset4);
} }
sli->gputexture = GPU_texture_create_2d_ex( sli->gputexture = GPU_texture_create_2d(
"matcap", ibuf->x, ibuf->y, 1, GPU_R11F_G11F_B10F, GPU_TEXTURE_USAGE_SHADER_READ, NULL); "matcap", ibuf->x, ibuf->y, 1, GPU_R11F_G11F_B10F, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
GPU_texture_update(sli->gputexture, GPU_DATA_FLOAT, gpu_matcap_3components); GPU_texture_update(sli->gputexture, GPU_DATA_FLOAT, gpu_matcap_3components);
@@ -539,13 +539,13 @@ static void studiolight_create_equirect_irradiance_gputexture(StudioLight *sl)
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED); BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED);
ImBuf *ibuf = sl->equirect_irradiance_buffer; ImBuf *ibuf = sl->equirect_irradiance_buffer;
sl->equirect_irradiance_gputexture = GPU_texture_create_2d_ex("studiolight_irradiance", sl->equirect_irradiance_gputexture = GPU_texture_create_2d("studiolight_irradiance",
ibuf->x, ibuf->x,
ibuf->y, ibuf->y,
1, 1,
GPU_RGBA16F, GPU_RGBA16F,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
ibuf->rect_float); ibuf->rect_float);
GPUTexture *tex = sl->equirect_irradiance_gputexture; GPUTexture *tex = sl->equirect_irradiance_gputexture;
GPU_texture_filter_mode(tex, true); GPU_texture_filter_mode(tex, true);
GPU_texture_wrap_mode(tex, true, true); GPU_texture_wrap_mode(tex, true, true);

View File

@@ -85,7 +85,7 @@ void MorphologicalDistanceFeatherWeights::compute_weights(int radius)
weights[i] /= sum; weights[i] /= sum;
} }
weights_texture_ = GPU_texture_create_1d_ex( weights_texture_ = GPU_texture_create_1d(
"Weights", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data()); "Weights", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data());
} }
@@ -129,7 +129,7 @@ void MorphologicalDistanceFeatherWeights::compute_distance_falloffs(int type, in
falloffs[i] = compute_distance_falloff(type, i * scale); falloffs[i] = compute_distance_falloff(type, i * scale);
} }
distance_falloffs_texture_ = GPU_texture_create_1d_ex( distance_falloffs_texture_ = GPU_texture_create_1d(
"Distance Factors", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, falloffs.data()); "Distance Factors", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, falloffs.data());
} }

View File

@@ -93,7 +93,7 @@ SymmetricBlurWeights::SymmetricBlurWeights(int type, float2 radius)
} }
} }
texture_ = GPU_texture_create_2d_ex( texture_ = GPU_texture_create_2d(
"Weights", size.x, size.y, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data()); "Weights", size.x, size.y, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data());
} }

View File

@@ -70,7 +70,7 @@ SymmetricSeparableBlurWeights::SymmetricSeparableBlurWeights(int type, float rad
weights[i] /= sum; weights[i] /= sum;
} }
texture_ = GPU_texture_create_1d_ex( texture_ = GPU_texture_create_1d(
"Weights", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data()); "Weights", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data());
} }

View File

@@ -639,9 +639,9 @@ static void dof_reduce_pass_init(EEVEE_FramebufferList *fbl,
/* Do not use texture pool because of needs mipmaps. */ /* Do not use texture pool because of needs mipmaps. */
eGPUTextureUsage tex_flags = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT | eGPUTextureUsage tex_flags = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW; GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW;
txl->dof_reduced_color = GPU_texture_create_2d_ex( txl->dof_reduced_color = GPU_texture_create_2d(
"dof_reduced_color", UNPACK2(res), mip_count, GPU_RGBA16F, tex_flags, NULL); "dof_reduced_color", UNPACK2(res), mip_count, GPU_RGBA16F, tex_flags, NULL);
txl->dof_reduced_coc = GPU_texture_create_2d_ex( txl->dof_reduced_coc = GPU_texture_create_2d(
"dof_reduced_coc", UNPACK2(res), mip_count, GPU_R16F, tex_flags, NULL); "dof_reduced_coc", UNPACK2(res), mip_count, GPU_R16F, tex_flags, NULL);
} }

View File

@@ -397,12 +397,12 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
if (lcache->grid_tx.tex == NULL) { if (lcache->grid_tx.tex == NULL) {
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT | eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
GPU_TEXTURE_USAGE_HOST_READ; GPU_TEXTURE_USAGE_HOST_READ;
lcache->grid_tx.tex = GPU_texture_create_2d_array_ex("lightcache_irradiance", lcache->grid_tx.tex = GPU_texture_create_2d_array("lightcache_irradiance",
UNPACK3(lcache->grid_tx.tex_size), UNPACK3(lcache->grid_tx.tex_size),
1, 1,
IRRADIANCE_FORMAT, IRRADIANCE_FORMAT,
usage, usage,
NULL); NULL);
GPU_texture_update(lcache->grid_tx.tex, GPU_DATA_UBYTE, lcache->grid_tx.data); GPU_texture_update(lcache->grid_tx.tex, GPU_DATA_UBYTE, lcache->grid_tx.data);
if (lcache->grid_tx.tex == NULL) { if (lcache->grid_tx.tex == NULL) {
@@ -418,23 +418,23 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
GPU_TEXTURE_USAGE_HOST_READ; GPU_TEXTURE_USAGE_HOST_READ;
/* Try to create a cubemap array. */ /* Try to create a cubemap array. */
lcache->cube_tx.tex = GPU_texture_create_cube_array_ex("lightcache_cubemaps", lcache->cube_tx.tex = GPU_texture_create_cube_array("lightcache_cubemaps",
lcache->cube_tx.tex_size[0], lcache->cube_tx.tex_size[0],
lcache->cube_tx.tex_size[2] / 6, lcache->cube_tx.tex_size[2] / 6,
lcache->mips_len + 1, lcache->mips_len + 1,
GPU_R11F_G11F_B10F, GPU_R11F_G11F_B10F,
usage, usage,
NULL); NULL);
if (lcache->cube_tx.tex == NULL) { if (lcache->cube_tx.tex == NULL) {
/* Try fallback to 2D array. */ /* Try fallback to 2D array. */
lcache->cube_tx.tex = GPU_texture_create_2d_array_ex("lightcache_cubemaps_fallback", lcache->cube_tx.tex = GPU_texture_create_2d_array("lightcache_cubemaps_fallback",
UNPACK3(lcache->cube_tx.tex_size), UNPACK3(lcache->cube_tx.tex_size),
lcache->mips_len + 1, lcache->mips_len + 1,
GPU_R11F_G11F_B10F, GPU_R11F_G11F_B10F,
usage, usage,
NULL); NULL);
} }
if (lcache->cube_tx.tex == NULL) { if (lcache->cube_tx.tex == NULL) {

View File

@@ -44,11 +44,11 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata)
if (txl->smaa_search_tx == NULL) { if (txl->smaa_search_tx == NULL) {
txl->smaa_search_tx = GPU_texture_create_2d_ex( txl->smaa_search_tx = GPU_texture_create_2d(
"smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, usage, NULL); "smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, usage, NULL);
GPU_texture_update(txl->smaa_search_tx, GPU_DATA_UBYTE, searchTexBytes); GPU_texture_update(txl->smaa_search_tx, GPU_DATA_UBYTE, searchTexBytes);
txl->smaa_area_tx = GPU_texture_create_2d_ex( txl->smaa_area_tx = GPU_texture_create_2d(
"smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, usage, NULL); "smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, usage, NULL);
GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UBYTE, areaTexBytes); GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UBYTE, areaTexBytes);

View File

@@ -80,7 +80,7 @@ static GPUTexture *edit_uv_mask_texture(
/* Free memory. */ /* Free memory. */
BKE_maskrasterize_handle_free(handle); BKE_maskrasterize_handle_free(handle);
GPUTexture *texture = GPU_texture_create_2d_ex( GPUTexture *texture = GPU_texture_create_2d(
mask->id.name, width, height, 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, buffer); mask->id.name, width, height, 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, buffer);
MEM_freeN(buffer); MEM_freeN(buffer);
return texture; return texture;
@@ -117,10 +117,10 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata)
const bool show_modified_uvs = sima->flag & SI_DRAWSHADOW; const bool show_modified_uvs = sima->flag & SI_DRAWSHADOW;
const bool is_tiled_image = image && (image->source == IMA_SRC_TILED); const bool is_tiled_image = image && (image->source == IMA_SRC_TILED);
const bool do_edges_only = (ts->uv_flag & UV_SYNC_SELECTION) ? const bool do_edges_only = (ts->uv_flag & UV_SYNC_SELECTION) ?
/* NOTE: Ignore #SCE_SELECT_EDGE because a single selected edge /* NOTE: Ignore #SCE_SELECT_EDGE because a single selected edge
* on the mesh may cause single UV vertices to be selected. */ * on the mesh may cause single UV vertices to be selected. */
false : false :
(ts->uv_selectmode == UV_SELECT_EDGE); (ts->uv_selectmode == UV_SELECT_EDGE);
const bool do_faces = ((sima->flag & SI_NO_DRAWFACES) == 0); const bool do_faces = ((sima->flag & SI_NO_DRAWFACES) == 0);
const bool do_face_dots = (ts->uv_flag & UV_SYNC_SELECTION) ? const bool do_face_dots = (ts->uv_flag & UV_SYNC_SELECTION) ?
(ts->selectmode & SCE_SELECT_FACE) != 0 : (ts->selectmode & SCE_SELECT_FACE) != 0 :

View File

@@ -60,7 +60,7 @@ static void select_engine_framebuffer_setup(void)
if (e_data.texture_u32 == NULL) { if (e_data.texture_u32 == NULL) {
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
e_data.texture_u32 = GPU_texture_create_2d_ex( e_data.texture_u32 = GPU_texture_create_2d(
"select_buf_ids", size[0], size[1], 1, GPU_R32UI, usage, NULL); "select_buf_ids", size[0], size[1], 1, GPU_R32UI, usage, NULL);
GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, e_data.texture_u32, 0, 0); GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, e_data.texture_u32, 0, 0);

View File

@@ -236,11 +236,11 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata)
/* TODO: could be shared for all viewports. */ /* TODO: could be shared for all viewports. */
if (txl->smaa_search_tx == NULL) { if (txl->smaa_search_tx == NULL) {
txl->smaa_search_tx = GPU_texture_create_2d_ex( txl->smaa_search_tx = GPU_texture_create_2d(
"smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, usage, NULL); "smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, usage, NULL);
GPU_texture_update(txl->smaa_search_tx, GPU_DATA_UBYTE, searchTexBytes); GPU_texture_update(txl->smaa_search_tx, GPU_DATA_UBYTE, searchTexBytes);
txl->smaa_area_tx = GPU_texture_create_2d_ex( txl->smaa_area_tx = GPU_texture_create_2d(
"smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, usage, NULL); "smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, usage, NULL);
GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UBYTE, areaTexBytes); GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UBYTE, areaTexBytes);

View File

@@ -505,9 +505,9 @@ static bool workbench_render_framebuffers_init(void)
if (dtxl->color == nullptr) { if (dtxl->color == nullptr) {
BLI_assert(dtxl->depth == nullptr); BLI_assert(dtxl->depth == nullptr);
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
dtxl->color = GPU_texture_create_2d_ex( dtxl->color = GPU_texture_create_2d(
"txl.color", size.x, size.y, 1, GPU_RGBA16F, usage, nullptr); "txl.color", size.x, size.y, 1, GPU_RGBA16F, usage, nullptr);
dtxl->depth = GPU_texture_create_2d_ex( dtxl->depth = GPU_texture_create_2d(
"txl.depth", size.x, size.y, 1, GPU_DEPTH24_STENCIL8, usage, nullptr); "txl.depth", size.x, size.y, 1, GPU_DEPTH24_STENCIL8, usage, nullptr);
} }

View File

@@ -66,9 +66,8 @@ static bool workbench_render_framebuffers_init(void)
if (dtxl->color == NULL) { if (dtxl->color == NULL) {
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
BLI_assert(dtxl->depth == NULL); BLI_assert(dtxl->depth == NULL);
dtxl->color = GPU_texture_create_2d_ex( dtxl->color = GPU_texture_create_2d("txl.color", UNPACK2(size), 1, GPU_RGBA16F, usage, NULL);
"txl.color", UNPACK2(size), 1, GPU_RGBA16F, usage, NULL); dtxl->depth = GPU_texture_create_2d(
dtxl->depth = GPU_texture_create_2d_ex(
"txl.depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, usage, NULL); "txl.depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, usage, NULL);
} }

View File

@@ -32,11 +32,11 @@ void workbench_volume_engine_init(WORKBENCH_Data *vedata)
const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f}; const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
txl->dummy_volume_tx = GPU_texture_create_3d_ex( txl->dummy_volume_tx = GPU_texture_create_3d(
"dummy_volume", 1, 1, 1, 1, GPU_RGBA8, usage, zero); "dummy_volume", 1, 1, 1, 1, GPU_RGBA8, usage, zero);
txl->dummy_shadow_tx = GPU_texture_create_3d_ex( txl->dummy_shadow_tx = GPU_texture_create_3d(
"dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, usage, one); "dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, usage, one);
txl->dummy_coba_tx = GPU_texture_create_1d_ex("dummy_coba", 1, 1, GPU_RGBA8, usage, zero); txl->dummy_coba_tx = GPU_texture_create_1d("dummy_coba", 1, 1, GPU_RGBA8, usage, zero);
} }
} }

View File

@@ -908,30 +908,30 @@ class Texture : NonCopyable {
bool cubemap) bool cubemap)
{ {
if (h == 0) { if (h == 0) {
return GPU_texture_create_1d_ex(name_, w, mip_len, format, usage, data); return GPU_texture_create_1d(name_, w, mip_len, format, usage, data);
} }
else if (cubemap) { else if (cubemap) {
if (layered) { if (layered) {
return GPU_texture_create_cube_array_ex(name_, w, d, mip_len, format, usage, data); return GPU_texture_create_cube_array(name_, w, d, mip_len, format, usage, data);
} }
else { else {
return GPU_texture_create_cube_ex(name_, w, mip_len, format, usage, data); return GPU_texture_create_cube(name_, w, mip_len, format, usage, data);
} }
} }
else if (d == 0) { else if (d == 0) {
if (layered) { if (layered) {
return GPU_texture_create_1d_array_ex(name_, w, h, mip_len, format, usage, data); return GPU_texture_create_1d_array(name_, w, h, mip_len, format, usage, data);
} }
else { else {
return GPU_texture_create_2d_ex(name_, w, h, mip_len, format, usage, data); return GPU_texture_create_2d(name_, w, h, mip_len, format, usage, data);
} }
} }
else { else {
if (layered) { if (layered) {
return GPU_texture_create_2d_array_ex(name_, w, h, d, mip_len, format, usage, data); return GPU_texture_create_2d_array(name_, w, h, d, mip_len, format, usage, data);
} }
else { else {
return GPU_texture_create_3d_ex(name_, w, h, d, mip_len, format, usage, data); return GPU_texture_create_3d(name_, w, h, d, mip_len, format, usage, data);
} }
} }
} }

View File

@@ -307,13 +307,13 @@ static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume,
/* Create GPU texture. */ /* Create GPU texture. */
eGPUTextureFormat format = (channels == 3) ? GPU_RGB16F : GPU_R16F; eGPUTextureFormat format = (channels == 3) ? GPU_RGB16F : GPU_R16F;
cache_grid->texture = GPU_texture_create_3d_ex("volume_grid", cache_grid->texture = GPU_texture_create_3d("volume_grid",
UNPACK3(dense_grid.resolution), UNPACK3(dense_grid.resolution),
1, 1,
format, format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
dense_grid.voxels); dense_grid.voxels);
/* The texture can be null if the resolution along one axis is larger than /* The texture can be null if the resolution along one axis is larger than
* GL_MAX_3D_TEXTURE_SIZE. */ * GL_MAX_3D_TEXTURE_SIZE. */
if (cache_grid->texture != nullptr) { if (cache_grid->texture != nullptr) {

View File

@@ -219,7 +219,7 @@ void DRW_globals_update(void)
BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size); BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size);
G_draw.ramp = GPU_texture_create_1d_ex( G_draw.ramp = GPU_texture_create_1d(
"ramp", col_size, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, colors); "ramp", col_size, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, colors);
MEM_freeN(colors); MEM_freeN(colors);
@@ -477,6 +477,6 @@ static GPUTexture *DRW_create_weight_colorramp_texture(void)
pixels[i][3] = 1.0f; pixels[i][3] = 1.0f;
} }
return GPU_texture_create_1d_ex( return GPU_texture_create_1d(
"weight_color_ramp", 256, 1, GPU_SRGB8_A8, GPU_TEXTURE_USAGE_SHADER_READ, pixels[0]); "weight_color_ramp", 256, 1, GPU_SRGB8_A8, GPU_TEXTURE_USAGE_SHADER_READ, pixels[0]);
} }

View File

@@ -106,7 +106,7 @@ static GPUTexture *create_transfer_function(int type, const struct ColorBand *co
break; break;
} }
GPUTexture *tex = GPU_texture_create_1d_ex( GPUTexture *tex = GPU_texture_create_1d(
"transf_func", TFUNC_WIDTH, 1, GPU_SRGB8_A8, GPU_TEXTURE_USAGE_SHADER_READ, data); "transf_func", TFUNC_WIDTH, 1, GPU_SRGB8_A8, GPU_TEXTURE_USAGE_SHADER_READ, data);
MEM_freeN(data); MEM_freeN(data);
@@ -179,13 +179,12 @@ static GPUTexture *create_volume_texture(const int dim[3],
} }
while (1) { while (1) {
tex = GPU_texture_create_3d_ex("volume", tex = GPU_texture_create_3d("volume",
UNPACK3(final_dim), UNPACK3(final_dim),
1, 1,
texture_format, texture_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, NULL);
NULL);
if (tex != NULL) { if (tex != NULL) {
break; break;
@@ -508,11 +507,11 @@ void DRW_smoke_ensure_velocity(FluidModifierData *fmd)
} }
if (!fds->tex_velocity_x) { if (!fds->tex_velocity_x) {
fds->tex_velocity_x = GPU_texture_create_3d_ex( fds->tex_velocity_x = GPU_texture_create_3d(
"velx", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_x); "velx", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_x);
fds->tex_velocity_y = GPU_texture_create_3d_ex( fds->tex_velocity_y = GPU_texture_create_3d(
"vely", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_y); "vely", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_y);
fds->tex_velocity_z = GPU_texture_create_3d_ex( fds->tex_velocity_z = GPU_texture_create_3d(
"velz", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_z); "velz", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_z);
BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_x)); BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_x));
BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_y)); BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_y));

View File

@@ -2339,7 +2339,7 @@ static void draw_select_framebuffer_depth_only_setup(const int size[2])
if (g_select_buffer.texture_depth == NULL) { if (g_select_buffer.texture_depth == NULL) {
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
g_select_buffer.texture_depth = GPU_texture_create_2d_ex( g_select_buffer.texture_depth = GPU_texture_create_2d(
"select_depth", size[0], size[1], 1, GPU_DEPTH_COMPONENT24, usage, NULL); "select_depth", size[0], size[1], 1, GPU_DEPTH_COMPONENT24, usage, NULL);
GPU_framebuffer_texture_attach( GPU_framebuffer_texture_attach(

View File

@@ -71,7 +71,7 @@ GPUTexture *DRW_texture_create_1d_ex(int w,
const float *fpixels) const float *fpixels)
{ {
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1; int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_1d_ex(__func__, w, mip_len, format, usage, fpixels); GPUTexture *tex = GPU_texture_create_1d(__func__, w, mip_len, format, usage, fpixels);
drw_texture_set_parameters(tex, flags); drw_texture_set_parameters(tex, flags);
return tex; return tex;
@@ -93,7 +93,7 @@ GPUTexture *DRW_texture_create_2d_ex(int w,
const float *fpixels) const float *fpixels)
{ {
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1; int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_2d_ex(__func__, w, h, mip_len, format, usage, fpixels); GPUTexture *tex = GPU_texture_create_2d(__func__, w, h, mip_len, format, usage, fpixels);
drw_texture_set_parameters(tex, flags); drw_texture_set_parameters(tex, flags);
return tex; return tex;
@@ -114,7 +114,7 @@ GPUTexture *DRW_texture_create_2d_array_ex(int w,
const float *fpixels) const float *fpixels)
{ {
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1; int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_2d_array_ex( GPUTexture *tex = GPU_texture_create_2d_array(
__func__, w, h, d, mip_len, format, usage, fpixels); __func__, w, h, d, mip_len, format, usage, fpixels);
drw_texture_set_parameters(tex, flags); drw_texture_set_parameters(tex, flags);
@@ -137,7 +137,7 @@ GPUTexture *DRW_texture_create_3d_ex(int w,
const float *fpixels) const float *fpixels)
{ {
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1; int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_3d_ex(__func__, w, h, d, mip_len, format, usage, fpixels); GPUTexture *tex = GPU_texture_create_3d(__func__, w, h, d, mip_len, format, usage, fpixels);
drw_texture_set_parameters(tex, flags); drw_texture_set_parameters(tex, flags);
return tex; return tex;
@@ -156,7 +156,7 @@ GPUTexture *DRW_texture_create_cube_ex(int w,
const float *fpixels) const float *fpixels)
{ {
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1; int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_cube_ex(__func__, w, mip_len, format, usage, fpixels); GPUTexture *tex = GPU_texture_create_cube(__func__, w, mip_len, format, usage, fpixels);
drw_texture_set_parameters(tex, flags); drw_texture_set_parameters(tex, flags);
return tex; return tex;
} }
@@ -177,8 +177,7 @@ GPUTexture *DRW_texture_create_cube_array_ex(int w,
const float *fpixels) const float *fpixels)
{ {
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1; int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_cube_array_ex( GPUTexture *tex = GPU_texture_create_cube_array(__func__, w, d, mip_len, format, usage, fpixels);
__func__, w, d, mip_len, format, usage, fpixels);
drw_texture_set_parameters(tex, flags); drw_texture_set_parameters(tex, flags);
return tex; return tex;
} }

View File

@@ -98,7 +98,7 @@ GPUTexture *DRW_texture_pool_query(DRWTexturePool *pool,
DRWTexturePoolHandle handle; DRWTexturePoolHandle handle;
handle.users_bits = user_bit; handle.users_bits = user_bit;
handle.texture = GPU_texture_create_2d_ex(name, width, height, 1, format, usage, nullptr); handle.texture = GPU_texture_create_2d(name, width, height, 1, format, usage, nullptr);
pool->handles.append(handle); pool->handles.append(handle);
/* Doing filtering for depth does not make sense when not doing shadow mapping, /* Doing filtering for depth does not make sense when not doing shadow mapping,
* and enabling texture filtering on integer texture make them unreadable. */ * and enabling texture filtering on integer texture make them unreadable. */
@@ -155,7 +155,7 @@ GPUTexture *DRW_texture_pool_texture_acquire(
int texture_id = pool->handles.size(); int texture_id = pool->handles.size();
SNPRINTF(name, "DRW_tex_pool_%d", texture_id); SNPRINTF(name, "DRW_tex_pool_%d", texture_id);
} }
tmp_tex = GPU_texture_create_2d_ex(name, width, height, 1, format, usage, nullptr); tmp_tex = GPU_texture_create_2d(name, width, height, 1, format, usage, nullptr);
} }
pool->tmp_tex_acquired.append(tmp_tex); pool->tmp_tex_acquired.append(tmp_tex);

View File

@@ -70,9 +70,9 @@ static void drw_volume_globals_init()
{ {
const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f}; const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
g_data.dummy_zero = GPU_texture_create_3d_ex( g_data.dummy_zero = GPU_texture_create_3d(
"dummy_zero", 1, 1, 1, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, zero); "dummy_zero", 1, 1, 1, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, zero);
g_data.dummy_one = GPU_texture_create_3d_ex( g_data.dummy_one = GPU_texture_create_3d(
"dummy_one", 1, 1, 1, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, one); "dummy_one", 1, 1, 1, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, one);
GPU_texture_wrap_mode(g_data.dummy_zero, true, true); GPU_texture_wrap_mode(g_data.dummy_zero, true, true);
GPU_texture_wrap_mode(g_data.dummy_one, true, true); GPU_texture_wrap_mode(g_data.dummy_one, true, true);

View File

@@ -912,20 +912,20 @@ void UI_icons_reload_internal_textures()
icongltex.invw = 1.0f / b32buf->x; icongltex.invw = 1.0f / b32buf->x;
icongltex.invh = 1.0f / b32buf->y; icongltex.invh = 1.0f / b32buf->y;
icongltex.tex[0] = GPU_texture_create_2d_ex( icongltex.tex[0] = GPU_texture_create_2d(
"icons", b32buf->x, b32buf->y, 2, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, nullptr); "icons", b32buf->x, b32buf->y, 2, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
GPU_texture_update_mipmap(icongltex.tex[0], 0, GPU_DATA_UBYTE, b32buf->rect); GPU_texture_update_mipmap(icongltex.tex[0], 0, GPU_DATA_UBYTE, b32buf->rect);
GPU_texture_update_mipmap(icongltex.tex[0], 1, GPU_DATA_UBYTE, b16buf->rect); GPU_texture_update_mipmap(icongltex.tex[0], 1, GPU_DATA_UBYTE, b16buf->rect);
} }
if (need_icons_with_border && icongltex.tex[1] == nullptr) { if (need_icons_with_border && icongltex.tex[1] == nullptr) {
icongltex.tex[1] = GPU_texture_create_2d_ex("icons_border", icongltex.tex[1] = GPU_texture_create_2d("icons_border",
b32buf_border->x, b32buf_border->x,
b32buf_border->y, b32buf_border->y,
2, 2,
GPU_RGBA8, GPU_RGBA8,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
nullptr); nullptr);
GPU_texture_update_mipmap(icongltex.tex[1], 0, GPU_DATA_UBYTE, b32buf_border->rect); GPU_texture_update_mipmap(icongltex.tex[1], 0, GPU_DATA_UBYTE, b32buf_border->rect);
GPU_texture_update_mipmap(icongltex.tex[1], 1, GPU_DATA_UBYTE, b16buf_border->rect); GPU_texture_update_mipmap(icongltex.tex[1], 1, GPU_DATA_UBYTE, b16buf_border->rect);
} }

View File

@@ -80,7 +80,7 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
const bool use_mipmap = use_filter && ((draw_width < img_w) || (draw_height < img_h)); const bool use_mipmap = use_filter && ((draw_width < img_w) || (draw_height < img_h));
const int mip_len = use_mipmap ? 9999 : 1; const int mip_len = use_mipmap ? 9999 : 1;
GPUTexture *tex = GPU_texture_create_2d_ex( GPUTexture *tex = GPU_texture_create_2d(
"immDrawPixels", img_w, img_h, mip_len, gpu_format, GPU_TEXTURE_USAGE_GENERAL, NULL); "immDrawPixels", img_w, img_h, mip_len, gpu_format, GPU_TEXTURE_USAGE_GENERAL, NULL);
const bool use_float_data = ELEM(gpu_format, GPU_RGBA16F, GPU_RGB16F, GPU_R16F); const bool use_float_data = ELEM(gpu_format, GPU_RGBA16F, GPU_RGB16F, GPU_R16F);
@@ -170,7 +170,7 @@ void immDrawPixelsTexTiled_scaling_clipping(IMMDrawPixelsTexState *state,
eGPUDataFormat gpu_data = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE; eGPUDataFormat gpu_data = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE;
size_t stride = components * ((use_float_data) ? sizeof(float) : sizeof(uchar)); size_t stride = components * ((use_float_data) ? sizeof(float) : sizeof(uchar));
GPUTexture *tex = GPU_texture_create_2d_ex( GPUTexture *tex = GPU_texture_create_2d(
"immDrawPixels", tex_w, tex_h, 1, gpu_format, GPU_TEXTURE_USAGE_GENERAL, NULL); "immDrawPixels", tex_w, tex_h, 1, gpu_format, GPU_TEXTURE_USAGE_GENERAL, NULL);
GPU_texture_filter_mode(tex, use_filter); GPU_texture_filter_mode(tex, use_filter);

View File

@@ -343,7 +343,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
eGPUTextureFormat format = col ? GPU_RGBA8 : GPU_R8; eGPUTextureFormat format = col ? GPU_RGBA8 : GPU_R8;
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT | eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW; GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW;
target->overlay_texture = GPU_texture_create_2d_ex( target->overlay_texture = GPU_texture_create_2d(
"paint_cursor_overlay", size, size, 1, format, usage, nullptr); "paint_cursor_overlay", size, size, 1, format, usage, nullptr);
GPU_texture_update(target->overlay_texture, GPU_DATA_UBYTE, buffer); GPU_texture_update(target->overlay_texture, GPU_DATA_UBYTE, buffer);
@@ -463,7 +463,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
if (!cursor_snap.overlay_texture) { if (!cursor_snap.overlay_texture) {
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT | eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW; GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW;
cursor_snap.overlay_texture = GPU_texture_create_2d_ex( cursor_snap.overlay_texture = GPU_texture_create_2d(
"cursor_snap_overaly", size, size, 1, GPU_R8, usage, nullptr); "cursor_snap_overaly", size, size, 1, GPU_R8, usage, nullptr);
GPU_texture_update(cursor_snap.overlay_texture, GPU_DATA_UBYTE, buffer); GPU_texture_update(cursor_snap.overlay_texture, GPU_DATA_UBYTE, buffer);

View File

@@ -1196,13 +1196,13 @@ static void draw_plane_marker_image(Scene *scene,
GPU_blend(GPU_BLEND_ALPHA); GPU_blend(GPU_BLEND_ALPHA);
} }
GPUTexture *texture = GPU_texture_create_2d_ex("plane_marker_image", GPUTexture *texture = GPU_texture_create_2d("plane_marker_image",
ibuf->x, ibuf->x,
ibuf->y, ibuf->y,
1, 1,
GPU_RGBA8, GPU_RGBA8,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
NULL); NULL);
GPU_texture_update(texture, GPU_DATA_UBYTE, display_buffer); GPU_texture_update(texture, GPU_DATA_UBYTE, display_buffer);
GPU_texture_filter_mode(texture, false); GPU_texture_filter_mode(texture, false);

View File

@@ -1909,7 +1909,7 @@ static void sequencer_draw_display_buffer(const bContext *C,
GPU_matrix_identity_projection_set(); GPU_matrix_identity_projection_set();
} }
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
GPUTexture *texture = GPU_texture_create_2d_ex( GPUTexture *texture = GPU_texture_create_2d(
"seq_display_buf", ibuf->x, ibuf->y, 1, format, usage, NULL); "seq_display_buf", ibuf->x, ibuf->y, 1, format, usage, NULL);
GPU_texture_update(texture, data, display_buffer); GPU_texture_update(texture, data, display_buffer);
GPU_texture_filter_mode(texture, false); GPU_texture_filter_mode(texture, false);

View File

@@ -264,76 +264,73 @@ typedef struct GPUTexture GPUTexture;
* \note \a data is expected to be float. If the \a format is not compatible with float data or if * \note \a data is expected to be float. If the \a format is not compatible with float data or if
* the data is not in float format, use GPU_texture_update to upload the data with the right data * the data is not in float format, use GPU_texture_update to upload the data with the right data
* format. * format.
* NOTE: `_ex` variants of texture creation functions allow specification of explicit usage for
* optimal performance. Using standard texture creation will use the `GPU_TEXTURE_USAGE_GENERAL`.
* *
* Textures created via other means will either inherit usage from the source resource, or also * Textures created via other means will either inherit usage from the source resource, or also
* be initialized with `GPU_TEXTURE_USAGE_GENERAL`. * be initialized with `GPU_TEXTURE_USAGE_GENERAL`.
* *
* flag. \a mips is the number of mip level to allocate. It must be >= 1. * flag. \a mips is the number of mip level to allocate. It must be >= 1.
*/ */
/* Extended texture functions. */ GPUTexture *GPU_texture_create_1d(const char *name,
GPUTexture *GPU_texture_create_1d_ex(const char *name, int width,
int width, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const float *data);
const float *data); GPUTexture *GPU_texture_create_1d_array(const char *name,
GPUTexture *GPU_texture_create_1d_array_ex(const char *name, int width,
int width, int layer_len,
int layer_len, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const float *data);
const float *data); GPUTexture *GPU_texture_create_2d(const char *name,
GPUTexture *GPU_texture_create_2d_ex(const char *name, int width,
int width, int height,
int height, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const float *data);
const float *data); GPUTexture *GPU_texture_create_2d_array(const char *name,
GPUTexture *GPU_texture_create_2d_array_ex(const char *name, int width,
int width, int height,
int height, int layer_len,
int layer_len, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const float *data);
const float *data); GPUTexture *GPU_texture_create_3d(const char *name,
GPUTexture *GPU_texture_create_3d_ex(const char *name, int width,
int width, int height,
int height, int depth,
int depth, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const void *data);
const void *data); GPUTexture *GPU_texture_create_cube(const char *name,
GPUTexture *GPU_texture_create_cube_ex(const char *name, int width,
int width, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const float *data);
const float *data); GPUTexture *GPU_texture_create_cube_array(const char *name,
GPUTexture *GPU_texture_create_cube_array_ex(const char *name, int width,
int width, int layer_len,
int layer_len, int mip_len,
int mip_len, eGPUTextureFormat format,
eGPUTextureFormat format, eGPUTextureUsage usage,
eGPUTextureUsage usage, const float *data);
const float *data);
/** /**
* DDS texture loading. Return NULL if compressed texture support is not available. * DDS texture loading. Return NULL if compressed texture support is not available.
* \a data should hold all the data for \a mip_len mipmaps. * \a data should hold all the data for \a mip_len mipmaps.
* The data is expected to be in compressed form. This isn't going to compress un-compress data. * The data is expected to be in compressed form. This isn't going to compress un-compress data.
*/ */
GPUTexture *GPU_texture_create_compressed_2d_ex(const char *name, GPUTexture *GPU_texture_create_compressed_2d(const char *name,
int width, int width,
int height, int height,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const void *data); const void *data);
/** /**
* Create a buffer texture that allow access to a buffer \a vertex_buf through a sampler of type * Create a buffer texture that allow access to a buffer \a vertex_buf through a sampler of type

View File

@@ -625,10 +625,10 @@ GPUOffScreen *GPU_offscreen_create(
width = max_ii(1, width); width = max_ii(1, width);
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
ofs->color = GPU_texture_create_2d_ex("ofs_color", width, height, 1, format, usage, nullptr); ofs->color = GPU_texture_create_2d("ofs_color", width, height, 1, format, usage, nullptr);
if (depth) { if (depth) {
ofs->depth = GPU_texture_create_2d_ex( ofs->depth = GPU_texture_create_2d(
"ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, usage, nullptr); "ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, usage, nullptr);
} }

View File

@@ -215,13 +215,13 @@ static void gpu_material_ramp_texture_build(GPUMaterial *mat)
GPUColorBandBuilder *builder = mat->coba_builder; GPUColorBandBuilder *builder = mat->coba_builder;
mat->coba_tex = GPU_texture_create_1d_array_ex("mat_ramp", mat->coba_tex = GPU_texture_create_1d_array("mat_ramp",
CM_TABLE + 1, CM_TABLE + 1,
builder->current_layer, builder->current_layer,
1, 1,
GPU_RGBA16F, GPU_RGBA16F,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
(float *)builder->pixels); (float *)builder->pixels);
MEM_freeN(builder); MEM_freeN(builder);
mat->coba_builder = NULL; mat->coba_builder = NULL;
@@ -233,14 +233,14 @@ static void gpu_material_sky_texture_build(GPUMaterial *mat)
return; return;
} }
mat->sky_tex = GPU_texture_create_2d_array_ex("mat_sky", mat->sky_tex = GPU_texture_create_2d_array("mat_sky",
GPU_SKY_WIDTH, GPU_SKY_WIDTH,
GPU_SKY_HEIGHT, GPU_SKY_HEIGHT,
mat->sky_builder->current_layer, mat->sky_builder->current_layer,
1, 1,
GPU_RGBA32F, GPU_RGBA32F,
GPU_TEXTURE_USAGE_GENERAL, GPU_TEXTURE_USAGE_GENERAL,
(float *)mat->sky_builder->pixels); (float *)mat->sky_builder->pixels);
MEM_freeN(mat->sky_builder); MEM_freeN(mat->sky_builder);
mat->sky_builder = NULL; mat->sky_builder = NULL;
@@ -610,12 +610,12 @@ struct GPUUniformBuf *GPU_material_sss_profile_get(GPUMaterial *material,
GPU_texture_free(material->sss_tex_profile); GPU_texture_free(material->sss_tex_profile);
} }
material->sss_tex_profile = GPU_texture_create_1d_ex("sss_tex_profile", material->sss_tex_profile = GPU_texture_create_1d("sss_tex_profile",
64, 64,
1, 1,
GPU_RGBA16F, GPU_RGBA16F,
GPU_TEXTURE_USAGE_SHADER_READ, GPU_TEXTURE_USAGE_SHADER_READ,
translucence_profile); translucence_profile);
MEM_freeN(translucence_profile); MEM_freeN(translucence_profile);

View File

@@ -286,97 +286,97 @@ static inline GPUTexture *gpu_texture_create(const char *name,
return reinterpret_cast<GPUTexture *>(tex); return reinterpret_cast<GPUTexture *>(tex);
} }
GPUTexture *GPU_texture_create_1d_ex(const char *name, GPUTexture *GPU_texture_create_1d(const char *name,
int w, int w,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const float *data) const float *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, 0, 0, GPU_TEXTURE_1D, mip_len, format, GPU_DATA_FLOAT, usage, data); name, w, 0, 0, GPU_TEXTURE_1D, mip_len, format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_1d_array_ex(const char *name, GPUTexture *GPU_texture_create_1d_array(const char *name,
int w, int w,
int h, int h,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const float *data) const float *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, h, 0, GPU_TEXTURE_1D_ARRAY, mip_len, format, GPU_DATA_FLOAT, usage, data); name, w, h, 0, GPU_TEXTURE_1D_ARRAY, mip_len, format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_2d_ex(const char *name, GPUTexture *GPU_texture_create_2d(const char *name,
int w, int w,
int h, int h,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const float *data) const float *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, h, 0, GPU_TEXTURE_2D, mip_len, format, GPU_DATA_FLOAT, usage, data); name, w, h, 0, GPU_TEXTURE_2D, mip_len, format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_2d_array_ex(const char *name, GPUTexture *GPU_texture_create_2d_array(const char *name,
int w, int w,
int h, int h,
int d, int d,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const float *data) const float *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, h, d, GPU_TEXTURE_2D_ARRAY, mip_len, format, GPU_DATA_FLOAT, usage, data); name, w, h, d, GPU_TEXTURE_2D_ARRAY, mip_len, format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_3d_ex(const char *name, GPUTexture *GPU_texture_create_3d(const char *name,
int w, int w,
int h, int h,
int d, int d,
int mip_len, int mip_len,
eGPUTextureFormat texture_format, eGPUTextureFormat texture_format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const void *data) const void *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, h, d, GPU_TEXTURE_3D, mip_len, texture_format, GPU_DATA_FLOAT, usage, data); name, w, h, d, GPU_TEXTURE_3D, mip_len, texture_format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_cube_ex(const char *name, GPUTexture *GPU_texture_create_cube(const char *name,
int w, int w,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const float *data) const float *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, w, 0, GPU_TEXTURE_CUBE, mip_len, format, GPU_DATA_FLOAT, usage, data); name, w, w, 0, GPU_TEXTURE_CUBE, mip_len, format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_cube_array_ex(const char *name, GPUTexture *GPU_texture_create_cube_array(const char *name,
int w, int w,
int d, int d,
int mip_len, int mip_len,
eGPUTextureFormat format, eGPUTextureFormat format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const float *data) const float *data)
{ {
return gpu_texture_create( return gpu_texture_create(
name, w, w, d, GPU_TEXTURE_CUBE_ARRAY, mip_len, format, GPU_DATA_FLOAT, usage, data); name, w, w, d, GPU_TEXTURE_CUBE_ARRAY, mip_len, format, GPU_DATA_FLOAT, usage, data);
} }
GPUTexture *GPU_texture_create_compressed_2d_ex(const char *name, GPUTexture *GPU_texture_create_compressed_2d(const char *name,
int w, int w,
int h, int h,
int miplen, int miplen,
eGPUTextureFormat tex_format, eGPUTextureFormat tex_format,
eGPUTextureUsage usage, eGPUTextureUsage usage,
const void *data) const void *data)
{ {
Texture *tex = GPUBackend::get()->texture_alloc(name); Texture *tex = GPUBackend::get()->texture_alloc(name);
bool success = tex->init_2D(w, h, 0, miplen, tex_format); bool success = tex->init_2D(w, h, 0, miplen, tex_format);

View File

@@ -126,9 +126,9 @@ static void gpu_viewport_textures_create(GPUViewport *viewport)
/* NOTE: dtxl_color texture requires write support as it may be written to by the realtime /* NOTE: dtxl_color texture requires write support as it may be written to by the realtime
* compositor. */ * compositor. */
viewport->color_render_tx[0] = GPU_texture_create_2d_ex( viewport->color_render_tx[0] = GPU_texture_create_2d(
"dtxl_color", UNPACK2(size), 1, GPU_RGBA16F, usage | GPU_TEXTURE_USAGE_SHADER_WRITE, NULL); "dtxl_color", UNPACK2(size), 1, GPU_RGBA16F, usage | GPU_TEXTURE_USAGE_SHADER_WRITE, NULL);
viewport->color_overlay_tx[0] = GPU_texture_create_2d_ex( viewport->color_overlay_tx[0] = GPU_texture_create_2d(
"dtxl_color_overlay", UNPACK2(size), 1, GPU_SRGB8_A8, usage, NULL); "dtxl_color_overlay", UNPACK2(size), 1, GPU_SRGB8_A8, usage, NULL);
if (GPU_clear_viewport_workaround()) { if (GPU_clear_viewport_workaround()) {
@@ -138,13 +138,13 @@ static void gpu_viewport_textures_create(GPUViewport *viewport)
} }
if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0 && viewport->color_render_tx[1] == NULL) { if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0 && viewport->color_render_tx[1] == NULL) {
viewport->color_render_tx[1] = GPU_texture_create_2d_ex("dtxl_color_stereo", viewport->color_render_tx[1] = GPU_texture_create_2d("dtxl_color_stereo",
UNPACK2(size), UNPACK2(size),
1, 1,
GPU_RGBA16F, GPU_RGBA16F,
usage | GPU_TEXTURE_USAGE_SHADER_WRITE, usage | GPU_TEXTURE_USAGE_SHADER_WRITE,
NULL); NULL);
viewport->color_overlay_tx[1] = GPU_texture_create_2d_ex( viewport->color_overlay_tx[1] = GPU_texture_create_2d(
"dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, usage, NULL); "dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, usage, NULL);
if (GPU_clear_viewport_workaround()) { if (GPU_clear_viewport_workaround()) {
@@ -156,12 +156,12 @@ static void gpu_viewport_textures_create(GPUViewport *viewport)
/* Can be shared with GPUOffscreen. */ /* Can be shared with GPUOffscreen. */
if (viewport->depth_tx == NULL) { if (viewport->depth_tx == NULL) {
/* Depth texture can be read back by gizmos #view3d_depths_create .*/ /* Depth texture can be read back by gizmos #view3d_depths_create .*/
viewport->depth_tx = GPU_texture_create_2d_ex("dtxl_depth", viewport->depth_tx = GPU_texture_create_2d("dtxl_depth",
UNPACK2(size), UNPACK2(size),
1, 1,
GPU_DEPTH24_STENCIL8, GPU_DEPTH24_STENCIL8,
usage | GPU_TEXTURE_USAGE_HOST_READ, usage | GPU_TEXTURE_USAGE_HOST_READ,
NULL); NULL);
if (GPU_clear_viewport_workaround()) { if (GPU_clear_viewport_workaround()) {
static int depth_clear = 0; static int depth_clear = 0;
GPU_texture_clear(viewport->depth_tx, GPU_DATA_UINT_24_8, &depth_clear); GPU_texture_clear(viewport->depth_tx, GPU_DATA_UINT_24_8, &depth_clear);

View File

@@ -106,7 +106,7 @@ void MTLContext::set_ghost_context(GHOST_ContextHandle ghostCtxHandle)
/* Add default texture for cases where no other framebuffer is bound */ /* Add default texture for cases where no other framebuffer is bound */
if (!default_fbo_gputexture_) { if (!default_fbo_gputexture_) {
default_fbo_gputexture_ = static_cast<gpu::MTLTexture *>(unwrap(GPU_texture_create_2d_ex( default_fbo_gputexture_ = static_cast<gpu::MTLTexture *>(unwrap(GPU_texture_create_2d(
__func__, 16, 16, 1, GPU_RGBA16F, GPU_TEXTURE_USAGE_GENERAL, nullptr))); __func__, 16, 16, 1, GPU_RGBA16F, GPU_TEXTURE_USAGE_GENERAL, nullptr)));
} }
mtl_back_left->add_color_attachment(default_fbo_gputexture_, 0, 0, 0); mtl_back_left->add_color_attachment(default_fbo_gputexture_, 0, 0, 0);
@@ -551,27 +551,25 @@ gpu::MTLTexture *MTLContext::get_dummy_texture(eGPUTextureType type,
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
switch (type) { switch (type) {
case GPU_TEXTURE_1D: case GPU_TEXTURE_1D:
tex = GPU_texture_create_1d_ex("Dummy 1D", 128, 1, format, usage, nullptr); tex = GPU_texture_create_1d("Dummy 1D", 128, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_1D_ARRAY: case GPU_TEXTURE_1D_ARRAY:
tex = GPU_texture_create_1d_array_ex("Dummy 1DArray", 128, 1, 1, format, usage, nullptr); tex = GPU_texture_create_1d_array("Dummy 1DArray", 128, 1, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_2D: case GPU_TEXTURE_2D:
tex = GPU_texture_create_2d_ex("Dummy 2D", 128, 128, 1, format, usage, nullptr); tex = GPU_texture_create_2d("Dummy 2D", 128, 128, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_2D_ARRAY: case GPU_TEXTURE_2D_ARRAY:
tex = GPU_texture_create_2d_array_ex( tex = GPU_texture_create_2d_array("Dummy 2DArray", 128, 128, 1, 1, format, usage, nullptr);
"Dummy 2DArray", 128, 128, 1, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_3D: case GPU_TEXTURE_3D:
tex = GPU_texture_create_3d_ex("Dummy 3D", 128, 128, 1, 1, format, usage, nullptr); tex = GPU_texture_create_3d("Dummy 3D", 128, 128, 1, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_CUBE: case GPU_TEXTURE_CUBE:
tex = GPU_texture_create_cube_ex("Dummy Cube", 128, 1, format, usage, nullptr); tex = GPU_texture_create_cube("Dummy Cube", 128, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_CUBE_ARRAY: case GPU_TEXTURE_CUBE_ARRAY:
tex = GPU_texture_create_cube_array_ex( tex = GPU_texture_create_cube_array("Dummy CubeArray", 128, 1, 1, format, usage, nullptr);
"Dummy CubeArray", 128, 1, 1, format, usage, nullptr);
break; break;
case GPU_TEXTURE_BUFFER: case GPU_TEXTURE_BUFFER:
if (!dummy_verts_[sampler_format]) { if (!dummy_verts_[sampler_format]) {

View File

@@ -513,14 +513,14 @@ void gpu::MTLTexture::update_sub_depth_2d(
} }
/* Push contents into an r32_tex and render contents to depth using a shader. */ /* Push contents into an r32_tex and render contents to depth using a shader. */
GPUTexture *r32_tex_tmp = GPU_texture_create_2d_ex("depth_intermediate_copy_tex", GPUTexture *r32_tex_tmp = GPU_texture_create_2d("depth_intermediate_copy_tex",
w_, w_,
h_, h_,
1, 1,
format, format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ |
GPU_TEXTURE_USAGE_ATTACHMENT, GPU_TEXTURE_USAGE_ATTACHMENT,
nullptr); nullptr);
GPU_texture_filter_mode(r32_tex_tmp, false); GPU_texture_filter_mode(r32_tex_tmp, false);
GPU_texture_wrap_mode(r32_tex_tmp, false, true); GPU_texture_wrap_mode(r32_tex_tmp, false, true);
gpu::MTLTexture *mtl_tex = static_cast<gpu::MTLTexture *>(unwrap(r32_tex_tmp)); gpu::MTLTexture *mtl_tex = static_cast<gpu::MTLTexture *>(unwrap(r32_tex_tmp));

View File

@@ -42,7 +42,7 @@ static void test_gpu_shader_compute_2d()
EXPECT_NE(shader, nullptr); EXPECT_NE(shader, nullptr);
/* Create texture to store result and attach to shader. */ /* Create texture to store result and attach to shader. */
GPUTexture *texture = GPU_texture_create_2d_ex( GPUTexture *texture = GPU_texture_create_2d(
"gpu_shader_compute_2d", SIZE, SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr); "gpu_shader_compute_2d", SIZE, SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
EXPECT_NE(texture, nullptr); EXPECT_NE(texture, nullptr);
@@ -88,7 +88,7 @@ static void test_gpu_shader_compute_1d()
EXPECT_NE(shader, nullptr); EXPECT_NE(shader, nullptr);
/* Construct Texture. */ /* Construct Texture. */
GPUTexture *texture = GPU_texture_create_1d_ex( GPUTexture *texture = GPU_texture_create_1d(
"gpu_shader_compute_1d", SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr); "gpu_shader_compute_1d", SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
EXPECT_NE(texture, nullptr); EXPECT_NE(texture, nullptr);
@@ -278,9 +278,9 @@ static void test_gpu_texture_read()
GPU_render_begin(); GPU_render_begin();
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ;
GPUTexture *rgba32u = GPU_texture_create_2d_ex("rgba32u", 1, 1, 1, GPU_RGBA32UI, usage, nullptr); GPUTexture *rgba32u = GPU_texture_create_2d("rgba32u", 1, 1, 1, GPU_RGBA32UI, usage, nullptr);
GPUTexture *rgba16u = GPU_texture_create_2d_ex("rgba16u", 1, 1, 1, GPU_RGBA16UI, usage, nullptr); GPUTexture *rgba16u = GPU_texture_create_2d("rgba16u", 1, 1, 1, GPU_RGBA16UI, usage, nullptr);
GPUTexture *rgba32f = GPU_texture_create_2d_ex("rgba32f", 1, 1, 1, GPU_RGBA32F, usage, nullptr); GPUTexture *rgba32f = GPU_texture_create_2d("rgba32f", 1, 1, 1, GPU_RGBA32F, usage, nullptr);
const float4 fcol = {0.0f, 1.3f, -231.0f, 1000.0f}; const float4 fcol = {0.0f, 1.3f, -231.0f, 1000.0f};
const uint4 ucol = {0, 1, 2, 12223}; const uint4 ucol = {0, 1, 2, 12223};
@@ -432,7 +432,7 @@ static void gpu_shader_lib_test(const char *test_src_name, const char *additiona
int test_output_px_len = divide_ceil_u(sizeof(TestOutput), 4 * 4); int test_output_px_len = divide_ceil_u(sizeof(TestOutput), 4 * 4);
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ;
GPUTexture *tex = GPU_texture_create_2d_ex( GPUTexture *tex = GPU_texture_create_2d(
"tx", test_output_px_len, test_count, 1, GPU_RGBA32UI, usage, nullptr); "tx", test_output_px_len, test_count, 1, GPU_RGBA32UI, usage, nullptr);
GPUFrameBuffer *fb = GPU_framebuffer_create("test_fb"); GPUFrameBuffer *fb = GPU_framebuffer_create("test_fb");
GPU_framebuffer_ensure_config(&fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(tex)}); GPU_framebuffer_ensure_config(&fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(tex)});

View File

@@ -252,25 +252,24 @@ GPUTexture *IMB_touch_gpu_texture(const char *name,
GPUTexture *tex; GPUTexture *tex;
if (layers > 0) { if (layers > 0) {
tex = GPU_texture_create_2d_array_ex(name, tex = GPU_texture_create_2d_array(name,
w, w,
h, h,
layers, layers,
9999, 9999,
tex_format, tex_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
NULL); NULL);
} }
else { else {
tex = GPU_texture_create_2d_ex(name, tex = GPU_texture_create_2d(name,
w, w,
h, h,
9999, 9999,
tex_format, tex_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, NULL);
NULL);
} }
GPU_texture_swizzle_set(tex, imb_gpu_get_swizzle(ibuf)); GPU_texture_swizzle_set(tex, imb_gpu_get_swizzle(ibuf));
@@ -340,13 +339,13 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
fprintf(stderr, "Unable to load non-power-of-two DXT image resolution,"); fprintf(stderr, "Unable to load non-power-of-two DXT image resolution,");
} }
else { else {
tex = GPU_texture_create_compressed_2d_ex(name, tex = GPU_texture_create_compressed_2d(name,
ibuf->x, ibuf->x,
ibuf->y, ibuf->y,
ibuf->dds_data.nummipmaps, ibuf->dds_data.nummipmaps,
compressed_format, compressed_format,
GPU_TEXTURE_USAGE_GENERAL, GPU_TEXTURE_USAGE_GENERAL,
ibuf->dds_data.data); ibuf->dds_data.data);
if (tex != NULL) { if (tex != NULL) {
return tex; return tex;
@@ -366,23 +365,21 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
bool freebuf = false; bool freebuf = false;
/* Create Texture. */ /* Create Texture. */
tex = GPU_texture_create_2d_ex(name, tex = GPU_texture_create_2d(name,
UNPACK2(size), UNPACK2(size),
9999, 9999,
tex_format, tex_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, NULL);
NULL);
if (tex == NULL) { if (tex == NULL) {
size[0] = max_ii(1, size[0] / 2); size[0] = max_ii(1, size[0] / 2);
size[1] = max_ii(1, size[1] / 2); size[1] = max_ii(1, size[1] / 2);
tex = GPU_texture_create_2d_ex(name, tex = GPU_texture_create_2d(name,
UNPACK2(size), UNPACK2(size),
9999, 9999,
tex_format, tex_format,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, NULL);
NULL);
do_rescale = true; do_rescale = true;
} }
BLI_assert(tex != NULL); BLI_assert(tex != NULL);

View File

@@ -207,35 +207,34 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
if (is_cubemap) { if (is_cubemap) {
if (layers) { if (layers) {
tex = GPU_texture_create_cube_array_ex( tex = GPU_texture_create_cube_array(
name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data); name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data);
} }
else { else {
tex = GPU_texture_create_cube_ex( tex = GPU_texture_create_cube(
name, size[0], 1, pygpu_textureformat.value_found, usage, data); name, size[0], 1, pygpu_textureformat.value_found, usage, data);
} }
} }
else if (layers) { else if (layers) {
if (len == 2) { if (len == 2) {
tex = GPU_texture_create_2d_array_ex( tex = GPU_texture_create_2d_array(
name, size[0], size[1], layers, 1, pygpu_textureformat.value_found, usage, data); name, size[0], size[1], layers, 1, pygpu_textureformat.value_found, usage, data);
} }
else { else {
tex = GPU_texture_create_1d_array_ex( tex = GPU_texture_create_1d_array(
name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data); name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data);
} }
} }
else if (len == 3) { else if (len == 3) {
tex = GPU_texture_create_3d_ex( tex = GPU_texture_create_3d(
name, size[0], size[1], size[2], 1, pygpu_textureformat.value_found, usage, data); name, size[0], size[1], size[2], 1, pygpu_textureformat.value_found, usage, data);
} }
else if (len == 2) { else if (len == 2) {
tex = GPU_texture_create_2d_ex( tex = GPU_texture_create_2d(
name, size[0], size[1], 1, pygpu_textureformat.value_found, usage, data); name, size[0], size[1], 1, pygpu_textureformat.value_found, usage, data);
} }
else { else {
tex = GPU_texture_create_1d_ex( tex = GPU_texture_create_1d(name, size[0], 1, pygpu_textureformat.value_found, usage, data);
name, size[0], 1, pygpu_textureformat.value_found, usage, data);
} }
} }

View File

@@ -232,7 +232,7 @@ static void wm_software_cursor_draw_bitmap(const int event_xy[2],
float gl_matrix[4][4]; float gl_matrix[4][4];
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL; eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
GPUTexture *texture = GPU_texture_create_2d_ex( GPUTexture *texture = GPU_texture_create_2d(
"softeare_cursor", bitmap->data_size[0], bitmap->data_size[1], 1, GPU_RGBA8, usage, NULL); "softeare_cursor", bitmap->data_size[0], bitmap->data_size[1], 1, GPU_RGBA8, usage, NULL);
GPU_texture_update(texture, GPU_DATA_UBYTE, bitmap->data); GPU_texture_update(texture, GPU_DATA_UBYTE, bitmap->data);
GPU_texture_filter_mode(texture, false); GPU_texture_filter_mode(texture, false);

View File

@@ -2306,14 +2306,14 @@ static void radial_control_set_tex(RadialControl *rc)
rc->use_secondary_tex, rc->use_secondary_tex,
!ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) { !ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) {
rc->texture = GPU_texture_create_2d_ex("radial_control", rc->texture = GPU_texture_create_2d("radial_control",
ibuf->x, ibuf->x,
ibuf->y, ibuf->y,
1, 1,
GPU_R8, GPU_R8,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_READ |
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW, GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
ibuf->rect_float); ibuf->rect_float);
GPU_texture_filter_mode(rc->texture, true); GPU_texture_filter_mode(rc->texture, true);
GPU_texture_swizzle_set(rc->texture, "111r"); GPU_texture_swizzle_set(rc->texture, "111r");

View File

@@ -477,7 +477,7 @@ static void draw_display_buffer(PlayState *ps, ImBuf *ibuf)
void *buffer_cache_handle = NULL; void *buffer_cache_handle = NULL;
display_buffer = ocio_transform_ibuf(ps, ibuf, &glsl_used, &format, &data, &buffer_cache_handle); display_buffer = ocio_transform_ibuf(ps, ibuf, &glsl_used, &format, &data, &buffer_cache_handle);
GPUTexture *texture = GPU_texture_create_2d_ex( GPUTexture *texture = GPU_texture_create_2d(
"display_buf", ibuf->x, ibuf->y, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, NULL); "display_buf", ibuf->x, ibuf->y, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
GPU_texture_update(texture, data, display_buffer); GPU_texture_update(texture, data, display_buffer);
GPU_texture_filter_mode(texture, false); GPU_texture_filter_mode(texture, false);