GPUTexture: Replace GL textarget enum by Image enum
This commit is contained in:
parent
025dc31d28
commit
487eaeed7e
Notes:
blender-bot
2023-02-14 10:35:28 +01:00
Referenced by issue #79306, DRW: small issues with yesterday commits modifying TEXTARGET
|
@ -63,7 +63,7 @@ static struct GPUTexture *gpencil_image_texture_get(Image *image, bool *r_alpha_
|
|||
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
||||
|
||||
if (ibuf != NULL && ibuf->rect != NULL) {
|
||||
gpu_tex = GPU_texture_from_blender(image, &iuser, ibuf, GL_TEXTURE_2D);
|
||||
gpu_tex = GPU_texture_from_blender(image, &iuser, ibuf, TEXTARGET_TEXTURE_2D);
|
||||
*r_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL);
|
||||
}
|
||||
BKE_image_release_ibuf(image, ibuf, lock);
|
||||
|
|
|
@ -175,7 +175,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
|
|||
}
|
||||
width = ibuf->x;
|
||||
height = ibuf->y;
|
||||
tex = GPU_texture_from_blender(image, iuser, ibuf, GL_TEXTURE_2D);
|
||||
tex = GPU_texture_from_blender(image, iuser, ibuf, TEXTARGET_TEXTURE_2D);
|
||||
BKE_image_release_ibuf(image, ibuf, lock);
|
||||
iuser->scene = NULL;
|
||||
|
||||
|
@ -203,7 +203,7 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp
|
|||
}
|
||||
|
||||
BKE_movieclip_user_set_frame(&bgpic->cuser, ctime);
|
||||
tex = GPU_texture_from_movieclip(clip, &bgpic->cuser, GL_TEXTURE_2D);
|
||||
tex = GPU_texture_from_movieclip(clip, &bgpic->cuser, TEXTARGET_TEXTURE_2D);
|
||||
if (tex == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
if (ima != NULL) {
|
||||
ImageUser iuser = *ob->iuser;
|
||||
camera_background_images_stereo_setup(draw_ctx->scene, draw_ctx->v3d, ima, &iuser);
|
||||
tex = GPU_texture_from_blender(ima, &iuser, NULL, GL_TEXTURE_2D);
|
||||
tex = GPU_texture_from_blender(ima, &iuser, NULL, TEXTARGET_TEXTURE_2D);
|
||||
if (tex) {
|
||||
size[0] = GPU_texture_orig_width(tex);
|
||||
size[1] = GPU_texture_orig_height(tex);
|
||||
|
|
|
@ -136,7 +136,8 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata)
|
|||
state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA;
|
||||
DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state);
|
||||
|
||||
GPUTexture *tex = GPU_texture_from_blender(imapaint->stencil, NULL, NULL, GL_TEXTURE_2D);
|
||||
GPUTexture *tex = GPU_texture_from_blender(
|
||||
imapaint->stencil, NULL, NULL, TEXTARGET_TEXTURE_2D);
|
||||
|
||||
const bool mask_premult = (imapaint->stencil->alpha_mode == IMA_ALPHA_PREMUL);
|
||||
const bool mask_inverted = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0;
|
||||
|
|
|
@ -261,11 +261,11 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
|
|||
|
||||
if (ima) {
|
||||
if (ima->source == IMA_SRC_TILED) {
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_2D_ARRAY);
|
||||
tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_1D_ARRAY);
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TEXTURE_2D_ARRAY);
|
||||
tex_tile_data = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TEXTURE_TILE_MAPPING);
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, GL_TEXTURE_2D);
|
||||
tex = GPU_texture_from_blender(ima, iuser, NULL, TEXTARGET_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1186,8 +1186,21 @@ GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat tex_format, const GLuint
|
|||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode)
|
||||
static GLenum convert_target_to_gl(int target)
|
||||
{
|
||||
static const GLenum table[] = {
|
||||
[TEXTARGET_TEXTURE_2D] = GL_TEXTURE_2D,
|
||||
[TEXTARGET_TEXTURE_CUBE_MAP] = GL_TEXTURE_CUBE_MAP,
|
||||
[TEXTARGET_TEXTURE_2D_ARRAY] = GL_TEXTURE_2D_ARRAY,
|
||||
[TEXTARGET_TEXTURE_TILE_MAPPING] = GL_TEXTURE_1D_ARRAY,
|
||||
};
|
||||
return table[target];
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_from_bindcode(int target, int bindcode)
|
||||
{
|
||||
GLenum textarget = convert_target_to_gl(target);
|
||||
|
||||
GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture");
|
||||
tex->bindcode = bindcode;
|
||||
tex->refcount = 1;
|
||||
|
|
|
@ -182,23 +182,14 @@ float GPU_get_anisotropic(void)
|
|||
return GTS.anisotropic;
|
||||
}
|
||||
|
||||
/* Set OpenGL state for an MTFace */
|
||||
|
||||
static GPUTexture **gpu_get_image_gputexture(Image *ima, GLenum textarget, const int multiview_eye)
|
||||
static GPUTexture **gpu_get_image_gputexture(Image *ima, int textarget, const int multiview_eye)
|
||||
{
|
||||
if (textarget == GL_TEXTURE_2D) {
|
||||
return &(ima->gputexture[TEXTARGET_TEXTURE_2D][multiview_eye]);
|
||||
}
|
||||
else if (textarget == GL_TEXTURE_CUBE_MAP) {
|
||||
return &(ima->gputexture[TEXTARGET_TEXTURE_CUBE_MAP][multiview_eye]);
|
||||
}
|
||||
else if (textarget == GL_TEXTURE_2D_ARRAY) {
|
||||
return &(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][multiview_eye]);
|
||||
}
|
||||
else if (textarget == GL_TEXTURE_1D_ARRAY) {
|
||||
return &(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][multiview_eye]);
|
||||
}
|
||||
const bool in_range = (textarget >= 0) && (textarget < TEXTARGET_COUNT);
|
||||
BLI_assert(in_range);
|
||||
|
||||
if (in_range) {
|
||||
return &(ima->gputexture[textarget][multiview_eye]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -895,10 +886,10 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf,
|
|||
}
|
||||
}
|
||||
|
||||
if (textarget == GL_TEXTURE_2D_ARRAY) {
|
||||
if (textarget == TEXTARGET_TEXTURE_2D_ARRAY) {
|
||||
bindcode = gpu_texture_create_tile_array(ima, ibuf_intern);
|
||||
}
|
||||
else if (textarget == GL_TEXTURE_1D_ARRAY) {
|
||||
else if (textarget == TEXTARGET_TEXTURE_TILE_MAPPING) {
|
||||
bindcode = gpu_texture_create_tile_mapping(ima, iuser ? iuser->multiview_eye : 0);
|
||||
}
|
||||
else {
|
||||
|
@ -914,7 +905,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf,
|
|||
|
||||
GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
|
||||
|
||||
if (textarget == GL_TEXTURE_1D_ARRAY) {
|
||||
if (textarget == TEXTARGET_TEXTURE_TILE_MAPPING) {
|
||||
/* Special for tile mapping. */
|
||||
GPU_texture_mipmap_mode(*tex, false, false);
|
||||
}
|
||||
|
|
|
@ -119,10 +119,10 @@ typedef struct ImageTile {
|
|||
|
||||
enum {
|
||||
TEXTARGET_TEXTURE_2D = 0,
|
||||
TEXTARGET_TEXTURE_CUBE_MAP = 1,
|
||||
TEXTARGET_TEXTURE_2D_ARRAY = 2,
|
||||
TEXTARGET_TEXTURE_TILE_MAPPING = 3,
|
||||
TEXTARGET_COUNT = 4,
|
||||
TEXTARGET_TEXTURE_CUBE_MAP,
|
||||
TEXTARGET_TEXTURE_2D_ARRAY,
|
||||
TEXTARGET_TEXTURE_TILE_MAPPING,
|
||||
TEXTARGET_COUNT,
|
||||
};
|
||||
|
||||
typedef struct Image {
|
||||
|
|
|
@ -222,19 +222,20 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame)
|
|||
BKE_imageuser_default(&iuser);
|
||||
iuser.framenr = frame;
|
||||
|
||||
GPUTexture *tex = GPU_texture_from_blender(image, &iuser, NULL, GL_TEXTURE_2D);
|
||||
GPUTexture *tex = GPU_texture_from_blender(image, &iuser, NULL, TEXTARGET_TEXTURE_2D);
|
||||
|
||||
if (tex == NULL) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Failed to load image texture '%s'", image->id.name + 2);
|
||||
return (int)GL_INVALID_OPERATION;
|
||||
/* TODO(fclem) this error code makes no sense for vulkan. */
|
||||
return 0x0502; /* GL_INVALID_OPERATION */
|
||||
}
|
||||
|
||||
return GL_NO_ERROR;
|
||||
return 0; /* GL_NO_ERROR */
|
||||
}
|
||||
|
||||
static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame)
|
||||
{
|
||||
int error = GL_NO_ERROR;
|
||||
int error = 0; /* GL_NO_ERROR */
|
||||
|
||||
BKE_image_tag_time(image);
|
||||
|
||||
|
|
Loading…
Reference in New Issue