#99807: Add support for exporting to USDZ - ultimate fixes #105185
|
@ -216,8 +216,13 @@ class DisplayGPUTexture {
|
|||
height = texture_height;
|
||||
|
||||
/* Texture must have a minimum size of 1x1. */
|
||||
gpu_texture = GPU_texture_create_2d(
|
||||
"CyclesBlitTexture", max(width, 1), max(height, 1), 1, GPU_RGBA16F, nullptr);
|
||||
gpu_texture = GPU_texture_create_2d("CyclesBlitTexture",
|
||||
max(width, 1),
|
||||
max(height, 1),
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_GENERAL,
|
||||
nullptr);
|
||||
|
||||
if (!gpu_texture) {
|
||||
LOG(ERROR) << "Error creating texture.";
|
||||
|
@ -700,14 +705,14 @@ static void draw_tile(const float2 &zoom,
|
|||
const float zoomed_height = draw_tile.params.size.y * zoom.y;
|
||||
if (texture.width != draw_tile.params.size.x || texture.height != draw_tile.params.size.y) {
|
||||
/* Resolution divider is different from 1, force nearest interpolation. */
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0, false);
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0);
|
||||
}
|
||||
else if (zoomed_width - draw_tile.params.size.x > 0.5f ||
|
||||
zoomed_height - draw_tile.params.size.y > 0.5f) {
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0, false);
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0);
|
||||
}
|
||||
else {
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_FILTER, 0, false);
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_FILTER, 0);
|
||||
}
|
||||
|
||||
/* Draw at the parameters for which the texture has been updated for. This allows to always draw
|
||||
|
|
|
@ -116,7 +116,9 @@ class MetalDevice : public Device {
|
|||
|
||||
bool use_local_atomic_sort() const;
|
||||
|
||||
string preprocess_source(MetalPipelineType pso_type, const uint kernel_features, string* source = nullptr);
|
||||
string preprocess_source(MetalPipelineType pso_type,
|
||||
const uint kernel_features,
|
||||
string *source = nullptr);
|
||||
|
||||
bool make_source_and_check_if_compile_needed(MetalPipelineType pso_type);
|
||||
|
||||
|
|
|
@ -310,7 +310,9 @@ bool MetalDevice::use_local_atomic_sort() const
|
|||
return DebugFlags().metal.use_local_atomic_sort;
|
||||
}
|
||||
|
||||
string MetalDevice::preprocess_source(MetalPipelineType pso_type, const uint kernel_features, string* source)
|
||||
string MetalDevice::preprocess_source(MetalPipelineType pso_type,
|
||||
const uint kernel_features,
|
||||
string *source)
|
||||
{
|
||||
string global_defines;
|
||||
if (use_adaptive_compilation()) {
|
||||
|
@ -362,18 +364,18 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type, const uint ker
|
|||
const double starttime = time_dt();
|
||||
|
||||
# define KERNEL_STRUCT_BEGIN(name, parent) \
|
||||
string_replace_same_length(*source, "kernel_data." #parent ".", "kernel_data_" #parent "_");
|
||||
string_replace_same_length(*source, "kernel_data." #parent ".", "kernel_data_" #parent "_");
|
||||
|
||||
bool next_member_is_specialized = true;
|
||||
|
||||
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE next_member_is_specialized = false;
|
||||
|
||||
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
|
||||
if (!next_member_is_specialized) { \
|
||||
string_replace( \
|
||||
*source, "kernel_data_" #parent "_" #name, "kernel_data." #parent ".__unused_" #name); \
|
||||
next_member_is_specialized = true; \
|
||||
}
|
||||
if (!next_member_is_specialized) { \
|
||||
string_replace( \
|
||||
*source, "kernel_data_" #parent "_" #name, "kernel_data." #parent ".__unused_" #name); \
|
||||
next_member_is_specialized = true; \
|
||||
}
|
||||
|
||||
# include "kernel/data_template.h"
|
||||
|
||||
|
@ -411,7 +413,7 @@ void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_feat
|
|||
string &source = this->source[pso_type];
|
||||
source = "\n#include \"kernel/device/metal/kernel.metal\"\n";
|
||||
source = path_source_replace_includes(source, path_get("source"));
|
||||
|
||||
|
||||
/* Perform any required specialization on the source.
|
||||
* With Metal function constants we can generate a single variant of the kernel source which can
|
||||
* be repeatedly respecialized.
|
||||
|
@ -463,7 +465,8 @@ bool MetalDevice::make_source_and_check_if_compile_needed(MetalPipelineType pso_
|
|||
|
||||
# define KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE next_member_is_specialized = false;
|
||||
|
||||
/* Add specialization constants to md5 so that 'get_best_pipeline' is able to return a suitable match. */
|
||||
/* Add specialization constants to md5 so that 'get_best_pipeline' is able to return a suitable
|
||||
* match. */
|
||||
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
|
||||
if (next_member_is_specialized) { \
|
||||
constant_values += string(#parent "." #name "=") + \
|
||||
|
@ -919,6 +922,11 @@ void MetalDevice::cancel()
|
|||
|
||||
bool MetalDevice::is_ready(string &status) const
|
||||
{
|
||||
if (!error_msg.empty()) {
|
||||
/* Avoid hanging if we had an error. */
|
||||
return true;
|
||||
}
|
||||
|
||||
int num_loaded = MetalDeviceKernels::get_loaded_kernel_count(this, PSO_GENERIC);
|
||||
if (num_loaded < DEVICE_KERNEL_NUM) {
|
||||
status = string_printf("%d / %d render kernels loaded (may take a few minutes the first time)",
|
||||
|
|
|
@ -428,11 +428,12 @@ bool MetalKernelPipeline::should_use_binary_archive() const
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Workaround for Intel GPU having issue using Binary Archives */
|
||||
MetalGPUVendor gpu_vendor = MetalInfo::get_device_vendor(mtlDevice);
|
||||
if (gpu_vendor == METAL_GPU_INTEL) {
|
||||
return false;
|
||||
else {
|
||||
/* Workaround for issues using Binary Archives on non-Apple Silicon systems. */
|
||||
MetalGPUVendor gpu_vendor = MetalInfo::get_device_vendor(mtlDevice);
|
||||
if (gpu_vendor != METAL_GPU_APPLE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pso_type == PSO_GENERIC) {
|
||||
|
@ -440,8 +441,10 @@ bool MetalKernelPipeline::should_use_binary_archive() const
|
|||
return true;
|
||||
}
|
||||
|
||||
if (device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND &&
|
||||
device_kernel <= DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW) {
|
||||
if ((device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND &&
|
||||
device_kernel <= DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW) ||
|
||||
(device_kernel >= DEVICE_KERNEL_SHADER_EVAL_DISPLACE &&
|
||||
device_kernel <= DEVICE_KERNEL_SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY)) {
|
||||
/* Archive all shade kernels - they take a long time to compile. */
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -215,11 +215,8 @@ class GHOST_IWindow {
|
|||
* Needs to be called after each swap events as the framebuffer will change.
|
||||
* \return A boolean success indicator.
|
||||
*/
|
||||
virtual GHOST_TSuccess getVulkanBackbuffer(void *image,
|
||||
void *framebuffer,
|
||||
void *render_pass,
|
||||
void *extent,
|
||||
uint32_t *fb_id) = 0;
|
||||
virtual GHOST_TSuccess getVulkanBackbuffer(
|
||||
void *image, void *framebuffer, void *render_pass, void *extent, uint32_t *fb_id) = 0;
|
||||
|
||||
/**
|
||||
* Invalidates the contents of this window.
|
||||
|
|
|
@ -107,14 +107,10 @@ uint GHOST_Window::getDefaultFramebuffer()
|
|||
return (m_context) ? m_context->getDefaultFramebuffer() : 0;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::getVulkanBackbuffer(void *image,
|
||||
void *framebuffer,
|
||||
void *render_pass,
|
||||
void *extent,
|
||||
uint32_t *fb_id)
|
||||
GHOST_TSuccess GHOST_Window::getVulkanBackbuffer(
|
||||
void *image, void *framebuffer, void *render_pass, void *extent, uint32_t *fb_id)
|
||||
{
|
||||
return m_context->getVulkanBackbuffer(
|
||||
image, framebuffer, render_pass, extent, fb_id);
|
||||
return m_context->getVulkanBackbuffer(image, framebuffer, render_pass, extent, fb_id);
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_Window::activateDrawingContext()
|
||||
|
|
|
@ -337,11 +337,11 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
|
|||
* It depends on more than height. So check instead by looking at the source. */
|
||||
std::string sampler1D_name = std::string("sampler1D ") + sampler_name;
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (lut.texture == nullptr) {
|
||||
|
@ -374,15 +374,14 @@ static bool addGPULut3D(OCIO_GPUTextures &textures,
|
|||
}
|
||||
|
||||
OCIO_GPULutTexture lut;
|
||||
lut.texture = GPU_texture_create_3d_ex(texture_name,
|
||||
edgelen,
|
||||
edgelen,
|
||||
edgelen,
|
||||
1,
|
||||
GPU_RGB16F,
|
||||
GPU_DATA_FLOAT,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
values);
|
||||
lut.texture = GPU_texture_create_3d(texture_name,
|
||||
edgelen,
|
||||
edgelen,
|
||||
edgelen,
|
||||
1,
|
||||
GPU_RGB16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
values);
|
||||
if (lut.texture == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -451,7 +450,7 @@ static bool createGPUCurveMapping(OCIO_GPUCurveMappping &curvemap,
|
|||
if (curve_mapping_settings) {
|
||||
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);
|
||||
GPU_texture_filter_mode(curvemap.texture, false);
|
||||
GPU_texture_wrap_mode(curvemap.texture, false, true);
|
||||
|
|
|
@ -1408,6 +1408,7 @@ class _defs_sculpt:
|
|||
def draw_settings(_context, layout, tool):
|
||||
props = tool.operator_properties("sculpt.trim_box_gesture")
|
||||
layout.prop(props, "trim_mode", expand=False)
|
||||
layout.prop(props, "trim_orientation", expand=False)
|
||||
layout.prop(props, "trim_extrude_mode", expand=False)
|
||||
layout.prop(props, "use_cursor_depth", expand=False)
|
||||
return dict(
|
||||
|
|
|
@ -1199,7 +1199,7 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x,
|
|||
if (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);
|
||||
|
||||
gc->bitmap_len_landed = 0;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
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);
|
||||
GPU_texture_mipmap_mode(tex, false, false);
|
||||
|
||||
|
@ -241,7 +241,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
|
|||
}
|
||||
|
||||
if (GPU_mipmap_enabled()) {
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
GPU_texture_mipmap_mode(tex, true, true);
|
||||
if (ima) {
|
||||
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
|
||||
|
@ -423,7 +423,7 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
|
|||
GPU_texture_wrap_mode(*tex, true, false);
|
||||
|
||||
if (GPU_mipmap_enabled()) {
|
||||
GPU_texture_generate_mipmap(*tex);
|
||||
GPU_texture_update_mipmap_chain(*tex);
|
||||
if (ima) {
|
||||
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
|
|||
}
|
||||
|
||||
if (*tex) {
|
||||
GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
|
||||
GPU_texture_original_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
|
||||
}
|
||||
|
||||
if (ibuf != ibuf_intern) {
|
||||
|
@ -820,7 +820,7 @@ static void gpu_texture_update_from_ibuf(
|
|||
}
|
||||
|
||||
if (GPU_mipmap_enabled()) {
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
}
|
||||
else {
|
||||
ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
|
||||
|
|
|
@ -478,13 +478,13 @@ static void studiolight_create_equirect_radiance_gputexture(StudioLight *sl)
|
|||
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED);
|
||||
ImBuf *ibuf = sl->equirect_radiance_buffer;
|
||||
|
||||
sl->equirect_radiance_gputexture = GPU_texture_create_2d_ex("studiolight_radiance",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
ibuf->rect_float);
|
||||
sl->equirect_radiance_gputexture = GPU_texture_create_2d("studiolight_radiance",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
ibuf->rect_float);
|
||||
GPUTexture *tex = sl->equirect_radiance_gputexture;
|
||||
GPU_texture_filter_mode(tex, 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);
|
||||
}
|
||||
|
||||
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);
|
||||
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) {
|
||||
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED);
|
||||
ImBuf *ibuf = sl->equirect_irradiance_buffer;
|
||||
sl->equirect_irradiance_gputexture = GPU_texture_create_2d_ex("studiolight_irradiance",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
ibuf->rect_float);
|
||||
sl->equirect_irradiance_gputexture = GPU_texture_create_2d("studiolight_irradiance",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
ibuf->rect_float);
|
||||
GPUTexture *tex = sl->equirect_irradiance_gputexture;
|
||||
GPU_texture_filter_mode(tex, true);
|
||||
GPU_texture_wrap_mode(tex, true, true);
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
|
||||
/* Extended file attribute used by OneDrive to mark placeholder files. */
|
||||
static const char *ONEDRIVE_RECALLONOPEN_ATTRIBUTE = "com.microsoft.OneDrive.RecallOnOpen";
|
||||
|
||||
|
@ -188,22 +187,24 @@ const char *BLI_expand_tilde(const char *path_with_tilde)
|
|||
return path_expanded;
|
||||
}
|
||||
|
||||
char *BLI_current_working_dir(char *dir, const size_t maxncpy) {
|
||||
char *BLI_current_working_dir(char *dir, const size_t maxncpy)
|
||||
{
|
||||
/* Can't just copy to the *dir pointer, as [path getCString gets grumpy.*/
|
||||
static char path_expanded[PATH_MAX];
|
||||
char path_expanded[PATH_MAX];
|
||||
@autoreleasepool {
|
||||
NSString *path = [[NSFileManager defaultManager] currentDirectoryPath];
|
||||
const size_t length = maxncpy > PATH_MAX ? PATH_MAX : maxncpy;
|
||||
[path getCString:path_expanded maxLength:length encoding:NSUTF8StringEncoding];
|
||||
BLI_strncpy(dir, path_expanded, maxncpy);
|
||||
return path_expanded;
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
bool BLI_change_working_dir(const char* dir) {
|
||||
bool BLI_change_working_dir(const char *dir)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString* path = [[NSString alloc] initWithUTF8String: dir];
|
||||
if ([[NSFileManager defaultManager] changeCurrentDirectoryPath: path] == YES) {
|
||||
NSString *path = [[NSString alloc] initWithUTF8String:dir];
|
||||
if ([[NSFileManager defaultManager] changeCurrentDirectoryPath:path] == YES) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -12,6 +12,12 @@ class ChangeWorkingDirectoryTest : public testing::Test {
|
|||
public:
|
||||
std::string test_temp_dir;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
/* Must use because BLI_change_working_dir() checks that we are on the main thread. */
|
||||
BLI_threadapi_init();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
if (!test_temp_dir.empty()) {
|
||||
|
@ -55,13 +61,15 @@ TEST(fileops, fstream_open_charptr_filename)
|
|||
|
||||
TEST_F(ChangeWorkingDirectoryTest, change_working_directory)
|
||||
{
|
||||
/* Must use because BLI_change_working_dir() checks that we are on the main thread. */
|
||||
BLI_threadapi_init();
|
||||
char original_cwd_buff[FILE_MAX];
|
||||
char *original_cwd = BLI_current_working_dir(original_cwd_buff, sizeof(original_cwd_buff));
|
||||
|
||||
char original_wd[FILE_MAX];
|
||||
if (!BLI_current_working_dir(original_wd, FILE_MAX)) {
|
||||
FAIL() << "unable to get the current working directory";
|
||||
}
|
||||
ASSERT_FALSE(original_cwd == nullptr) << "Unable to get the current working directory.";
|
||||
/* While some implementation of `getcwd` (or similar) may return allocated memory in some cases,
|
||||
* in the context of `BLI_current_working_dir` usages, this is not expected and should not
|
||||
* happen. */
|
||||
ASSERT_TRUE(original_cwd == original_cwd_buff)
|
||||
<< "Returned CWD path unexpectedly different than given char buffer.";
|
||||
|
||||
std::string temp_file_name(std::tmpnam(nullptr));
|
||||
test_temp_dir = temp_file_name + "_новый";
|
||||
|
@ -79,24 +87,34 @@ TEST_F(ChangeWorkingDirectoryTest, change_working_directory)
|
|||
ASSERT_TRUE(BLI_change_working_dir(test_temp_dir.c_str()))
|
||||
<< "temporary directory should succeed changing directory.";
|
||||
|
||||
char cwd[FILE_MAX];
|
||||
if (!BLI_current_working_dir(cwd, FILE_MAX)) {
|
||||
FAIL() << "unable to get the current working directory";
|
||||
}
|
||||
char new_cwd_buff[FILE_MAX];
|
||||
char *new_cwd = BLI_current_working_dir(new_cwd_buff, sizeof(new_cwd_buff));
|
||||
ASSERT_FALSE(new_cwd == nullptr) << "Unable to get the current working directory.";
|
||||
ASSERT_TRUE(new_cwd == new_cwd_buff)
|
||||
<< "Returned CWD path unexpectedly different than given char buffer.";
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* The name returned by std::tmpnam is fine but the Apple OS method
|
||||
* picks the true var folder, not the alias, meaning the below
|
||||
* comparison always fails unless we prepend with the correct value. */
|
||||
test_temp_dir = "/private" + test_temp_dir;
|
||||
#endif // #ifdef __APPLE__
|
||||
#endif // #ifdef __APPLE__
|
||||
|
||||
ASSERT_EQ(BLI_path_cmp_normalized(cwd, test_temp_dir.c_str()), 0)
|
||||
ASSERT_EQ(BLI_path_cmp_normalized(new_cwd, test_temp_dir.c_str()), 0)
|
||||
<< "the path of the current working directory should equal the path of the temporary "
|
||||
"directory that was created.";
|
||||
|
||||
ASSERT_TRUE(BLI_change_working_dir(original_wd))
|
||||
ASSERT_TRUE(BLI_change_working_dir(original_cwd))
|
||||
<< "changing directory back to the original working directory should succeed.";
|
||||
|
||||
char final_cwd_buff[FILE_MAX];
|
||||
char *final_cwd = BLI_current_working_dir(final_cwd_buff, sizeof(final_cwd_buff));
|
||||
ASSERT_FALSE(final_cwd == nullptr) << "Unable to get the current working directory.";
|
||||
ASSERT_TRUE(final_cwd == final_cwd_buff)
|
||||
<< "Returned CWD path unexpectedly different than given char buffer.";
|
||||
|
||||
ASSERT_EQ(BLI_path_cmp_normalized(final_cwd, original_cwd), 0)
|
||||
<< "The final CWD path should be the same as the original CWD path.";
|
||||
}
|
||||
|
||||
} // namespace blender::tests
|
||||
|
|
|
@ -85,7 +85,8 @@ void MorphologicalDistanceFeatherWeights::compute_weights(int radius)
|
|||
weights[i] /= sum;
|
||||
}
|
||||
|
||||
weights_texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data());
|
||||
weights_texture_ = GPU_texture_create_1d(
|
||||
"Weights", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data());
|
||||
}
|
||||
|
||||
/* Computes a falloff that is equal to 1 at an input of zero and decrease to zero at an input of 1,
|
||||
|
@ -129,7 +130,7 @@ void MorphologicalDistanceFeatherWeights::compute_distance_falloffs(int type, in
|
|||
}
|
||||
|
||||
distance_falloffs_texture_ = GPU_texture_create_1d(
|
||||
"Distance Factors", size, 1, GPU_R16F, falloffs.data());
|
||||
"Distance Factors", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, falloffs.data());
|
||||
}
|
||||
|
||||
void MorphologicalDistanceFeatherWeights::bind_weights_as_texture(GPUShader *shader,
|
||||
|
|
|
@ -93,7 +93,8 @@ SymmetricBlurWeights::SymmetricBlurWeights(int type, float2 radius)
|
|||
}
|
||||
}
|
||||
|
||||
texture_ = GPU_texture_create_2d("Weights", size.x, size.y, 1, GPU_R16F, weights.data());
|
||||
texture_ = GPU_texture_create_2d(
|
||||
"Weights", size.x, size.y, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data());
|
||||
}
|
||||
|
||||
SymmetricBlurWeights::~SymmetricBlurWeights()
|
||||
|
|
|
@ -70,7 +70,8 @@ SymmetricSeparableBlurWeights::SymmetricSeparableBlurWeights(int type, float rad
|
|||
weights[i] /= sum;
|
||||
}
|
||||
|
||||
texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data());
|
||||
texture_ = GPU_texture_create_1d(
|
||||
"Weights", size, 1, GPU_R16F, GPU_TEXTURE_USAGE_GENERAL, weights.data());
|
||||
}
|
||||
|
||||
SymmetricSeparableBlurWeights::~SymmetricSeparableBlurWeights()
|
||||
|
|
|
@ -639,9 +639,9 @@ static void dof_reduce_pass_init(EEVEE_FramebufferList *fbl,
|
|||
/* Do not use texture pool because of needs mipmaps. */
|
||||
eGPUTextureUsage tex_flags = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -397,12 +397,12 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
|
|||
if (lcache->grid_tx.tex == NULL) {
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
|
||||
GPU_TEXTURE_USAGE_HOST_READ;
|
||||
lcache->grid_tx.tex = GPU_texture_create_2d_array_ex("lightcache_irradiance",
|
||||
UNPACK3(lcache->grid_tx.tex_size),
|
||||
1,
|
||||
IRRADIANCE_FORMAT,
|
||||
usage,
|
||||
NULL);
|
||||
lcache->grid_tx.tex = GPU_texture_create_2d_array("lightcache_irradiance",
|
||||
UNPACK3(lcache->grid_tx.tex_size),
|
||||
1,
|
||||
IRRADIANCE_FORMAT,
|
||||
usage,
|
||||
NULL);
|
||||
GPU_texture_update(lcache->grid_tx.tex, GPU_DATA_UBYTE, lcache->grid_tx.data);
|
||||
|
||||
if (lcache->grid_tx.tex == NULL) {
|
||||
|
@ -418,23 +418,23 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
|
|||
GPU_TEXTURE_USAGE_HOST_READ;
|
||||
|
||||
/* Try to create a cubemap array. */
|
||||
lcache->cube_tx.tex = GPU_texture_create_cube_array_ex("lightcache_cubemaps",
|
||||
lcache->cube_tx.tex_size[0],
|
||||
lcache->cube_tx.tex_size[2] / 6,
|
||||
lcache->mips_len + 1,
|
||||
GPU_R11F_G11F_B10F,
|
||||
usage,
|
||||
NULL);
|
||||
lcache->cube_tx.tex = GPU_texture_create_cube_array("lightcache_cubemaps",
|
||||
lcache->cube_tx.tex_size[0],
|
||||
lcache->cube_tx.tex_size[2] / 6,
|
||||
lcache->mips_len + 1,
|
||||
GPU_R11F_G11F_B10F,
|
||||
usage,
|
||||
NULL);
|
||||
|
||||
if (lcache->cube_tx.tex == NULL) {
|
||||
/* Try fallback to 2D array. */
|
||||
|
||||
lcache->cube_tx.tex = GPU_texture_create_2d_array_ex("lightcache_cubemaps_fallback",
|
||||
UNPACK3(lcache->cube_tx.tex_size),
|
||||
lcache->mips_len + 1,
|
||||
GPU_R11F_G11F_B10F,
|
||||
usage,
|
||||
NULL);
|
||||
lcache->cube_tx.tex = GPU_texture_create_2d_array("lightcache_cubemaps_fallback",
|
||||
UNPACK3(lcache->cube_tx.tex_size),
|
||||
lcache->mips_len + 1,
|
||||
GPU_R11F_G11F_B10F,
|
||||
usage,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (lcache->cube_tx.tex == NULL) {
|
||||
|
|
|
@ -44,11 +44,11 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata)
|
|||
|
||||
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);
|
||||
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);
|
||||
GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UBYTE, areaTexBytes);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ static GPUTexture *edit_uv_mask_texture(
|
|||
|
||||
/* Free memory. */
|
||||
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);
|
||||
MEM_freeN(buffer);
|
||||
return texture;
|
||||
|
|
|
@ -382,8 +382,8 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
camera_background_images_stereo_setup(draw_ctx->scene, draw_ctx->v3d, ima, &iuser);
|
||||
tex = BKE_image_get_gpu_texture(ima, &iuser, nullptr);
|
||||
if (tex) {
|
||||
size[0] = GPU_texture_orig_width(tex);
|
||||
size[1] = GPU_texture_orig_height(tex);
|
||||
size[0] = GPU_texture_original_width(tex);
|
||||
size[1] = GPU_texture_original_height(tex);
|
||||
}
|
||||
}
|
||||
CLAMP_MIN(size[0], 1);
|
||||
|
|
|
@ -60,7 +60,7 @@ static void select_engine_framebuffer_setup(void)
|
|||
|
||||
if (e_data.texture_u32 == NULL) {
|
||||
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);
|
||||
GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, e_data.texture_u32, 0, 0);
|
||||
|
||||
|
|
|
@ -236,11 +236,11 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata)
|
|||
|
||||
/* TODO: could be shared for all viewports. */
|
||||
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);
|
||||
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);
|
||||
GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UBYTE, areaTexBytes);
|
||||
|
||||
|
|
|
@ -504,9 +504,11 @@ static bool workbench_render_framebuffers_init(void)
|
|||
* the other views will reuse these buffers */
|
||||
if (dtxl->color == nullptr) {
|
||||
BLI_assert(dtxl->depth == nullptr);
|
||||
dtxl->color = GPU_texture_create_2d("txl.color", size.x, size.y, 1, GPU_RGBA16F, nullptr);
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
|
||||
dtxl->color = GPU_texture_create_2d(
|
||||
"txl.color", size.x, size.y, 1, GPU_RGBA16F, usage, nullptr);
|
||||
dtxl->depth = GPU_texture_create_2d(
|
||||
"txl.depth", size.x, size.y, 1, GPU_DEPTH24_STENCIL8, nullptr);
|
||||
"txl.depth", size.x, size.y, 1, GPU_DEPTH24_STENCIL8, usage, nullptr);
|
||||
}
|
||||
|
||||
if (!(dtxl->depth && dtxl->color)) {
|
||||
|
|
|
@ -66,9 +66,8 @@ static bool workbench_render_framebuffers_init(void)
|
|||
if (dtxl->color == NULL) {
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
|
||||
BLI_assert(dtxl->depth == NULL);
|
||||
dtxl->color = GPU_texture_create_2d_ex(
|
||||
"txl.color", UNPACK2(size), 1, GPU_RGBA16F, usage, NULL);
|
||||
dtxl->depth = GPU_texture_create_2d_ex(
|
||||
dtxl->color = GPU_texture_create_2d("txl.color", UNPACK2(size), 1, GPU_RGBA16F, usage, NULL);
|
||||
dtxl->depth = GPU_texture_create_2d(
|
||||
"txl.depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, usage, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,15 +28,15 @@ void workbench_volume_engine_init(WORKBENCH_Data *vedata)
|
|||
WORKBENCH_TextureList *txl = vedata->txl;
|
||||
|
||||
if (txl->dummy_volume_tx == NULL) {
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT;
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ;
|
||||
|
||||
const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
txl->dummy_volume_tx = GPU_texture_create_3d_ex(
|
||||
"dummy_volume", 1, 1, 1, 1, GPU_RGBA8, GPU_DATA_FLOAT, usage, zero);
|
||||
txl->dummy_shadow_tx = GPU_texture_create_3d_ex(
|
||||
"dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, GPU_DATA_FLOAT, usage, one);
|
||||
txl->dummy_coba_tx = GPU_texture_create_1d_ex("dummy_coba", 1, 1, GPU_RGBA8, usage, zero);
|
||||
txl->dummy_volume_tx = GPU_texture_create_3d(
|
||||
"dummy_volume", 1, 1, 1, 1, GPU_RGBA8, usage, zero);
|
||||
txl->dummy_shadow_tx = GPU_texture_create_3d(
|
||||
"dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, usage, one);
|
||||
txl->dummy_coba_tx = GPU_texture_create_1d("dummy_coba", 1, 1, GPU_RGBA8, usage, zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -775,27 +775,27 @@ class Texture : NonCopyable {
|
|||
|
||||
bool depth() const
|
||||
{
|
||||
return GPU_texture_depth(tx_);
|
||||
return GPU_texture_has_depth_format(tx_);
|
||||
}
|
||||
|
||||
bool is_stencil() const
|
||||
{
|
||||
return GPU_texture_stencil(tx_);
|
||||
return GPU_texture_has_stencil_format(tx_);
|
||||
}
|
||||
|
||||
bool is_integer() const
|
||||
{
|
||||
return GPU_texture_integer(tx_);
|
||||
return GPU_texture_has_integer_format(tx_);
|
||||
}
|
||||
|
||||
bool is_cube() const
|
||||
{
|
||||
return GPU_texture_cube(tx_);
|
||||
return GPU_texture_is_cube(tx_);
|
||||
}
|
||||
|
||||
bool is_array() const
|
||||
{
|
||||
return GPU_texture_array(tx_);
|
||||
return GPU_texture_is_array(tx_);
|
||||
}
|
||||
|
||||
int3 size(int miplvl = 0) const
|
||||
|
@ -886,7 +886,7 @@ class Texture : NonCopyable {
|
|||
int3 size(0);
|
||||
GPU_texture_get_mipmap_size(tx_, 0, size);
|
||||
if (size != int3(w, h, d) || GPU_texture_format(tx_) != format ||
|
||||
GPU_texture_cube(tx_) != cubemap || GPU_texture_array(tx_) != layered) {
|
||||
GPU_texture_is_cube(tx_) != cubemap || GPU_texture_is_array(tx_) != layered) {
|
||||
free();
|
||||
}
|
||||
}
|
||||
|
@ -908,31 +908,30 @@ class Texture : NonCopyable {
|
|||
bool cubemap)
|
||||
{
|
||||
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) {
|
||||
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 {
|
||||
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) {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
return GPU_texture_create_3d_ex(
|
||||
name_, w, h, d, mip_len, format, GPU_DATA_FLOAT, usage, data);
|
||||
return GPU_texture_create_3d(name_, w, h, d, mip_len, format, usage, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,14 +307,13 @@ static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume,
|
|||
|
||||
/* Create GPU texture. */
|
||||
eGPUTextureFormat format = (channels == 3) ? GPU_RGB16F : GPU_R16F;
|
||||
cache_grid->texture = GPU_texture_create_3d_ex("volume_grid",
|
||||
UNPACK3(dense_grid.resolution),
|
||||
1,
|
||||
format,
|
||||
GPU_DATA_FLOAT,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
dense_grid.voxels);
|
||||
cache_grid->texture = GPU_texture_create_3d("volume_grid",
|
||||
UNPACK3(dense_grid.resolution),
|
||||
1,
|
||||
format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
dense_grid.voxels);
|
||||
/* The texture can be null if the resolution along one axis is larger than
|
||||
* GL_MAX_3D_TEXTURE_SIZE. */
|
||||
if (cache_grid->texture != nullptr) {
|
||||
|
|
|
@ -43,7 +43,7 @@ void ResourceBind::execute() const
|
|||
}
|
||||
switch (type) {
|
||||
case ResourceBind::Type::Sampler:
|
||||
GPU_texture_bind_ex(is_reference ? *texture_ref : texture, sampler, slot, false);
|
||||
GPU_texture_bind_ex(is_reference ? *texture_ref : texture, sampler, slot);
|
||||
break;
|
||||
case ResourceBind::Type::BufferSampler:
|
||||
GPU_vertbuf_bind_as_texture(is_reference ? *vertex_buf_ref : vertex_buf, slot);
|
||||
|
|
|
@ -219,7 +219,7 @@ void DRW_globals_update(void)
|
|||
|
||||
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);
|
||||
|
||||
MEM_freeN(colors);
|
||||
|
@ -477,6 +477,6 @@ static GPUTexture *DRW_create_weight_colorramp_texture(void)
|
|||
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]);
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ static GPUTexture *create_transfer_function(int type, const struct ColorBand *co
|
|||
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);
|
||||
|
||||
MEM_freeN(data);
|
||||
|
@ -179,14 +179,12 @@ static GPUTexture *create_volume_texture(const int dim[3],
|
|||
}
|
||||
|
||||
while (1) {
|
||||
tex = GPU_texture_create_3d_ex("volume",
|
||||
UNPACK3(final_dim),
|
||||
1,
|
||||
texture_format,
|
||||
data_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
tex = GPU_texture_create_3d("volume",
|
||||
UNPACK3(final_dim),
|
||||
1,
|
||||
texture_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
|
||||
if (tex != NULL) {
|
||||
break;
|
||||
|
@ -509,27 +507,12 @@ void DRW_smoke_ensure_velocity(FluidModifierData *fmd)
|
|||
}
|
||||
|
||||
if (!fds->tex_velocity_x) {
|
||||
fds->tex_velocity_x = GPU_texture_create_3d_ex("velx",
|
||||
UNPACK3(fds->res),
|
||||
1,
|
||||
GPU_R16F,
|
||||
GPU_DATA_FLOAT,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
vel_x);
|
||||
fds->tex_velocity_y = GPU_texture_create_3d_ex("vely",
|
||||
UNPACK3(fds->res),
|
||||
1,
|
||||
GPU_R16F,
|
||||
GPU_DATA_FLOAT,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
vel_y);
|
||||
fds->tex_velocity_z = GPU_texture_create_3d_ex("velz",
|
||||
UNPACK3(fds->res),
|
||||
1,
|
||||
GPU_R16F,
|
||||
GPU_DATA_FLOAT,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
vel_z);
|
||||
fds->tex_velocity_x = GPU_texture_create_3d(
|
||||
"velx", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_x);
|
||||
fds->tex_velocity_y = GPU_texture_create_3d(
|
||||
"vely", UNPACK3(fds->res), 1, GPU_R16F, GPU_TEXTURE_USAGE_SHADER_READ, vel_y);
|
||||
fds->tex_velocity_z = GPU_texture_create_3d(
|
||||
"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_y));
|
||||
BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_z));
|
||||
|
|
|
@ -2339,7 +2339,7 @@ static void draw_select_framebuffer_depth_only_setup(const int size[2])
|
|||
|
||||
if (g_select_buffer.texture_depth == NULL) {
|
||||
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);
|
||||
|
||||
GPU_framebuffer_texture_attach(
|
||||
|
|
|
@ -646,10 +646,10 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
|
|||
shgroup->shader, uni->location, uni->length, uni->arraysize, uni->pvalue);
|
||||
break;
|
||||
case DRW_UNIFORM_TEXTURE:
|
||||
GPU_texture_bind_ex(uni->texture, uni->sampler_state, uni->location, false);
|
||||
GPU_texture_bind_ex(uni->texture, uni->sampler_state, uni->location);
|
||||
break;
|
||||
case DRW_UNIFORM_TEXTURE_REF:
|
||||
GPU_texture_bind_ex(*uni->texture_ref, uni->sampler_state, uni->location, false);
|
||||
GPU_texture_bind_ex(*uni->texture_ref, uni->sampler_state, uni->location);
|
||||
break;
|
||||
case DRW_UNIFORM_IMAGE:
|
||||
GPU_texture_image_bind(uni->texture, uni->location);
|
||||
|
|
|
@ -54,7 +54,7 @@ void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
|
|||
|
||||
if (flags & DRW_TEX_MIPMAP) {
|
||||
GPU_texture_mipmap_mode(tex, true, flags & DRW_TEX_FILTER);
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
}
|
||||
else {
|
||||
GPU_texture_filter_mode(tex, flags & DRW_TEX_FILTER);
|
||||
|
@ -71,7 +71,7 @@ GPUTexture *DRW_texture_create_1d_ex(int w,
|
|||
const float *fpixels)
|
||||
{
|
||||
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);
|
||||
|
||||
return tex;
|
||||
|
@ -93,7 +93,7 @@ GPUTexture *DRW_texture_create_2d_ex(int w,
|
|||
const float *fpixels)
|
||||
{
|
||||
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);
|
||||
|
||||
return tex;
|
||||
|
@ -114,7 +114,7 @@ GPUTexture *DRW_texture_create_2d_array_ex(int w,
|
|||
const float *fpixels)
|
||||
{
|
||||
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);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
|
@ -137,8 +137,7 @@ GPUTexture *DRW_texture_create_3d_ex(int w,
|
|||
const float *fpixels)
|
||||
{
|
||||
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
|
||||
GPUTexture *tex = GPU_texture_create_3d_ex(
|
||||
__func__, w, h, d, mip_len, format, GPU_DATA_FLOAT, usage, fpixels);
|
||||
GPUTexture *tex = GPU_texture_create_3d(__func__, w, h, d, mip_len, format, usage, fpixels);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
|
||||
return tex;
|
||||
|
@ -157,7 +156,7 @@ GPUTexture *DRW_texture_create_cube_ex(int w,
|
|||
const float *fpixels)
|
||||
{
|
||||
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);
|
||||
return tex;
|
||||
}
|
||||
|
@ -178,8 +177,7 @@ GPUTexture *DRW_texture_create_cube_array_ex(int w,
|
|||
const float *fpixels)
|
||||
{
|
||||
int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
|
||||
GPUTexture *tex = GPU_texture_create_cube_array_ex(
|
||||
__func__, w, d, mip_len, format, usage, fpixels);
|
||||
GPUTexture *tex = GPU_texture_create_cube_array(__func__, w, d, mip_len, format, usage, fpixels);
|
||||
drw_texture_set_parameters(tex, flags);
|
||||
return tex;
|
||||
}
|
||||
|
@ -260,7 +258,7 @@ void DRW_texture_ensure_2d(
|
|||
|
||||
void DRW_texture_generate_mipmaps(GPUTexture *tex)
|
||||
{
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
}
|
||||
|
||||
void DRW_texture_free(GPUTexture *tex)
|
||||
|
|
|
@ -98,11 +98,12 @@ GPUTexture *DRW_texture_pool_query(DRWTexturePool *pool,
|
|||
|
||||
DRWTexturePoolHandle handle;
|
||||
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);
|
||||
/* Doing filtering for depth does not make sense when not doing shadow mapping,
|
||||
* and enabling texture filtering on integer texture make them unreadable. */
|
||||
bool do_filter = !GPU_texture_depth(handle.texture) && !GPU_texture_integer(handle.texture);
|
||||
bool do_filter = !GPU_texture_has_depth_format(handle.texture) &&
|
||||
!GPU_texture_has_integer_format(handle.texture);
|
||||
GPU_texture_filter_mode(handle.texture, do_filter);
|
||||
|
||||
return handle.texture;
|
||||
|
@ -154,7 +155,7 @@ GPUTexture *DRW_texture_pool_texture_acquire(
|
|||
int texture_id = pool->handles.size();
|
||||
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);
|
||||
|
|
|
@ -70,10 +70,10 @@ static void drw_volume_globals_init()
|
|||
{
|
||||
const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
g_data.dummy_zero = GPU_texture_create_3d_ex(
|
||||
"dummy_zero", 1, 1, 1, 1, GPU_RGBA8, GPU_DATA_FLOAT, GPU_TEXTURE_USAGE_SHADER_READ, zero);
|
||||
g_data.dummy_one = GPU_texture_create_3d_ex(
|
||||
"dummy_one", 1, 1, 1, 1, GPU_RGBA8, GPU_DATA_FLOAT, GPU_TEXTURE_USAGE_SHADER_READ, one);
|
||||
g_data.dummy_zero = GPU_texture_create_3d(
|
||||
"dummy_zero", 1, 1, 1, 1, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, zero);
|
||||
g_data.dummy_one = GPU_texture_create_3d(
|
||||
"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_one, true, true);
|
||||
|
||||
|
|
|
@ -4483,7 +4483,8 @@ void ANIM_channel_draw(
|
|||
if (ac->sl) {
|
||||
if (ELEM(ac->spacetype, SPACE_ACTION, SPACE_GRAPH) &&
|
||||
(acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) ||
|
||||
acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) {
|
||||
acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) &&
|
||||
!ELEM(ale->type, ANIMTYPE_GPLAYER, ANIMTYPE_DSGPENCIL)) {
|
||||
/* for F-Curves, draw color-preview of curve left to the visibility icon */
|
||||
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
@ -5227,7 +5228,8 @@ void ANIM_channel_draw_widgets(const bContext *C,
|
|||
if (ac->sl) {
|
||||
if (ELEM(ac->spacetype, SPACE_ACTION, SPACE_GRAPH) &&
|
||||
(acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE) ||
|
||||
acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE))) {
|
||||
acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) &&
|
||||
(ale->type != ANIMTYPE_GPLAYER)) {
|
||||
/* Pin toggle. */
|
||||
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_ALWAYS_VISIBLE)) {
|
||||
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_ALWAYS_VISIBLE);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "BLI_dial_2d.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_base_safe.h"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
@ -46,7 +47,7 @@
|
|||
|
||||
static int gizmo_cage2d_transform_flag_get(const wmGizmo *gz);
|
||||
|
||||
static bool gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], float scale[2])
|
||||
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], float scale[2])
|
||||
{
|
||||
float matrix_final_no_offset[4][4];
|
||||
float asp[2] = {1.0f, 1.0f};
|
||||
|
@ -67,29 +68,21 @@ static bool gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], f
|
|||
float len_x_axis = len_v3(x_axis);
|
||||
float len_y_axis = len_v3(y_axis);
|
||||
|
||||
if (len_x_axis == 0.0f || len_y_axis == 0.0f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
scale[0] = 1.0f / len_x_axis;
|
||||
scale[1] = 1.0f / len_y_axis;
|
||||
return true;
|
||||
/* Set scale to zero if axis length is zero. */
|
||||
scale[0] = safe_divide(1.0f, len_x_axis);
|
||||
scale[1] = safe_divide(1.0f, len_y_axis);
|
||||
}
|
||||
|
||||
static bool gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[2], float margin[2])
|
||||
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[2], float margin[2])
|
||||
{
|
||||
float handle_size;
|
||||
handle_size = 0.15f;
|
||||
handle_size *= gz->scale_final;
|
||||
float scale_xy[2];
|
||||
if (!gizmo_calc_rect_view_scale(gz, dims, scale_xy)) {
|
||||
zero_v2(margin);
|
||||
return false;
|
||||
}
|
||||
gizmo_calc_rect_view_scale(gz, dims, scale_xy);
|
||||
|
||||
margin[0] = (handle_size * scale_xy[0]);
|
||||
margin[1] = (handle_size * scale_xy[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -396,7 +389,17 @@ static void cage2d_draw_box_interaction(const float color[4],
|
|||
|
||||
{
|
||||
if (is_solid) {
|
||||
BLI_assert(ELEM(prim_type, GPU_PRIM_TRI_FAN));
|
||||
|
||||
if (margin[0] == 0.0f && margin[1] == 0.0) {
|
||||
prim_type = GPU_PRIM_POINTS;
|
||||
}
|
||||
else if (margin[0] == 0.0f || margin[1] == 0.0) {
|
||||
prim_type = GPU_PRIM_LINE_STRIP;
|
||||
}
|
||||
else {
|
||||
BLI_assert(ELEM(prim_type, GPU_PRIM_TRI_FAN));
|
||||
}
|
||||
|
||||
immBegin(prim_type, verts_len);
|
||||
immAttr3f(attr_id.col, 0.0f, 0.0f, 0.0f);
|
||||
for (uint i = 0; i < verts_len; i++) {
|
||||
|
@ -445,6 +448,18 @@ static void cage2d_draw_box_interaction(const float color[4],
|
|||
static void imm_draw_point_aspect_2d(
|
||||
uint pos, float x, float y, float rad_x, float rad_y, bool solid)
|
||||
{
|
||||
if (rad_x == 0 && rad_y == 0) {
|
||||
immBegin(GPU_PRIM_POINTS, 1);
|
||||
immVertex2f(pos, x, y);
|
||||
immEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
if (rad_x == 0 || rad_y == 0) {
|
||||
/* Do not draw anything if only on of the radii is zero. */
|
||||
return;
|
||||
}
|
||||
|
||||
if (solid) {
|
||||
/* NOTE(Metal/AMD): Small Triangle-list primitives more optimal for GPU HW than Triangle-strip.
|
||||
*/
|
||||
|
@ -539,20 +554,28 @@ static void cage2d_draw_rect_wire(const rctf *r,
|
|||
|
||||
static void cage2d_draw_circle_wire(const float color[3],
|
||||
const float size[2],
|
||||
const float margin,
|
||||
const float margin[2],
|
||||
const float line_width)
|
||||
{
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
|
||||
immBindBuiltinProgram(is_zero_v2(margin) ? GPU_SHADER_3D_UNIFORM_COLOR :
|
||||
GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
|
||||
immUniformColor3fv(color);
|
||||
|
||||
float viewport[4];
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", line_width * U.pixelsize + margin);
|
||||
|
||||
imm_draw_circle_wire_aspect_3d(pos, 0.0f, 0.0f, size[0], size[1], CIRCLE_RESOL);
|
||||
if (is_zero_v2(margin)) {
|
||||
/* Draw a central point. */
|
||||
immBegin(GPU_PRIM_POINTS, 1);
|
||||
immVertex3f(pos, 0.0f, 0.0f, 0.0f);
|
||||
immEnd();
|
||||
}
|
||||
else {
|
||||
float viewport[4];
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
immUniform2fv("viewportSize", &viewport[2]);
|
||||
immUniform1f("lineWidth", line_width * U.pixelsize);
|
||||
imm_draw_circle_wire_aspect_3d(pos, 0.0f, 0.0f, size[0], size[1], CIRCLE_RESOL);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
@ -592,20 +615,6 @@ static void cage2d_draw_rect_handles(const rctf *r,
|
|||
immUnbindProgram();
|
||||
}
|
||||
|
||||
static void cage2d_draw_central_handle(const float color[3], const float margin[2])
|
||||
{
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
|
||||
const float rad[2] = {margin[0] * 0.25f, margin[1] * 0.25f};
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor3fv(color);
|
||||
|
||||
imm_draw_circle_fill_aspect_3d(pos, 0.0f, 0.0f, rad[0], rad[1], CIRCLE_RESOL);
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
static void gizmo_cage2d_draw_intern(wmGizmo *gz,
|
||||
|
@ -650,10 +659,8 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
|
|||
if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
|
||||
/* Only scaling is needed for now. */
|
||||
GPU_select_load_id(select_id | ED_GIZMO_CAGE2D_PART_SCALE);
|
||||
cage2d_draw_circle_wire(
|
||||
gz->color, size_real, 0.5f * (margin[0] + margin[1]), gz->line_width);
|
||||
|
||||
cage2d_draw_central_handle(gz->color, margin);
|
||||
cage2d_draw_circle_wire(gz->color, size_real, margin, gz->line_width);
|
||||
}
|
||||
else {
|
||||
if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE) {
|
||||
|
@ -747,15 +754,13 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
|
|||
cage2d_draw_rect_wire(&r, margin, black, transform_flag, draw_options, outline_line_width);
|
||||
cage2d_draw_rect_wire(&r, margin, color, transform_flag, draw_options, gz->line_width);
|
||||
|
||||
/* corner gizmos */
|
||||
cage2d_draw_rect_handles(&r, margin, color, transform_flag, true);
|
||||
/* Corner gizmos. */
|
||||
cage2d_draw_rect_handles(&r, margin, black, transform_flag, false);
|
||||
cage2d_draw_rect_handles(&r, margin, color, transform_flag, true);
|
||||
}
|
||||
else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
|
||||
cage2d_draw_circle_wire(black, size_real, 0.0f, outline_line_width);
|
||||
cage2d_draw_circle_wire(color, size_real, 0.0f, gz->line_width);
|
||||
|
||||
cage2d_draw_central_handle(color, margin);
|
||||
cage2d_draw_circle_wire(black, size_real, margin, outline_line_width);
|
||||
cage2d_draw_circle_wire(color, size_real, margin, gz->line_width);
|
||||
}
|
||||
else {
|
||||
BLI_assert(0);
|
||||
|
@ -826,9 +831,7 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
|||
}
|
||||
|
||||
float margin[2];
|
||||
if (!gizmo_calc_rect_view_margin(gz, dims, margin)) {
|
||||
return -1;
|
||||
}
|
||||
gizmo_calc_rect_view_margin(gz, dims, margin);
|
||||
|
||||
/* Expand for hots-pot. */
|
||||
const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
|
||||
|
@ -1035,14 +1038,6 @@ static int gizmo_cage2d_modal(bContext *C,
|
|||
const wmEvent *event,
|
||||
eWM_GizmoFlagTweak UNUSED(tweak_flag))
|
||||
{
|
||||
/* For transform logic to be manageable we operate in -0.5..0.5 2D space,
|
||||
* no matter the size of the rectangle, mouse coords are scaled to unit space.
|
||||
* The mouse coords have been projected into the matrix
|
||||
* so we don't need to worry about axis alignment.
|
||||
*
|
||||
* - The cursor offset are multiplied by 'dims'.
|
||||
* - Matrix translation is also multiplied by 'dims'.
|
||||
*/
|
||||
RectTransformInteraction *data = gz->interaction_data;
|
||||
int transform_flag = RNA_enum_get(gz->ptr, "transform");
|
||||
if ((transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM) == 0) {
|
||||
|
@ -1073,6 +1068,8 @@ static int gizmo_cage2d_modal(bContext *C,
|
|||
copy_m4_m4(matrix_back, gz->matrix_offset);
|
||||
copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
|
||||
|
||||
/* The mouse coords are projected into the matrix so we don't need to worry about axis
|
||||
* alignment. */
|
||||
bool ok = gizmo_window_project_2d(
|
||||
C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local);
|
||||
copy_m4_m4(gz->matrix_offset, matrix_back);
|
||||
|
@ -1145,6 +1142,7 @@ static int gizmo_cage2d_modal(bContext *C,
|
|||
float pivot[2];
|
||||
if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE) {
|
||||
gizmo_pivot_from_scale_part(gz->highlight_part, pivot);
|
||||
mul_v2_v2(pivot, dims);
|
||||
}
|
||||
else {
|
||||
zero_v2(pivot);
|
||||
|
@ -1153,27 +1151,26 @@ static int gizmo_cage2d_modal(bContext *C,
|
|||
bool constrain_axis[2] = {false};
|
||||
gizmo_constrain_from_scale_part(gz->highlight_part, constrain_axis);
|
||||
|
||||
float scale[2] = {1.0f, 1.0f};
|
||||
float size_new[2], size_orig[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
size_orig[i] = len_v3(data->orig_matrix_offset[i]);
|
||||
size_new[i] = size_orig[i];
|
||||
if (constrain_axis[i] == false) {
|
||||
/* Original cursor position relative to pivot, remapped to [-1, 1] */
|
||||
const float delta_orig = (data->orig_mouse[i] - data->orig_matrix_offset[3][i]) /
|
||||
(dims[i] * len_v3(data->orig_matrix_offset[i])) -
|
||||
pivot[i];
|
||||
const float delta_curr = (point_local[i] - data->orig_matrix_offset[3][i]) /
|
||||
(dims[i] * len_v3(data->orig_matrix_offset[i])) -
|
||||
pivot[i];
|
||||
/* Original cursor position relative to pivot. */
|
||||
const float delta_orig = data->orig_mouse[i] - data->orig_matrix_offset[3][i] -
|
||||
pivot[i] * size_orig[i];
|
||||
const float delta_curr = point_local[i] - data->orig_matrix_offset[3][i] -
|
||||
pivot[i] * size_orig[i];
|
||||
|
||||
if ((transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED) == 0) {
|
||||
if (signum_i(delta_orig) != signum_i(delta_curr)) {
|
||||
scale[i] = 0.0f;
|
||||
size_new[i] = 0.0f;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Original cursor position does not exactly lie on the cage boundary due to margin. */
|
||||
const float delta_boundary = signf(delta_orig) * 0.5f - pivot[i];
|
||||
scale[i] = delta_curr / delta_boundary;
|
||||
size_new[i] = delta_curr / (signf(delta_orig) * 0.5f * dims[i] - pivot[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1181,33 +1178,39 @@ static int gizmo_cage2d_modal(bContext *C,
|
|||
if (constrain_axis[0] == false && constrain_axis[1] == false) {
|
||||
if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
|
||||
/* So that the cursor lies on the circle. */
|
||||
scale[1] = scale[0] = len_v2(scale);
|
||||
size_new[1] = size_new[0] = len_v2(size_new);
|
||||
}
|
||||
else {
|
||||
scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
|
||||
size_new[1] = size_new[0] = (size_new[1] + size_new[0]) / 2.0f;
|
||||
}
|
||||
}
|
||||
else if (constrain_axis[0] == false) {
|
||||
scale[1] = scale[0];
|
||||
size_new[1] = size_new[0];
|
||||
}
|
||||
else if (constrain_axis[1] == false) {
|
||||
scale[0] = scale[1];
|
||||
size_new[0] = size_new[1];
|
||||
}
|
||||
else {
|
||||
BLI_assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* scale around pivot */
|
||||
/* Scale around pivot. */
|
||||
float scale[2];
|
||||
float matrix_scale[4][4];
|
||||
unit_m4(matrix_scale);
|
||||
|
||||
mul_v3_fl(matrix_scale[0], scale[0]);
|
||||
mul_v3_fl(matrix_scale[1], scale[1]);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (size_orig[i] == 0) {
|
||||
size_orig[i] = 1.0f;
|
||||
gz->matrix_offset[i][i] = 1.0f;
|
||||
}
|
||||
scale[i] = size_new[i] / size_orig[i];
|
||||
mul_v3_fl(matrix_scale[i], scale[i]);
|
||||
}
|
||||
|
||||
transform_pivot_set_m4(matrix_scale,
|
||||
(const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f});
|
||||
mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
|
||||
transform_pivot_set_m4(matrix_scale, (const float[3]){UNPACK2(pivot), 0.0f});
|
||||
mul_m4_m4_post(gz->matrix_offset, matrix_scale);
|
||||
}
|
||||
|
||||
if (gz_prop->type != NULL) {
|
||||
|
|
|
@ -9657,7 +9657,7 @@ static int ui_handle_viewlist_items_hover(const wmEvent *event, const ARegion *r
|
|||
bool has_item = false;
|
||||
LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) {
|
||||
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
|
||||
if (ELEM(but->type, UI_BTYPE_VIEW_ITEM,UI_BTYPE_LISTROW)) {
|
||||
if (ELEM(but->type, UI_BTYPE_VIEW_ITEM, UI_BTYPE_LISTROW)) {
|
||||
but->flag &= ~UI_ACTIVE;
|
||||
has_item = true;
|
||||
}
|
||||
|
|
|
@ -912,20 +912,20 @@ void UI_icons_reload_internal_textures()
|
|||
icongltex.invw = 1.0f / b32buf->x;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
if (need_icons_with_border && icongltex.tex[1] == nullptr) {
|
||||
icongltex.tex[1] = GPU_texture_create_2d_ex("icons_border",
|
||||
b32buf_border->x,
|
||||
b32buf_border->y,
|
||||
2,
|
||||
GPU_RGBA8,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
nullptr);
|
||||
icongltex.tex[1] = GPU_texture_create_2d("icons_border",
|
||||
b32buf_border->x,
|
||||
b32buf_border->y,
|
||||
2,
|
||||
GPU_RGBA8,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
nullptr);
|
||||
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);
|
||||
}
|
||||
|
@ -1626,7 +1626,7 @@ static void icon_draw_cache_texture_flush_ex(GPUTexture *texture,
|
|||
GPU_uniformbuf_bind(ubo, data_binding);
|
||||
|
||||
const int img_binding = GPU_shader_get_sampler_binding(shader, "image");
|
||||
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
|
||||
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding);
|
||||
|
||||
GPUBatch *quad = GPU_batch_preset_quad();
|
||||
GPU_batch_set_shader(quad, shader);
|
||||
|
@ -1818,7 +1818,7 @@ static void icon_draw_texture(float x,
|
|||
GPU_shader_uniform_float_ex(shader, rect_geom_loc, 4, 1, geom_color);
|
||||
GPU_shader_uniform_1f(shader, "text_width", text_width);
|
||||
|
||||
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
|
||||
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding);
|
||||
|
||||
GPUBatch *quad = GPU_batch_preset_quad();
|
||||
GPU_batch_set_shader(quad, shader);
|
||||
|
|
|
@ -4092,7 +4092,7 @@ static void widget_list_itembut(uiWidgetColors *wcol,
|
|||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
if (state->but_flag & UI_ACTIVE && !(state->but_flag & UI_SELECT)) {
|
||||
if (state->but_flag & UI_ACTIVE && !(state->but_flag & UI_SELECT)) {
|
||||
copy_v3_v3_uchar(wcol->inner, wcol->text);
|
||||
wcol->inner[3] = 20;
|
||||
}
|
||||
|
|
|
@ -234,7 +234,6 @@ static void build_poly_connections(blender::AtomicDisjointSet &islands,
|
|||
/* Polys are connected if they share edges. By connecting all edges of a loop (as long as they
|
||||
* are not a seam) we can find connected faces. */
|
||||
threading::parallel_for(polys.index_range(), 1024, [&](const IndexRange range) {
|
||||
|
||||
for (const int poly_index : range) {
|
||||
if (hide_poly[poly_index]) {
|
||||
continue;
|
||||
|
@ -259,9 +258,7 @@ static void build_poly_connections(blender::AtomicDisjointSet &islands,
|
|||
islands.join(inner_mloop.e, outer_mloop.e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
|
|||
const int mip_len = use_mipmap ? 9999 : 1;
|
||||
|
||||
GPUTexture *tex = GPU_texture_create_2d(
|
||||
"immDrawPixels", img_w, img_h, mip_len, gpu_format, 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);
|
||||
eGPUDataFormat gpu_data_format = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE;
|
||||
|
@ -89,7 +89,7 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
|
|||
|
||||
GPU_texture_filter_mode(tex, use_filter);
|
||||
if (use_mipmap) {
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
GPU_texture_mipmap_mode(tex, true, true);
|
||||
}
|
||||
GPU_texture_wrap_mode(tex, false, true);
|
||||
|
@ -170,7 +170,8 @@ void immDrawPixelsTexTiled_scaling_clipping(IMMDrawPixelsTexState *state,
|
|||
eGPUDataFormat gpu_data = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UBYTE;
|
||||
size_t stride = components * ((use_float_data) ? sizeof(float) : sizeof(uchar));
|
||||
|
||||
GPUTexture *tex = GPU_texture_create_2d("immDrawPixels", tex_w, tex_h, 1, gpu_format, NULL);
|
||||
GPUTexture *tex = GPU_texture_create_2d(
|
||||
"immDrawPixels", tex_w, tex_h, 1, gpu_format, GPU_TEXTURE_USAGE_GENERAL, NULL);
|
||||
|
||||
GPU_texture_filter_mode(tex, use_filter);
|
||||
GPU_texture_wrap_mode(tex, false, true);
|
||||
|
|
|
@ -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;
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
|
||||
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);
|
||||
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) {
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT |
|
||||
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);
|
||||
GPU_texture_update(cursor_snap.overlay_texture, GPU_DATA_UBYTE, buffer);
|
||||
|
||||
|
|
|
@ -1033,8 +1033,10 @@ static void sculpt_gesture_trim_shape_origin_normal_get(SculptGestureContext *sg
|
|||
*/
|
||||
switch (trim_operation->orientation) {
|
||||
case SCULPT_GESTURE_TRIM_ORIENTATION_VIEW:
|
||||
copy_v3_v3(r_origin, sgcontext->world_space_view_origin);
|
||||
mul_v3_m4v3(
|
||||
r_origin, sgcontext->vc.obact->object_to_world, sgcontext->ss->gesture_initial_location);
|
||||
copy_v3_v3(r_normal, sgcontext->world_space_view_normal);
|
||||
negate_v3(r_normal);
|
||||
break;
|
||||
case SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE:
|
||||
mul_v3_m4v3(
|
||||
|
@ -1168,14 +1170,30 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
|
|||
|
||||
const float(*ob_imat)[4] = vc->obact->world_to_object;
|
||||
|
||||
/* Write vertices coordinates for the front face. */
|
||||
/* Write vertices coordinatesSCULPT_GESTURE_TRIM_DIFFERENCE for the front face. */
|
||||
float(*positions)[3] = BKE_mesh_vert_positions_for_write(trim_operation->mesh);
|
||||
float depth_point[3];
|
||||
madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_front);
|
||||
|
||||
/* Get origin point for SCULPT_GESTURE_TRIM_ORIENTATION_VIEW.
|
||||
* Note: for projection extrusion we add depth_front here
|
||||
* instead of in the loop.
|
||||
*/
|
||||
if (trim_operation->extrude_mode == SCULPT_GESTURE_TRIM_EXTRUDE_FIXED) {
|
||||
copy_v3_v3(depth_point, shape_origin);
|
||||
}
|
||||
else {
|
||||
madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_front);
|
||||
}
|
||||
|
||||
for (int i = 0; i < tot_screen_points; i++) {
|
||||
float new_point[3];
|
||||
if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) {
|
||||
ED_view3d_win_to_3d(vc->v3d, region, depth_point, screen_points[i], new_point);
|
||||
|
||||
/* For fixed mode we add the shape normal here to avoid projection errors. */
|
||||
if (trim_operation->extrude_mode == SCULPT_GESTURE_TRIM_EXTRUDE_FIXED) {
|
||||
madd_v3_v3fl(new_point, shape_normal, depth_front);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ED_view3d_win_to_3d_on_plane(region, shape_plane, screen_points[i], false, new_point);
|
||||
|
|
|
@ -1196,13 +1196,13 @@ static void draw_plane_marker_image(Scene *scene,
|
|||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
}
|
||||
|
||||
GPUTexture *texture = GPU_texture_create_2d_ex("plane_marker_image",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_RGBA8,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
NULL);
|
||||
GPUTexture *texture = GPU_texture_create_2d("plane_marker_image",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_RGBA8,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
NULL);
|
||||
GPU_texture_update(texture, GPU_DATA_UBYTE, display_buffer);
|
||||
GPU_texture_filter_mode(texture, false);
|
||||
|
||||
|
|
|
@ -1223,7 +1223,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
|
|||
|
||||
eGPUTextureFormat texture_format = IMB_gpu_get_texture_format(
|
||||
ibuf, ima->flag & IMA_HIGH_BITDEPTH, ibuf->planes >= 8);
|
||||
const char *texture_format_description = GPU_texture_format_description(texture_format);
|
||||
const char *texture_format_description = GPU_texture_format_name(texture_format);
|
||||
ofs += BLI_snprintf_rlen(str + ofs, len - ofs, TIP_(", %s"), texture_format_description);
|
||||
|
||||
uiItemL(col, str, ICON_NONE);
|
||||
|
|
|
@ -3268,6 +3268,11 @@ static bool outliner_data_operation_poll(bContext *C)
|
|||
}
|
||||
const SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
|
||||
const TreeElement *te = get_target_element(space_outliner);
|
||||
|
||||
if (te == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
||||
get_element_operation_type(te, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
||||
return ELEM(datalevel,
|
||||
|
|
|
@ -1909,7 +1909,7 @@ static void sequencer_draw_display_buffer(const bContext *C,
|
|||
GPU_matrix_identity_projection_set();
|
||||
}
|
||||
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);
|
||||
GPU_texture_update(texture, data, display_buffer);
|
||||
GPU_texture_filter_mode(texture, false);
|
||||
|
|
|
@ -108,8 +108,7 @@ static void gizmo_light_radius_prop_matrix_get(const wmGizmo *UNUSED(gz),
|
|||
BKE_view_layer_synced_ensure(CTX_data_scene(C), view_layer);
|
||||
const Light *la = BKE_view_layer_active_object_get(view_layer)->data;
|
||||
|
||||
/* Draw gizmo even when radius is zero. */
|
||||
const float diameter = fmaxf(2.0f * la->radius, 1e-2f);
|
||||
const float diameter = 2.0f * la->radius;
|
||||
matrix[0][0] = diameter;
|
||||
matrix[1][1] = diameter;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -83,12 +83,13 @@ void FrameBuffer::attachment_set(GPUAttachmentType type, const GPUAttachment &ne
|
|||
|
||||
if (new_attachment.tex) {
|
||||
if (new_attachment.layer > 0) {
|
||||
BLI_assert(GPU_texture_cube(new_attachment.tex) || GPU_texture_array(new_attachment.tex));
|
||||
BLI_assert(GPU_texture_is_cube(new_attachment.tex) ||
|
||||
GPU_texture_is_array(new_attachment.tex));
|
||||
}
|
||||
if (GPU_texture_stencil(new_attachment.tex)) {
|
||||
if (GPU_texture_has_stencil_format(new_attachment.tex)) {
|
||||
BLI_assert(ELEM(type, GPU_FB_DEPTH_STENCIL_ATTACHMENT));
|
||||
}
|
||||
else if (GPU_texture_depth(new_attachment.tex)) {
|
||||
else if (GPU_texture_has_depth_format(new_attachment.tex)) {
|
||||
BLI_assert(ELEM(type, GPU_FB_DEPTH_ATTACHMENT));
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +361,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb,
|
|||
fb->attachment_set(GPU_FB_DEPTH_ATTACHMENT, depth_attachment);
|
||||
}
|
||||
else {
|
||||
GPUAttachmentType type = GPU_texture_stencil(depth_attachment.tex) ?
|
||||
GPUAttachmentType type = GPU_texture_has_stencil_format(depth_attachment.tex) ?
|
||||
GPU_FB_DEPTH_STENCIL_ATTACHMENT :
|
||||
GPU_FB_DEPTH_ATTACHMENT;
|
||||
fb->attachment_set(type, depth_attachment);
|
||||
|
@ -478,11 +479,12 @@ void GPU_framebuffer_blit(GPUFrameBuffer *gpufb_read,
|
|||
}
|
||||
|
||||
if (blit_buffers & GPU_DEPTH_BIT) {
|
||||
BLI_assert(GPU_texture_depth(read_tex) && GPU_texture_depth(write_tex));
|
||||
BLI_assert(GPU_texture_has_depth_format(read_tex) && GPU_texture_has_depth_format(write_tex));
|
||||
BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
|
||||
}
|
||||
if (blit_buffers & GPU_STENCIL_BIT) {
|
||||
BLI_assert(GPU_texture_stencil(read_tex) && GPU_texture_stencil(write_tex));
|
||||
BLI_assert(GPU_texture_has_stencil_format(read_tex) &&
|
||||
GPU_texture_has_stencil_format(write_tex));
|
||||
BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
|
||||
}
|
||||
#endif
|
||||
|
@ -623,10 +625,10 @@ GPUOffScreen *GPU_offscreen_create(
|
|||
width = max_ii(1, width);
|
||||
|
||||
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) {
|
||||
ofs->depth = GPU_texture_create_2d_ex(
|
||||
ofs->depth = GPU_texture_create_2d(
|
||||
"ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, usage, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -609,7 +609,7 @@ void immBindTexture(const char *name, GPUTexture *tex)
|
|||
void immBindTextureSampler(const char *name, GPUTexture *tex, eGPUSamplerState state)
|
||||
{
|
||||
int binding = GPU_shader_get_sampler_binding(imm->shader, name);
|
||||
GPU_texture_bind_ex(tex, state, binding, true);
|
||||
GPU_texture_bind_ex(tex, state, binding);
|
||||
}
|
||||
|
||||
void immBindUniformBuf(const char *name, GPUUniformBuf *ubo)
|
||||
|
|
|
@ -215,13 +215,13 @@ static void gpu_material_ramp_texture_build(GPUMaterial *mat)
|
|||
|
||||
GPUColorBandBuilder *builder = mat->coba_builder;
|
||||
|
||||
mat->coba_tex = GPU_texture_create_1d_array_ex("mat_ramp",
|
||||
CM_TABLE + 1,
|
||||
builder->current_layer,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
(float *)builder->pixels);
|
||||
mat->coba_tex = GPU_texture_create_1d_array("mat_ramp",
|
||||
CM_TABLE + 1,
|
||||
builder->current_layer,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
(float *)builder->pixels);
|
||||
|
||||
MEM_freeN(builder);
|
||||
mat->coba_builder = NULL;
|
||||
|
@ -239,6 +239,7 @@ static void gpu_material_sky_texture_build(GPUMaterial *mat)
|
|||
mat->sky_builder->current_layer,
|
||||
1,
|
||||
GPU_RGBA32F,
|
||||
GPU_TEXTURE_USAGE_GENERAL,
|
||||
(float *)mat->sky_builder->pixels);
|
||||
|
||||
MEM_freeN(mat->sky_builder);
|
||||
|
@ -609,12 +610,12 @@ struct GPUUniformBuf *GPU_material_sss_profile_get(GPUMaterial *material,
|
|||
GPU_texture_free(material->sss_tex_profile);
|
||||
}
|
||||
|
||||
material->sss_tex_profile = GPU_texture_create_1d_ex("sss_tex_profile",
|
||||
64,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
translucence_profile);
|
||||
material->sss_tex_profile = GPU_texture_create_1d("sss_tex_profile",
|
||||
64,
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||
translucence_profile);
|
||||
|
||||
MEM_freeN(translucence_profile);
|
||||
|
||||
|
|
|
@ -286,98 +286,97 @@ static inline GPUTexture *gpu_texture_create(const char *name,
|
|||
return reinterpret_cast<GPUTexture *>(tex);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_1d_ex(const char *name,
|
||||
int w,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
GPUTexture *GPU_texture_create_1d(const char *name,
|
||||
int w,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
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,
|
||||
int w,
|
||||
int h,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
GPUTexture *GPU_texture_create_1d_array(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
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,
|
||||
int w,
|
||||
int h,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
GPUTexture *GPU_texture_create_2d(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
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,
|
||||
int w,
|
||||
int h,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
GPUTexture *GPU_texture_create_2d_array(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
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,
|
||||
int w,
|
||||
int h,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat texture_format,
|
||||
eGPUDataFormat data_format,
|
||||
eGPUTextureUsage usage,
|
||||
const void *data)
|
||||
GPUTexture *GPU_texture_create_3d(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat texture_format,
|
||||
eGPUTextureUsage usage,
|
||||
const void *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
name, w, h, d, GPU_TEXTURE_3D, mip_len, texture_format, data_format, 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,
|
||||
int w,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
GPUTexture *GPU_texture_create_cube(const char *name,
|
||||
int w,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
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,
|
||||
int w,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
GPUTexture *GPU_texture_create_cube_array(const char *name,
|
||||
int w,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
eGPUTextureUsage usage,
|
||||
const float *data)
|
||||
{
|
||||
return gpu_texture_create(
|
||||
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,
|
||||
int w,
|
||||
int h,
|
||||
int miplen,
|
||||
eGPUTextureFormat tex_format,
|
||||
eGPUTextureUsage usage,
|
||||
const void *data)
|
||||
GPUTexture *GPU_texture_create_compressed_2d(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int miplen,
|
||||
eGPUTextureFormat tex_format,
|
||||
eGPUTextureUsage usage,
|
||||
const void *data)
|
||||
{
|
||||
Texture *tex = GPUBackend::get()->texture_alloc(name);
|
||||
bool success = tex->init_2D(w, h, 0, miplen, tex_format);
|
||||
|
@ -404,70 +403,6 @@ GPUTexture *GPU_texture_create_compressed_2d_ex(const char *name,
|
|||
return reinterpret_cast<GPUTexture *>(tex);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_1d(
|
||||
const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
|
||||
{
|
||||
return GPU_texture_create_1d_ex(name, w, mip_len, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_1d_array(
|
||||
const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
|
||||
{
|
||||
return GPU_texture_create_1d_array_ex(
|
||||
name, w, h, mip_len, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2d(
|
||||
const char *name, int w, int h, int mips, eGPUTextureFormat format, const float *data)
|
||||
{
|
||||
return GPU_texture_create_2d_ex(name, w, h, mips, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_2d_array(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat format,
|
||||
const float *data)
|
||||
{
|
||||
return GPU_texture_create_2d_array_ex(
|
||||
name, w, h, d, mip_len, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_3d(const char *name,
|
||||
int w,
|
||||
int h,
|
||||
int d,
|
||||
int mip_len,
|
||||
eGPUTextureFormat texture_format,
|
||||
eGPUDataFormat data_format,
|
||||
const void *data)
|
||||
{
|
||||
return GPU_texture_create_3d_ex(
|
||||
name, w, h, d, mip_len, texture_format, data_format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_cube(
|
||||
const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
|
||||
{
|
||||
return GPU_texture_create_cube_ex(name, w, mip_len, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_cube_array(
|
||||
const char *name, int w, int d, int mip_len, eGPUTextureFormat format, const float *data)
|
||||
{
|
||||
return GPU_texture_create_cube_array_ex(
|
||||
name, w, d, mip_len, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_compressed_2d(
|
||||
const char *name, int w, int h, int miplen, eGPUTextureFormat format, const void *data)
|
||||
{
|
||||
return GPU_texture_create_compressed_2d_ex(
|
||||
name, w, h, miplen, format, GPU_TEXTURE_USAGE_GENERAL, data);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_from_vertbuf(const char *name, GPUVertBuf *vert)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
|
@ -534,18 +469,6 @@ GPUTexture *GPU_texture_create_view(const char *name,
|
|||
return wrap(view);
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_create_single_layer_view(const char *name, const GPUTexture *src)
|
||||
{
|
||||
eGPUTextureFormat format = unwrap(src)->format_get();
|
||||
eGPUTextureType type = unwrap(src)->type_get();
|
||||
BLI_assert(ELEM(type, GPU_TEXTURE_1D, GPU_TEXTURE_2D, GPU_TEXTURE_CUBE));
|
||||
type |= GPU_TEXTURE_ARRAY;
|
||||
|
||||
Texture *view = GPUBackend::get()->texture_alloc(name);
|
||||
view->init_view(src, format, type, 0, 9999, 0, 1, false);
|
||||
return wrap(view);
|
||||
}
|
||||
|
||||
/* ------ Usage ------ */
|
||||
eGPUTextureUsage GPU_texture_usage(const GPUTexture *texture_)
|
||||
{
|
||||
|
@ -624,10 +547,7 @@ void GPU_unpack_row_length_set(uint len)
|
|||
|
||||
/* ------ Binding ------ */
|
||||
|
||||
void GPU_texture_bind_ex(GPUTexture *tex_,
|
||||
eGPUSamplerState state,
|
||||
int unit,
|
||||
const bool /*set_number*/)
|
||||
void GPU_texture_bind_ex(GPUTexture *tex_, eGPUSamplerState state, int unit)
|
||||
{
|
||||
Texture *tex = reinterpret_cast<Texture *>(tex_);
|
||||
state = (state >= GPU_SAMPLER_MAX) ? tex->sampler_state : state;
|
||||
|
@ -666,7 +586,7 @@ void GPU_texture_image_unbind_all()
|
|||
Context::get()->state_manager->image_unbind_all();
|
||||
}
|
||||
|
||||
void GPU_texture_generate_mipmap(GPUTexture *tex)
|
||||
void GPU_texture_update_mipmap_chain(GPUTexture *tex)
|
||||
{
|
||||
reinterpret_cast<Texture *>(tex)->generate_mipmap();
|
||||
}
|
||||
|
@ -728,7 +648,7 @@ void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4])
|
|||
|
||||
void GPU_texture_stencil_texture_mode_set(GPUTexture *tex, bool use_stencil)
|
||||
{
|
||||
BLI_assert(GPU_texture_stencil(tex) || !use_stencil);
|
||||
BLI_assert(GPU_texture_has_stencil_format(tex) || !use_stencil);
|
||||
reinterpret_cast<Texture *>(tex)->stencil_texture_mode_set(use_stencil);
|
||||
}
|
||||
|
||||
|
@ -790,17 +710,17 @@ int GPU_texture_mip_count(const GPUTexture *tex)
|
|||
return reinterpret_cast<const Texture *>(tex)->mip_count();
|
||||
}
|
||||
|
||||
int GPU_texture_orig_width(const GPUTexture *tex)
|
||||
int GPU_texture_original_width(const GPUTexture *tex)
|
||||
{
|
||||
return reinterpret_cast<const Texture *>(tex)->src_w;
|
||||
}
|
||||
|
||||
int GPU_texture_orig_height(const GPUTexture *tex)
|
||||
int GPU_texture_original_height(const GPUTexture *tex)
|
||||
{
|
||||
return reinterpret_cast<const Texture *>(tex)->src_h;
|
||||
}
|
||||
|
||||
void GPU_texture_orig_size_set(GPUTexture *tex_, int w, int h)
|
||||
void GPU_texture_original_size_set(GPUTexture *tex_, int w, int h)
|
||||
{
|
||||
Texture *tex = reinterpret_cast<Texture *>(tex_);
|
||||
tex->src_w = w;
|
||||
|
@ -812,9 +732,10 @@ eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
|
|||
return reinterpret_cast<const Texture *>(tex)->format_get();
|
||||
}
|
||||
|
||||
const char *GPU_texture_format_description(eGPUTextureFormat texture_format)
|
||||
const char *GPU_texture_format_name(eGPUTextureFormat texture_format)
|
||||
{
|
||||
switch (texture_format) {
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA8UI:
|
||||
return "RGBA8UI";
|
||||
case GPU_RGBA8I:
|
||||
|
@ -875,24 +796,57 @@ const char *GPU_texture_format_description(eGPUTextureFormat texture_format)
|
|||
return "R16F";
|
||||
case GPU_R16:
|
||||
return "R16";
|
||||
|
||||
/* Special formats texture & render-buffer. */
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
return "RGB10A2";
|
||||
return "RGB10_A2";
|
||||
case GPU_RGB10_A2UI:
|
||||
return "RGB10_A2UI";
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return "R11FG11FB10F";
|
||||
return "R11F_G11F_B10F";
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return "DEPTH32FSTENCIL8";
|
||||
return "DEPTH32F_STENCIL8";
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return "DEPTH24STENCIL8";
|
||||
return "DEPTH24_STENCIL8";
|
||||
case GPU_SRGB8_A8:
|
||||
return "SRGB8A8";
|
||||
|
||||
/* Texture only format */
|
||||
case (GPU_RGB16F):
|
||||
return "SRGB8_A8";
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB16F:
|
||||
return "RGB16F";
|
||||
|
||||
/* Special formats texture only */
|
||||
case GPU_RGB16_SNORM:
|
||||
return "RGB16_SNORM";
|
||||
case GPU_RGB16I:
|
||||
return "RGB16I";
|
||||
case GPU_RGB16UI:
|
||||
return "RGB16UI";
|
||||
case GPU_RGB16:
|
||||
return "RGB16";
|
||||
case GPU_RGBA16_SNORM:
|
||||
return "RGBA16_SNORM";
|
||||
case GPU_RGBA8_SNORM:
|
||||
return "RGBA8_SNORM";
|
||||
case GPU_RGB32F:
|
||||
return "RGB32F";
|
||||
case GPU_RGB32I:
|
||||
return "RGB32I";
|
||||
case GPU_RGB32UI:
|
||||
return "RGB32UI";
|
||||
case GPU_RGB8_SNORM:
|
||||
return "RGB8_SNORM";
|
||||
case GPU_RGB8:
|
||||
return "RGB8";
|
||||
case GPU_RGB8I:
|
||||
return "RGB8I";
|
||||
case GPU_RGB8UI:
|
||||
return "RGB8UI";
|
||||
case GPU_RG16_SNORM:
|
||||
return "RG16_SNORM";
|
||||
case GPU_RG8_SNORM:
|
||||
return "RG8_SNORM";
|
||||
case GPU_R16_SNORM:
|
||||
return "R16_SNORM";
|
||||
case GPU_R8_SNORM:
|
||||
return "R8_SNORM";
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
return "SRGB8_A8_DXT1";
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
|
@ -905,40 +859,43 @@ const char *GPU_texture_format_description(eGPUTextureFormat texture_format)
|
|||
return "RGBA8_DXT3";
|
||||
case GPU_RGBA8_DXT5:
|
||||
return "RGBA8_DXT5";
|
||||
|
||||
/* Depth Formats */
|
||||
case GPU_SRGB8:
|
||||
return "SRGB8";
|
||||
case GPU_RGB9_E5:
|
||||
return "RGB9_E5";
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return "DEPTH32F";
|
||||
return "DEPTH_COMPONENT32F";
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
return "DEPTH24";
|
||||
return "DEPTH_COMPONENT24";
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return "DEPTH16";
|
||||
return "DEPTH_COMPONENT16";
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return "";
|
||||
}
|
||||
|
||||
bool GPU_texture_depth(const GPUTexture *tex)
|
||||
bool GPU_texture_has_depth_format(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_DEPTH) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_stencil(const GPUTexture *tex)
|
||||
bool GPU_texture_has_stencil_format(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_STENCIL) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_integer(const GPUTexture *tex)
|
||||
bool GPU_texture_has_integer_format(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_INTEGER) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_cube(const GPUTexture *tex)
|
||||
bool GPU_texture_is_cube(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_CUBE) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_array(const GPUTexture *tex)
|
||||
bool GPU_texture_is_array(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_ARRAY) != 0;
|
||||
}
|
||||
|
|
|
@ -17,16 +17,27 @@ namespace blender {
|
|||
namespace gpu {
|
||||
|
||||
typedef enum eGPUTextureFormatFlag {
|
||||
/* The format has a depth component and can be used as depth attachment. */
|
||||
GPU_FORMAT_DEPTH = (1 << 0),
|
||||
/* The format has a stencil component and can be used as stencil attachment. */
|
||||
GPU_FORMAT_STENCIL = (1 << 1),
|
||||
/* The format represent non-normalized integers data, either signed or unsigned. */
|
||||
GPU_FORMAT_INTEGER = (1 << 2),
|
||||
GPU_FORMAT_FLOAT = (1 << 3),
|
||||
GPU_FORMAT_COMPRESSED = (1 << 4),
|
||||
/* The format is using normalized integers, either signed or unsigned. */
|
||||
GPU_FORMAT_NORMALIZED_INTEGER = (1 << 3),
|
||||
/* The format represent floating point data, either signed or unsigned. */
|
||||
GPU_FORMAT_FLOAT = (1 << 4),
|
||||
/* The format is using block compression. */
|
||||
GPU_FORMAT_COMPRESSED = (1 << 5),
|
||||
/* The format is using sRGB encoded storage. */
|
||||
GPU_FORMAT_SRGB = (1 << 6),
|
||||
/* The format can store negative values. */
|
||||
GPU_FORMAT_SIGNED = (1 << 7),
|
||||
|
||||
GPU_FORMAT_DEPTH_STENCIL = (GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL),
|
||||
} eGPUTextureFormatFlag;
|
||||
|
||||
ENUM_OPERATORS(eGPUTextureFormatFlag, GPU_FORMAT_DEPTH_STENCIL)
|
||||
ENUM_OPERATORS(eGPUTextureFormatFlag, GPU_FORMAT_SIGNED)
|
||||
|
||||
typedef enum eGPUTextureType {
|
||||
GPU_TEXTURE_1D = (1 << 0),
|
||||
|
@ -265,7 +276,37 @@ class Texture {
|
|||
BLI_assert(slot == 0);
|
||||
return GPU_FB_DEPTH_STENCIL_ATTACHMENT;
|
||||
default:
|
||||
/* Valid color attachment formats. */
|
||||
return GPU_FB_COLOR_ATTACHMENT0 + slot;
|
||||
|
||||
case GPU_RGB16F:
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGBA8_SNORM:
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB32UI:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB16:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RGB8:
|
||||
case GPU_RGB8I:
|
||||
case GPU_RGB8UI:
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
case GPU_R16_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
case GPU_SRGB8:
|
||||
case GPU_RGB9_E5:
|
||||
BLI_assert_msg(0, "Texture cannot be attached to a framebuffer because of its type");
|
||||
return GPU_FB_COLOR_ATTACHMENT0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,54 +364,114 @@ static inline const PixelBuffer *unwrap(const GPUPixelBuffer *pixbuf)
|
|||
inline size_t to_bytesize(eGPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA8:
|
||||
return (4 * 8) / 8;
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA32F:
|
||||
return 32;
|
||||
case GPU_RG32F:
|
||||
return (4 * 32) / 8;
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16:
|
||||
return 16;
|
||||
case GPU_RGB16F:
|
||||
return 12;
|
||||
case GPU_DEPTH32F_STENCIL8: /* 32-bit depth, 8 bits stencil, and 24 unused bits. */
|
||||
return 8;
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16I:
|
||||
return (4 * 16) / 8;
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG8:
|
||||
return (2 * 8) / 8;
|
||||
case GPU_RG32UI:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG32F:
|
||||
return (2 * 32) / 8;
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA8:
|
||||
case GPU_SRGB8_A8:
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_R32F:
|
||||
return (2 * 16) / 8;
|
||||
case GPU_R8UI:
|
||||
case GPU_R8I:
|
||||
case GPU_R8:
|
||||
return 8 / 8;
|
||||
case GPU_R32UI:
|
||||
case GPU_R32I:
|
||||
return 4;
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
return 3;
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_R16F:
|
||||
case GPU_R32F:
|
||||
return 32 / 8;
|
||||
case GPU_R16UI:
|
||||
case GPU_R16I:
|
||||
case GPU_RG8:
|
||||
case GPU_R16F:
|
||||
case GPU_R16:
|
||||
return 2;
|
||||
case GPU_R8:
|
||||
case GPU_R8UI:
|
||||
return 1;
|
||||
return 16 / 8;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_RGB10_A2UI:
|
||||
return (3 * 10 + 2) / 8;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return (11 + 11 + 10) / 8;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
/* 32-bit depth, 8 bits stencil, and 24 unused bits. */
|
||||
return (32 + 8 + 24) / 8;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return (24 + 8) / 8;
|
||||
case GPU_SRGB8_A8:
|
||||
return (3 * 8 + 8) / 8;
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB16F:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB16:
|
||||
return (3 * 16) / 8;
|
||||
case GPU_RGBA16_SNORM:
|
||||
return (4 * 16) / 8;
|
||||
case GPU_RGBA8_SNORM:
|
||||
return (4 * 8) / 8;
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB32UI:
|
||||
return (3 * 32) / 8;
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RGB8:
|
||||
case GPU_RGB8I:
|
||||
case GPU_RGB8UI:
|
||||
return (3 * 8) / 8;
|
||||
case GPU_RG16_SNORM:
|
||||
return (2 * 16) / 8;
|
||||
case GPU_RG8_SNORM:
|
||||
return (2 * 8) / 8;
|
||||
case GPU_R16_SNORM:
|
||||
return (1 * 16) / 8;
|
||||
case GPU_R8_SNORM:
|
||||
return (1 * 8) / 8;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
return 1; /* Incorrect but actual size is fractional. */
|
||||
default:
|
||||
BLI_assert_msg(0, "Texture format incorrect or unsupported");
|
||||
return 0;
|
||||
/* Incorrect but actual size is fractional. */
|
||||
return 1;
|
||||
case GPU_SRGB8:
|
||||
return (3 * 8) / 8;
|
||||
case GPU_RGB9_E5:
|
||||
return (3 * 9 + 5) / 8;
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return 32 / 8;
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
return 24 / 8;
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return 16 / 8;
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline size_t to_block_size(eGPUTextureFormat data_type)
|
||||
|
@ -393,65 +494,235 @@ inline size_t to_block_size(eGPUTextureFormat data_type)
|
|||
inline eGPUTextureFormatFlag to_format_flag(eGPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return GPU_FORMAT_DEPTH;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return GPU_FORMAT_DEPTH_STENCIL;
|
||||
case GPU_R8UI:
|
||||
case GPU_RG16I:
|
||||
case GPU_R16I:
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA8UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RGBA8I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGBA8:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_RGBA32UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RGBA32I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGBA32F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGBA16UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RGBA16I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGBA16F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGBA16:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_RG8UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RG8I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RG8:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_RG32UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RG32I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RG32F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_RG16UI:
|
||||
case GPU_R16UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RG16I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RG16F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_RG16:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_R8UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_R8I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_R8:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_R32UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_R32I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_R32F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_R16UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_R16I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_R16F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_R16:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_RGB10_A2UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return GPU_FORMAT_FLOAT;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return GPU_FORMAT_DEPTH_STENCIL;
|
||||
case GPU_SRGB8_A8:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_SRGB;
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB16F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB16_SNORM:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB16I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB16UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RGB16:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGBA8_SNORM:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB32F:
|
||||
return GPU_FORMAT_FLOAT | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB32I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB32UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RGB8_SNORM:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB8:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER;
|
||||
case GPU_RGB8I:
|
||||
return GPU_FORMAT_INTEGER | GPU_FORMAT_SIGNED;
|
||||
case GPU_RGB8UI:
|
||||
return GPU_FORMAT_INTEGER;
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
case GPU_R16_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_SIGNED;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_COMPRESSED | GPU_FORMAT_SRGB;
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_COMPRESSED;
|
||||
case GPU_SRGB8:
|
||||
return GPU_FORMAT_NORMALIZED_INTEGER | GPU_FORMAT_SRGB;
|
||||
case GPU_RGB9_E5:
|
||||
return GPU_FORMAT_FLOAT;
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return GPU_FORMAT_DEPTH;
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return GPU_FORMAT_FLOAT;
|
||||
}
|
||||
|
||||
inline int to_component_len(eGPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16:
|
||||
return 4;
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG8:
|
||||
case GPU_RG32UI:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
return 2;
|
||||
case GPU_R8UI:
|
||||
case GPU_R8I:
|
||||
case GPU_R8:
|
||||
case GPU_R32UI:
|
||||
case GPU_R32I:
|
||||
case GPU_R32F:
|
||||
case GPU_R16UI:
|
||||
case GPU_R16I:
|
||||
case GPU_R16F:
|
||||
case GPU_R16:
|
||||
return 1;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_RGB10_A2UI:
|
||||
return 4;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return 3;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
/* Only count depth component. */
|
||||
return 1;
|
||||
case GPU_SRGB8_A8:
|
||||
return 4;
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB16F:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB16:
|
||||
return 3;
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGBA8_SNORM:
|
||||
return 4;
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB32UI:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RGB8:
|
||||
case GPU_RGB8I:
|
||||
case GPU_RGB8UI:
|
||||
return 3;
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
return 2;
|
||||
case GPU_R16_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
return 1;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
return GPU_FORMAT_COMPRESSED;
|
||||
default:
|
||||
return GPU_FORMAT_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
inline int to_component_len(eGPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_SRGB8_A8:
|
||||
case GPU_RGB10_A2:
|
||||
return 4;
|
||||
case GPU_RGB16F:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_SRGB8:
|
||||
case GPU_RGB9_E5:
|
||||
return 3;
|
||||
case GPU_RG8:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG16:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG32UI:
|
||||
return 2;
|
||||
default:
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return 1;
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline size_t to_bytesize(eGPUDataFormat data_format)
|
||||
|
@ -469,10 +740,9 @@ inline size_t to_bytesize(eGPUDataFormat data_format)
|
|||
case GPU_DATA_10_11_11_REV:
|
||||
case GPU_DATA_2_10_10_10_REV:
|
||||
return 4;
|
||||
default:
|
||||
BLI_assert_msg(0, "Data format incorrect or unsupported");
|
||||
return 0;
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline size_t to_bytesize(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
|
||||
|
@ -492,172 +762,315 @@ inline size_t to_bytesize(eGPUTextureFormat tex_format, eGPUDataFormat data_form
|
|||
inline bool validate_data_format(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
|
||||
{
|
||||
switch (tex_format) {
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UINT);
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return ELEM(data_format, GPU_DATA_UINT_24_8, GPU_DATA_UINT);
|
||||
case GPU_R16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_R32UI:
|
||||
case GPU_RG32UI:
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA32UI:
|
||||
return data_format == GPU_DATA_UINT;
|
||||
case GPU_R8I:
|
||||
case GPU_RG8I:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_R16I:
|
||||
case GPU_RG16I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_R32I:
|
||||
case GPU_RG32I:
|
||||
case GPU_RGBA32I:
|
||||
return data_format == GPU_DATA_INT;
|
||||
case GPU_R8:
|
||||
case GPU_RG8:
|
||||
case GPU_RGBA8:
|
||||
case GPU_R8UI:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG32UI:
|
||||
case GPU_R32UI:
|
||||
return ELEM(data_format, GPU_DATA_UINT);
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_R16UI:
|
||||
return ELEM(data_format, GPU_DATA_UINT); /* Also GPU_DATA_USHORT if needed. */
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_SRGB8_A8:
|
||||
return ELEM(data_format, GPU_DATA_UBYTE, GPU_DATA_FLOAT);
|
||||
case GPU_RGB10_A2:
|
||||
return ELEM(data_format, GPU_DATA_2_10_10_10_REV, GPU_DATA_FLOAT);
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT);
|
||||
case GPU_RGBA16F:
|
||||
return ELEM(data_format, GPU_DATA_HALF_FLOAT, GPU_DATA_FLOAT);
|
||||
default:
|
||||
return data_format == GPU_DATA_FLOAT;
|
||||
}
|
||||
}
|
||||
case GPU_RG8UI:
|
||||
case GPU_R8UI:
|
||||
return ELEM(data_format, GPU_DATA_UINT, GPU_DATA_UBYTE);
|
||||
|
||||
/* Ensure valid upload formats. With format conversion support, certain types can be extended to
|
||||
* allow upload from differing source formats. If these cases are added, amend accordingly. */
|
||||
inline bool validate_data_format_mtl(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
|
||||
{
|
||||
switch (tex_format) {
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UINT);
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
/* Data can be provided as a 4-byte UINT. */
|
||||
return ELEM(data_format, GPU_DATA_UINT_24_8, GPU_DATA_UINT);
|
||||
case GPU_R8UI:
|
||||
case GPU_R16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_R32UI:
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG32UI:
|
||||
return data_format == GPU_DATA_UINT;
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RG32I:
|
||||
case GPU_R32I:
|
||||
return ELEM(data_format, GPU_DATA_INT);
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RG16I:
|
||||
case GPU_R16I:
|
||||
return ELEM(data_format, GPU_DATA_INT); /* Also GPU_DATA_SHORT if needed. */
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG32I:
|
||||
case GPU_R8I:
|
||||
return data_format == GPU_DATA_INT;
|
||||
case GPU_R8:
|
||||
case GPU_RG8:
|
||||
return ELEM(data_format, GPU_DATA_INT); /* Also GPU_DATA_BYTE if needed. */
|
||||
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RG32F:
|
||||
case GPU_R32F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT);
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RG16F:
|
||||
case GPU_R16F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_HALF_FLOAT);
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG16:
|
||||
case GPU_R16:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT); /* Also GPU_DATA_USHORT if needed. */
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RG8:
|
||||
case GPU_R8:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UBYTE);
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_RGB10_A2UI:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_2_10_10_10_REV);
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_10_11_11_REV);
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
/* Should have its own type. For now, we rely on the backend to do the conversion. */
|
||||
ATTR_FALLTHROUGH;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return ELEM(data_format, GPU_DATA_UINT_24_8, GPU_DATA_UINT);
|
||||
case GPU_SRGB8_A8:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UBYTE);
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB32UI:
|
||||
return ELEM(data_format, GPU_DATA_UINT);
|
||||
case GPU_RGB16UI:
|
||||
return ELEM(data_format, GPU_DATA_UINT); /* Also GPU_DATA_SHORT if needed. */
|
||||
case GPU_RGB8UI:
|
||||
return ELEM(data_format, GPU_DATA_UINT); /* Also GPU_DATA_BYTE if needed. */
|
||||
case GPU_RGB32I:
|
||||
return ELEM(data_format, GPU_DATA_INT);
|
||||
case GPU_RGB16I:
|
||||
return ELEM(data_format, GPU_DATA_INT); /* Also GPU_DATA_USHORT if needed. */
|
||||
case GPU_RGB8I:
|
||||
return ELEM(data_format, GPU_DATA_INT, GPU_DATA_UBYTE);
|
||||
case GPU_RGB16:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT); /* Also GPU_DATA_USHORT if needed. */
|
||||
case GPU_RGB8:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UBYTE);
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_R16_SNORM:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT); /* Also GPU_DATA_SHORT if needed. */
|
||||
case GPU_RGBA8_SNORM:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT); /* Also GPU_DATA_BYTE if needed. */
|
||||
case GPU_RGB32F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT);
|
||||
case GPU_RGB16F:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_HALF_FLOAT);
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
return ELEM(data_format, GPU_DATA_UBYTE, GPU_DATA_FLOAT);
|
||||
case GPU_RGB10_A2:
|
||||
return ELEM(data_format, GPU_DATA_2_10_10_10_REV, GPU_DATA_FLOAT);
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT);
|
||||
case GPU_RGBA16F:
|
||||
return ELEM(data_format, GPU_DATA_HALF_FLOAT, GPU_DATA_FLOAT);
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
case GPU_R32F:
|
||||
case GPU_R16F:
|
||||
case GPU_R16:
|
||||
case GPU_RGB16F:
|
||||
return data_format == GPU_DATA_FLOAT;
|
||||
default:
|
||||
BLI_assert_msg(0, "Unrecognized data format");
|
||||
return data_format == GPU_DATA_FLOAT;
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
/* TODO(fclem): GPU_DATA_COMPRESSED for each compression? Wouldn't it be overkill?
|
||||
* For now, expect format to be set to float. */
|
||||
return ELEM(data_format, GPU_DATA_FLOAT);
|
||||
case GPU_SRGB8:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UBYTE);
|
||||
case GPU_RGB9_E5:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT);
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UINT);
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return data_format == GPU_DATA_FLOAT;
|
||||
}
|
||||
|
||||
/* Return default data format for an internal texture format. */
|
||||
inline eGPUDataFormat to_data_format(eGPUTextureFormat tex_format)
|
||||
{
|
||||
switch (tex_format) {
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return GPU_DATA_UINT_24_8;
|
||||
case GPU_R16UI:
|
||||
case GPU_R32UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG32UI:
|
||||
case GPU_RGBA16UI:
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA32UI:
|
||||
return GPU_DATA_UINT;
|
||||
case GPU_R16I:
|
||||
case GPU_R32I:
|
||||
case GPU_R8I:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG8I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA8I:
|
||||
return GPU_DATA_INT;
|
||||
case GPU_R8:
|
||||
case GPU_R8UI:
|
||||
case GPU_RG8:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RG32UI:
|
||||
case GPU_R32UI:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_R16UI:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_SRGB8_A8:
|
||||
return GPU_DATA_UBYTE;
|
||||
case GPU_RG8UI:
|
||||
case GPU_R8UI:
|
||||
return GPU_DATA_UINT;
|
||||
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RG32I:
|
||||
case GPU_R32I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RG16I:
|
||||
case GPU_R16I:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RG8I:
|
||||
case GPU_R8I:
|
||||
return GPU_DATA_INT;
|
||||
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RG32F:
|
||||
case GPU_R32F:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RG16F:
|
||||
case GPU_R16F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG16:
|
||||
case GPU_R16:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RG8:
|
||||
case GPU_R8:
|
||||
return GPU_DATA_FLOAT;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_RGB10_A2UI:
|
||||
return GPU_DATA_2_10_10_10_REV;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return GPU_DATA_10_11_11_REV;
|
||||
default:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
/* Should have its own type. For now, we rely on the backend to do the conversion. */
|
||||
ATTR_FALLTHROUGH;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return GPU_DATA_UINT_24_8;
|
||||
case GPU_SRGB8_A8:
|
||||
return GPU_DATA_FLOAT;
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB32UI:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB8UI:
|
||||
return GPU_DATA_UINT;
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB8I:
|
||||
return GPU_DATA_INT;
|
||||
case GPU_RGB16:
|
||||
case GPU_RGB8:
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_R16_SNORM:
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_RGBA8_SNORM:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB16F:
|
||||
return GPU_DATA_FLOAT;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
/* TODO(fclem): GPU_DATA_COMPRESSED for each compression? Wouldn't it be overkill?
|
||||
* For now, expect format to be set to float. */
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_SRGB8:
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_RGB9_E5:
|
||||
return GPU_DATA_FLOAT;
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return GPU_DATA_FLOAT;
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return GPU_DATA_FLOAT;
|
||||
}
|
||||
|
||||
inline eGPUFrameBufferBits to_framebuffer_bits(eGPUTextureFormat tex_format)
|
||||
{
|
||||
switch (tex_format) {
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RG32UI:
|
||||
case GPU_R32UI:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_R16UI:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RG8UI:
|
||||
case GPU_R8UI:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RG32I:
|
||||
case GPU_R32I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RG16I:
|
||||
case GPU_R16I:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RG8I:
|
||||
case GPU_R8I:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RG32F:
|
||||
case GPU_R32F:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RG16F:
|
||||
case GPU_R16F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG16:
|
||||
case GPU_R16:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RG8:
|
||||
case GPU_R8:
|
||||
return GPU_COLOR_BIT;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_RGB10_A2UI:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_SRGB8_A8:
|
||||
return GPU_COLOR_BIT;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return GPU_DEPTH_BIT | GPU_STENCIL_BIT;
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return GPU_DEPTH_BIT;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return GPU_DEPTH_BIT | GPU_STENCIL_BIT;
|
||||
default:
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB32UI:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB8UI:
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB8I:
|
||||
case GPU_RGB16:
|
||||
case GPU_RGB8:
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_R16_SNORM:
|
||||
case GPU_RGBA8_SNORM:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB16F:
|
||||
BLI_assert_msg(0, "This texture format is not compatible with framebuffer attachment.");
|
||||
return GPU_COLOR_BIT;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
case GPU_SRGB8:
|
||||
case GPU_RGB9_E5:
|
||||
BLI_assert_msg(0, "This texture format is not compatible with framebuffer attachment.");
|
||||
return GPU_COLOR_BIT;
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return GPU_COLOR_BIT;
|
||||
}
|
||||
|
||||
static inline eGPUTextureFormat to_texture_format(const GPUVertFormat *format)
|
||||
|
|
|
@ -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
|
||||
* 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);
|
||||
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);
|
||||
|
||||
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) {
|
||||
viewport->color_render_tx[1] = GPU_texture_create_2d_ex("dtxl_color_stereo",
|
||||
UNPACK2(size),
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
usage | GPU_TEXTURE_USAGE_SHADER_WRITE,
|
||||
NULL);
|
||||
viewport->color_overlay_tx[1] = GPU_texture_create_2d_ex(
|
||||
viewport->color_render_tx[1] = GPU_texture_create_2d("dtxl_color_stereo",
|
||||
UNPACK2(size),
|
||||
1,
|
||||
GPU_RGBA16F,
|
||||
usage | GPU_TEXTURE_USAGE_SHADER_WRITE,
|
||||
NULL);
|
||||
viewport->color_overlay_tx[1] = GPU_texture_create_2d(
|
||||
"dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, usage, NULL);
|
||||
|
||||
if (GPU_clear_viewport_workaround()) {
|
||||
|
@ -156,12 +156,12 @@ static void gpu_viewport_textures_create(GPUViewport *viewport)
|
|||
/* Can be shared with GPUOffscreen. */
|
||||
if (viewport->depth_tx == NULL) {
|
||||
/* Depth texture can be read back by gizmos #view3d_depths_create .*/
|
||||
viewport->depth_tx = GPU_texture_create_2d_ex("dtxl_depth",
|
||||
UNPACK2(size),
|
||||
1,
|
||||
GPU_DEPTH24_STENCIL8,
|
||||
usage | GPU_TEXTURE_USAGE_HOST_READ,
|
||||
NULL);
|
||||
viewport->depth_tx = GPU_texture_create_2d("dtxl_depth",
|
||||
UNPACK2(size),
|
||||
1,
|
||||
GPU_DEPTH24_STENCIL8,
|
||||
usage | GPU_TEXTURE_USAGE_HOST_READ,
|
||||
NULL);
|
||||
if (GPU_clear_viewport_workaround()) {
|
||||
static int depth_clear = 0;
|
||||
GPU_texture_clear(viewport->depth_tx, GPU_DATA_UINT_24_8, &depth_clear);
|
||||
|
|
|
@ -106,8 +106,8 @@ void MTLContext::set_ghost_context(GHOST_ContextHandle ghostCtxHandle)
|
|||
|
||||
/* Add default texture for cases where no other framebuffer is bound */
|
||||
if (!default_fbo_gputexture_) {
|
||||
default_fbo_gputexture_ = static_cast<gpu::MTLTexture *>(
|
||||
unwrap(GPU_texture_create_2d(__func__, 16, 16, 1, GPU_RGBA16F, nullptr)));
|
||||
default_fbo_gputexture_ = static_cast<gpu::MTLTexture *>(unwrap(GPU_texture_create_2d(
|
||||
__func__, 16, 16, 1, GPU_RGBA16F, GPU_TEXTURE_USAGE_GENERAL, nullptr)));
|
||||
}
|
||||
mtl_back_left->add_color_attachment(default_fbo_gputexture_, 0, 0, 0);
|
||||
|
||||
|
@ -548,27 +548,28 @@ gpu::MTLTexture *MTLContext::get_dummy_texture(eGPUTextureType type,
|
|||
|
||||
/* Create dummy texture based on desired type. */
|
||||
GPUTexture *tex = nullptr;
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
|
||||
switch (type) {
|
||||
case GPU_TEXTURE_1D:
|
||||
tex = GPU_texture_create_1d("Dummy 1D", 128, 1, format, nullptr);
|
||||
tex = GPU_texture_create_1d("Dummy 1D", 128, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_1D_ARRAY:
|
||||
tex = GPU_texture_create_1d_array("Dummy 1DArray", 128, 1, 1, format, nullptr);
|
||||
tex = GPU_texture_create_1d_array("Dummy 1DArray", 128, 1, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_2D:
|
||||
tex = GPU_texture_create_2d("Dummy 2D", 128, 128, 1, format, nullptr);
|
||||
tex = GPU_texture_create_2d("Dummy 2D", 128, 128, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_2D_ARRAY:
|
||||
tex = GPU_texture_create_2d_array("Dummy 2DArray", 128, 128, 1, 1, format, nullptr);
|
||||
tex = GPU_texture_create_2d_array("Dummy 2DArray", 128, 128, 1, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_3D:
|
||||
tex = GPU_texture_create_3d("Dummy 3D", 128, 128, 1, 1, format, GPU_DATA_UBYTE, nullptr);
|
||||
tex = GPU_texture_create_3d("Dummy 3D", 128, 128, 1, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_CUBE:
|
||||
tex = GPU_texture_create_cube("Dummy Cube", 128, 1, format, nullptr);
|
||||
tex = GPU_texture_create_cube("Dummy Cube", 128, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_CUBE_ARRAY:
|
||||
tex = GPU_texture_create_cube_array("Dummy CubeArray", 128, 1, 1, format, nullptr);
|
||||
tex = GPU_texture_create_cube_array("Dummy CubeArray", 128, 1, 1, format, usage, nullptr);
|
||||
break;
|
||||
case GPU_TEXTURE_BUFFER:
|
||||
if (!dummy_verts_[sampler_format]) {
|
||||
|
|
|
@ -558,60 +558,6 @@ inline MTLPixelFormat mtl_format_get_writeable_view_format(MTLPixelFormat format
|
|||
return format;
|
||||
}
|
||||
|
||||
/* Returns the associated engine data type with a given texture:
|
||||
* Definitely not complete, edit according to the METAL specification. */
|
||||
inline eGPUDataFormat to_mtl_internal_data_format(eGPUTextureFormat tex_format)
|
||||
{
|
||||
switch (tex_format) {
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG8:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
case GPU_R8:
|
||||
case GPU_R32F:
|
||||
case GPU_R16F:
|
||||
case GPU_R16:
|
||||
case GPU_RGB16F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_SRGB8_A8:
|
||||
return GPU_DATA_FLOAT;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return GPU_DATA_UINT_24_8;
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG32UI:
|
||||
case GPU_R8UI:
|
||||
case GPU_R16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_R32UI:
|
||||
return GPU_DATA_UINT;
|
||||
case GPU_R8I:
|
||||
case GPU_RG8I:
|
||||
case GPU_R16I:
|
||||
case GPU_R32I:
|
||||
case GPU_RG16I:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RG32I:
|
||||
return GPU_DATA_INT;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return GPU_DATA_10_11_11_REV;
|
||||
default:
|
||||
BLI_assert(false && "Texture not yet handled");
|
||||
return GPU_DATA_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
inline MTLTextureUsage mtl_usage_from_gpu(eGPUTextureUsage usage)
|
||||
{
|
||||
MTLTextureUsage mtl_usage = MTLTextureUsageUnknown;
|
||||
|
|
|
@ -275,7 +275,7 @@ void gpu::MTLTexture::blit(id<MTLBlitCommandEncoder> blit_encoder,
|
|||
uint depth)
|
||||
{
|
||||
|
||||
BLI_assert(this && dest);
|
||||
BLI_assert(dest);
|
||||
BLI_assert(width > 0 && height > 0 && depth > 0);
|
||||
MTLSize src_size = MTLSizeMake(width, height, depth);
|
||||
MTLOrigin src_origin = MTLOriginMake(src_x_offset, src_y_offset, src_z_offset);
|
||||
|
@ -1347,7 +1347,7 @@ void *gpu::MTLTexture::read(int mip, eGPUDataFormat type)
|
|||
/* Prepare Array for return data. */
|
||||
BLI_assert(!(format_flag_ & GPU_FORMAT_COMPRESSED));
|
||||
BLI_assert(mip <= mipmaps_);
|
||||
BLI_assert(validate_data_format_mtl(format_, type));
|
||||
BLI_assert(validate_data_format(format_, type));
|
||||
|
||||
/* NOTE: mip_size_get() won't override any dimension that is equal to 0. */
|
||||
int extent[3] = {1, 1, 1};
|
||||
|
@ -1406,7 +1406,7 @@ void gpu::MTLTexture::read_internal(int mip,
|
|||
bool is_depth_format = (format_flag_ & GPU_FORMAT_DEPTH);
|
||||
|
||||
/* Verify if we need to use compute read. */
|
||||
eGPUDataFormat data_format = to_mtl_internal_data_format(this->format_get());
|
||||
eGPUDataFormat data_format = to_data_format(this->format_get());
|
||||
bool format_conversion_needed = (data_format != desired_output_format);
|
||||
bool can_use_simple_read = (desired_output_bpp == image_bpp) && (!format_conversion_needed) &&
|
||||
(num_output_components == image_components);
|
||||
|
@ -1420,7 +1420,7 @@ void gpu::MTLTexture::read_internal(int mip,
|
|||
BLI_assert(num_output_components == 1);
|
||||
BLI_assert(image_components == 1);
|
||||
BLI_assert(data_format == GPU_DATA_FLOAT || data_format == GPU_DATA_UINT_24_8);
|
||||
BLI_assert(validate_data_format_mtl(format_, data_format));
|
||||
BLI_assert(validate_data_format(format_, data_format));
|
||||
}
|
||||
|
||||
/* SPECIAL Workaround for R11G11B10 textures requesting a read using: GPU_DATA_10_11_11_REV. */
|
||||
|
|
|
@ -32,9 +32,8 @@ namespace blender::gpu {
|
|||
|
||||
MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format)
|
||||
{
|
||||
|
||||
switch (tex_format) {
|
||||
/* Formats texture & render-buffer. */
|
||||
/* Texture & Render-Buffer Formats. */
|
||||
case GPU_RGBA8UI:
|
||||
return MTLPixelFormatRGBA8Uint;
|
||||
case GPU_RGBA8I:
|
||||
|
@ -74,7 +73,7 @@ MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format)
|
|||
case GPU_RG16F:
|
||||
return MTLPixelFormatRG16Float;
|
||||
case GPU_RG16:
|
||||
return MTLPixelFormatRG16Float;
|
||||
return MTLPixelFormatRG16Unorm;
|
||||
case GPU_R8UI:
|
||||
return MTLPixelFormatR8Uint;
|
||||
case GPU_R8I:
|
||||
|
@ -94,38 +93,100 @@ MTLPixelFormat gpu_texture_format_to_metal(eGPUTextureFormat tex_format)
|
|||
case GPU_R16F:
|
||||
return MTLPixelFormatR16Float;
|
||||
case GPU_R16:
|
||||
return MTLPixelFormatR16Snorm;
|
||||
|
||||
/* Special formats texture & renderbuffer. */
|
||||
return MTLPixelFormatR16Unorm;
|
||||
/* Special formats texture & renderbuffer */
|
||||
case GPU_RGB10_A2:
|
||||
return MTLPixelFormatRGB10A2Unorm;
|
||||
case GPU_RGB10_A2UI:
|
||||
return MTLPixelFormatRGB10A2Uint;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return MTLPixelFormatRG11B10Float;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return MTLPixelFormatDepth32Float_Stencil8;
|
||||
case GPU_DEPTH24_STENCIL8: {
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
BLI_assert_msg(false, "GPU_DEPTH24_STENCIL8 not supported by Apple Silicon.");
|
||||
return MTLPixelFormatDepth24Unorm_Stencil8;
|
||||
}
|
||||
case GPU_SRGB8_A8:
|
||||
return MTLPixelFormatRGBA8Unorm_sRGB;
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB16F:
|
||||
/* 48-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA16Float;
|
||||
|
||||
case GPU_RGBA16_SNORM:
|
||||
return MTLPixelFormatRGBA16Snorm;
|
||||
case GPU_RGBA8_SNORM:
|
||||
return MTLPixelFormatRGBA8Snorm;
|
||||
case GPU_RGB32F:
|
||||
/* 96-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA32Float;
|
||||
case GPU_RGB32I:
|
||||
/* 96-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA32Sint;
|
||||
case GPU_RGB32UI:
|
||||
/* 96-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA32Uint;
|
||||
case GPU_RGB16_SNORM:
|
||||
/* 48-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA16Snorm;
|
||||
case GPU_RGB16I:
|
||||
/* 48-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA16Sint;
|
||||
case GPU_RGB16UI:
|
||||
/* 48-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA16Uint;
|
||||
case GPU_RGB16:
|
||||
/* 48-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA16Unorm;
|
||||
case GPU_RGB8_SNORM:
|
||||
/* 24-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA8Snorm;
|
||||
case GPU_RGB8:
|
||||
/* 24-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA8Unorm;
|
||||
case GPU_RGB8I:
|
||||
/* 24-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA8Sint;
|
||||
case GPU_RGB8UI:
|
||||
/* 24-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA8Uint;
|
||||
case GPU_RG16_SNORM:
|
||||
return MTLPixelFormatRG16Snorm;
|
||||
case GPU_RG8_SNORM:
|
||||
return MTLPixelFormatRG8Snorm;
|
||||
case GPU_R16_SNORM:
|
||||
return MTLPixelFormatR16Snorm;
|
||||
case GPU_R8_SNORM:
|
||||
return MTLPixelFormatR8Snorm;
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
BLI_assert_msg(false, "Compressed texture not implemented yet!\n");
|
||||
return MTLPixelFormatRGBA8Unorm;
|
||||
case GPU_SRGB8:
|
||||
/* 24-Bit pixel format are not supported. Emulate using a padded type with alpha. */
|
||||
return MTLPixelFormatRGBA8Unorm_sRGB;
|
||||
case GPU_RGB9_E5:
|
||||
return MTLPixelFormatRGB9E5Float;
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return MTLPixelFormatDepth32Float;
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
/* This formal is not supported on Metal.
|
||||
* Use 32Float depth instead with some conversion steps for download and upload. */
|
||||
return MTLPixelFormatDepth32Float;
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return MTLPixelFormatDepth16Unorm;
|
||||
|
||||
default:
|
||||
BLI_assert_msg(false, "Unrecognised GPU pixel format!\n");
|
||||
return MTLPixelFormatRGBA8Unorm;
|
||||
}
|
||||
BLI_assert_msg(false, "Unrecognised GPU pixel format!\n");
|
||||
return MTLPixelFormatRGBA8Unorm;
|
||||
}
|
||||
|
||||
int get_mtl_format_bytesize(MTLPixelFormat tex_format)
|
||||
{
|
||||
|
||||
switch (tex_format) {
|
||||
case MTLPixelFormatRGBA8Uint:
|
||||
case MTLPixelFormatRGBA8Sint:
|
||||
|
@ -184,7 +245,6 @@ int get_mtl_format_bytesize(MTLPixelFormat tex_format)
|
|||
|
||||
int get_mtl_format_num_components(MTLPixelFormat tex_format)
|
||||
{
|
||||
|
||||
switch (tex_format) {
|
||||
case MTLPixelFormatRGBA8Uint:
|
||||
case MTLPixelFormatRGBA8Sint:
|
||||
|
@ -485,7 +545,7 @@ void gpu::MTLTexture::update_sub_depth_2d(
|
|||
GPU_DEPTH_COMPONENT16,
|
||||
GPU_DEPTH24_STENCIL8,
|
||||
GPU_DEPTH32F_STENCIL8));
|
||||
BLI_assert(validate_data_format_mtl(format_, type));
|
||||
BLI_assert(validate_data_format(format_, type));
|
||||
BLI_assert(ELEM(type, GPU_DATA_FLOAT, GPU_DATA_UINT_24_8, GPU_DATA_UINT));
|
||||
|
||||
/* Determine whether we are in GPU_DATA_UINT_24_8 or GPU_DATA_FLOAT mode. */
|
||||
|
@ -513,14 +573,14 @@ void gpu::MTLTexture::update_sub_depth_2d(
|
|||
}
|
||||
|
||||
/* 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",
|
||||
w_,
|
||||
h_,
|
||||
1,
|
||||
format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_ATTACHMENT,
|
||||
nullptr);
|
||||
GPUTexture *r32_tex_tmp = GPU_texture_create_2d("depth_intermediate_copy_tex",
|
||||
w_,
|
||||
h_,
|
||||
1,
|
||||
format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_ATTACHMENT,
|
||||
nullptr);
|
||||
GPU_texture_filter_mode(r32_tex_tmp, false);
|
||||
GPU_texture_wrap_mode(r32_tex_tmp, false, true);
|
||||
gpu::MTLTexture *mtl_tex = static_cast<gpu::MTLTexture *>(unwrap(r32_tex_tmp));
|
||||
|
|
|
@ -162,7 +162,8 @@ void GLFrameBuffer::update_attachments()
|
|||
continue;
|
||||
}
|
||||
GLuint gl_tex = static_cast<GLTexture *>(unwrap(attach.tex))->tex_id_;
|
||||
if (attach.layer > -1 && GPU_texture_cube(attach.tex) && !GPU_texture_array(attach.tex)) {
|
||||
if (attach.layer > -1 && GPU_texture_is_cube(attach.tex) &&
|
||||
!GPU_texture_is_array(attach.tex)) {
|
||||
/* Could be avoided if ARB_direct_state_access is required. In this case
|
||||
* #glFramebufferTextureLayer would bind the correct face. */
|
||||
GLenum gl_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach.layer;
|
||||
|
|
|
@ -109,10 +109,8 @@ class GLPixelBuffer : public PixelBuffer {
|
|||
|
||||
inline GLenum to_gl_internal_format(eGPUTextureFormat format)
|
||||
{
|
||||
/* You can add any of the available type to this list
|
||||
* For available types see GPU_texture.h */
|
||||
switch (format) {
|
||||
/* Formats texture & renderbuffer */
|
||||
/* Texture & Render-Buffer Formats. */
|
||||
case GPU_RGBA8UI:
|
||||
return GL_RGBA8UI;
|
||||
case GPU_RGBA8I:
|
||||
|
@ -176,6 +174,8 @@ inline GLenum to_gl_internal_format(eGPUTextureFormat format)
|
|||
/* Special formats texture & renderbuffer */
|
||||
case GPU_RGB10_A2:
|
||||
return GL_RGB10_A2;
|
||||
case GPU_RGB10_A2UI:
|
||||
return GL_RGB10_A2UI;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return GL_R11F_G11F_B10F;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
|
@ -184,10 +184,44 @@ inline GLenum to_gl_internal_format(eGPUTextureFormat format)
|
|||
return GL_DEPTH24_STENCIL8;
|
||||
case GPU_SRGB8_A8:
|
||||
return GL_SRGB8_ALPHA8;
|
||||
/* Texture only format */
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB16F:
|
||||
return GL_RGB16F;
|
||||
/* Special formats texture only */
|
||||
case GPU_RGBA16_SNORM:
|
||||
return GL_RGBA16_SNORM;
|
||||
case GPU_RGBA8_SNORM:
|
||||
return GL_RGBA8_SNORM;
|
||||
case GPU_RGB32F:
|
||||
return GL_RGB32F;
|
||||
case GPU_RGB32I:
|
||||
return GL_RGB32I;
|
||||
case GPU_RGB32UI:
|
||||
return GL_RGB32UI;
|
||||
case GPU_RGB16_SNORM:
|
||||
return GL_RGB16_SNORM;
|
||||
case GPU_RGB16I:
|
||||
return GL_RGB16I;
|
||||
case GPU_RGB16UI:
|
||||
return GL_RGB16UI;
|
||||
case GPU_RGB16:
|
||||
return GL_RGB16;
|
||||
case GPU_RGB8_SNORM:
|
||||
return GL_RGB8_SNORM;
|
||||
case GPU_RGB8:
|
||||
return GL_RGB8;
|
||||
case GPU_RGB8I:
|
||||
return GL_RGB8I;
|
||||
case GPU_RGB8UI:
|
||||
return GL_RGB8UI;
|
||||
case GPU_RG16_SNORM:
|
||||
return GL_RG16_SNORM;
|
||||
case GPU_RG8_SNORM:
|
||||
return GL_RG8_SNORM;
|
||||
case GPU_R16_SNORM:
|
||||
return GL_R16_SNORM;
|
||||
case GPU_R8_SNORM:
|
||||
return GL_R8_SNORM;
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
|
@ -200,17 +234,20 @@ inline GLenum to_gl_internal_format(eGPUTextureFormat format)
|
|||
return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
case GPU_RGBA8_DXT5:
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
/* Depth Formats */
|
||||
case GPU_SRGB8:
|
||||
return GL_SRGB8;
|
||||
case GPU_RGB9_E5:
|
||||
return GL_RGB9_E5;
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return GL_DEPTH_COMPONENT32F;
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
return GL_DEPTH_COMPONENT24;
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return GL_DEPTH_COMPONENT16;
|
||||
default:
|
||||
BLI_assert_msg(0, "Texture format incorrect or unsupported");
|
||||
return 0;
|
||||
}
|
||||
BLI_assert_msg(0, "Texture format incorrect or unsupported");
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline GLenum to_gl_target(eGPUTextureType type)
|
||||
|
@ -310,62 +347,80 @@ inline GLenum to_gl(eGPUDataFormat format)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Definitely not complete, edit according to the OpenGL specification.
|
||||
*/
|
||||
inline GLenum to_gl_data_format(eGPUTextureFormat format)
|
||||
{
|
||||
/* You can add any of the available type to this list
|
||||
* For available types see GPU_texture.h */
|
||||
switch (format) {
|
||||
case GPU_R8I:
|
||||
case GPU_R8UI:
|
||||
case GPU_R16I:
|
||||
case GPU_R16UI:
|
||||
case GPU_R32I:
|
||||
case GPU_R32UI:
|
||||
return GL_RED_INTEGER;
|
||||
case GPU_RG8I:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG32UI:
|
||||
return GL_RG_INTEGER;
|
||||
case GPU_RGBA8I:
|
||||
/* Texture & Render-Buffer Formats. */
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16:
|
||||
return GL_RGBA;
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA16I:
|
||||
return GL_RGBA_INTEGER;
|
||||
case GPU_R8:
|
||||
case GPU_R16:
|
||||
case GPU_R16F:
|
||||
case GPU_R32F:
|
||||
return GL_RED;
|
||||
case GPU_RG8:
|
||||
case GPU_RG16:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
return GL_RG;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_RGB16F:
|
||||
return GL_RGB;
|
||||
case GPU_RGBA8:
|
||||
case GPU_SRGB8_A8:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG32UI:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG16UI:
|
||||
return GL_RG_INTEGER;
|
||||
case GPU_R8:
|
||||
case GPU_R32F:
|
||||
case GPU_R16F:
|
||||
case GPU_R16:
|
||||
return GL_RED;
|
||||
case GPU_R8UI:
|
||||
case GPU_R8I:
|
||||
case GPU_R32UI:
|
||||
case GPU_R32I:
|
||||
case GPU_R16UI:
|
||||
case GPU_R16I:
|
||||
return GL_RED_INTEGER;
|
||||
/* Special formats texture & renderbuffer */
|
||||
case GPU_RGB10_A2UI:
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_SRGB8_A8:
|
||||
return GL_RGBA;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
return GL_RGB;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return GL_DEPTH_STENCIL;
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return GL_DEPTH_COMPONENT;
|
||||
/* Texture only formats. */
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGBA8_SNORM:
|
||||
return GL_RGBA;
|
||||
case GPU_RGB16F:
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB32UI:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB16:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RGB8:
|
||||
case GPU_RGB8I:
|
||||
case GPU_RGB8UI:
|
||||
return GL_RGB;
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
return GL_RG;
|
||||
case GPU_R16_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
return GL_RED;
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
|
@ -378,10 +433,17 @@ inline GLenum to_gl_data_format(eGPUTextureFormat format)
|
|||
return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
case GPU_RGBA8_DXT5:
|
||||
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
default:
|
||||
BLI_assert_msg(0, "Texture format incorrect or unsupported\n");
|
||||
return 0;
|
||||
case GPU_SRGB8:
|
||||
case GPU_RGB9_E5:
|
||||
return GL_RGB;
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return GL_DEPTH_COMPONENT;
|
||||
}
|
||||
BLI_assert_msg(0, "Texture format incorrect or unsupported\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@ static void test_gpu_shader_compute_2d()
|
|||
|
||||
/* Create texture to store result and attach to shader. */
|
||||
GPUTexture *texture = GPU_texture_create_2d(
|
||||
"gpu_shader_compute_2d", SIZE, SIZE, 1, GPU_RGBA32F, nullptr);
|
||||
"gpu_shader_compute_2d", SIZE, SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
|
||||
EXPECT_NE(texture, nullptr);
|
||||
|
||||
GPU_shader_bind(shader);
|
||||
|
@ -89,7 +89,7 @@ static void test_gpu_shader_compute_1d()
|
|||
|
||||
/* Construct Texture. */
|
||||
GPUTexture *texture = GPU_texture_create_1d(
|
||||
"gpu_shader_compute_1d", SIZE, 1, GPU_RGBA32F, nullptr);
|
||||
"gpu_shader_compute_1d", SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
|
||||
EXPECT_NE(texture, nullptr);
|
||||
|
||||
GPU_shader_bind(shader);
|
||||
|
@ -278,9 +278,9 @@ static void test_gpu_texture_read()
|
|||
GPU_render_begin();
|
||||
|
||||
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 *rgba16u = GPU_texture_create_2d_ex("rgba16u", 1, 1, 1, GPU_RGBA16UI, usage, nullptr);
|
||||
GPUTexture *rgba32f = GPU_texture_create_2d_ex("rgba32f", 1, 1, 1, GPU_RGBA32F, usage, nullptr);
|
||||
GPUTexture *rgba32u = GPU_texture_create_2d("rgba32u", 1, 1, 1, GPU_RGBA32UI, usage, nullptr);
|
||||
GPUTexture *rgba16u = GPU_texture_create_2d("rgba16u", 1, 1, 1, GPU_RGBA16UI, 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 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);
|
||||
|
||||
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);
|
||||
GPUFrameBuffer *fb = GPU_framebuffer_create("test_fb");
|
||||
GPU_framebuffer_ensure_config(&fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(tex)});
|
||||
|
|
|
@ -11,121 +11,234 @@ namespace blender::gpu {
|
|||
VkImageAspectFlagBits to_vk_image_aspect_flag_bits(const eGPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA8:
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG8:
|
||||
case GPU_RG32UI:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
case GPU_R8UI:
|
||||
case GPU_R8I:
|
||||
case GPU_R8:
|
||||
case GPU_R32UI:
|
||||
case GPU_R32I:
|
||||
case GPU_R32F:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RG16UI:
|
||||
case GPU_R16UI:
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RG8UI:
|
||||
case GPU_R8UI:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RG32I:
|
||||
case GPU_R32I:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RG16I:
|
||||
case GPU_R16I:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RG8I:
|
||||
case GPU_R8I:
|
||||
case GPU_RGBA32F:
|
||||
case GPU_RG32F:
|
||||
case GPU_R32F:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RG16F:
|
||||
case GPU_R16F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG16:
|
||||
case GPU_R16:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RG8:
|
||||
case GPU_R8:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
case GPU_RGB10_A2UI:
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_SRGB8_A8:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return static_cast<VkImageAspectFlagBits>(VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB32UI:
|
||||
case GPU_RGB16UI:
|
||||
case GPU_RGB8UI:
|
||||
case GPU_RGB32I:
|
||||
case GPU_RGB16I:
|
||||
case GPU_RGB8I:
|
||||
case GPU_RGB16:
|
||||
case GPU_RGB8:
|
||||
case GPU_RGBA16_SNORM:
|
||||
case GPU_RGB16_SNORM:
|
||||
case GPU_RG16_SNORM:
|
||||
case GPU_R16_SNORM:
|
||||
case GPU_RGBA8_SNORM:
|
||||
case GPU_RGB8_SNORM:
|
||||
case GPU_RG8_SNORM:
|
||||
case GPU_R8_SNORM:
|
||||
case GPU_RGB32F:
|
||||
case GPU_RGB16F:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
case GPU_SRGB8:
|
||||
case GPU_RGB9_E5:
|
||||
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return static_cast<VkImageAspectFlagBits>(VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
/* Not supported by Vulkan*/
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return static_cast<VkImageAspectFlagBits>(0);
|
||||
}
|
||||
|
||||
VkFormat to_vk_format(const eGPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
/* Formats texture & render-buffer */
|
||||
case GPU_RGBA32UI:
|
||||
return VK_FORMAT_R32G32B32A32_UINT;
|
||||
case GPU_RG32UI:
|
||||
return VK_FORMAT_R32G32_UINT;
|
||||
case GPU_R32UI:
|
||||
return VK_FORMAT_R32_UINT;
|
||||
case GPU_RGBA16UI:
|
||||
return VK_FORMAT_R16G16B16A16_UINT;
|
||||
case GPU_RG16UI:
|
||||
return VK_FORMAT_R16G16_UINT;
|
||||
case GPU_R16UI:
|
||||
return VK_FORMAT_R16_UINT;
|
||||
case GPU_RGBA8UI:
|
||||
return VK_FORMAT_R8G8B8A8_UINT;
|
||||
case GPU_RG8UI:
|
||||
return VK_FORMAT_R8G8_UINT;
|
||||
case GPU_R8UI:
|
||||
return VK_FORMAT_R8_UINT;
|
||||
case GPU_RGBA32I:
|
||||
return VK_FORMAT_R32G32B32A32_SINT;
|
||||
case GPU_RG32I:
|
||||
return VK_FORMAT_R32G32_SINT;
|
||||
case GPU_R32I:
|
||||
return VK_FORMAT_R32_SINT;
|
||||
case GPU_RGBA16I:
|
||||
return VK_FORMAT_R16G16B16A16_SINT;
|
||||
case GPU_RG16I:
|
||||
return VK_FORMAT_R16G16_SINT;
|
||||
case GPU_R16I:
|
||||
return VK_FORMAT_R16_SINT;
|
||||
case GPU_RGBA8I:
|
||||
return VK_FORMAT_R8G8B8A8_SINT;
|
||||
case GPU_RG8I:
|
||||
return VK_FORMAT_R8G8_SINT;
|
||||
case GPU_R8I:
|
||||
return VK_FORMAT_R8_SINT;
|
||||
case GPU_RGBA32F:
|
||||
return VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||
case GPU_RGBA8UI:
|
||||
case GPU_RGBA8I:
|
||||
case GPU_RGBA8:
|
||||
case GPU_RGBA32UI:
|
||||
case GPU_RGBA32I:
|
||||
case GPU_RGBA16UI:
|
||||
case GPU_RGBA16I:
|
||||
case GPU_RGBA16F:
|
||||
case GPU_RGBA16:
|
||||
case GPU_RG8UI:
|
||||
case GPU_RG8I:
|
||||
case GPU_RG8:
|
||||
case GPU_RG32UI:
|
||||
case GPU_RG32I:
|
||||
case GPU_RG32F:
|
||||
case GPU_RG16UI:
|
||||
case GPU_RG16I:
|
||||
case GPU_RG16F:
|
||||
case GPU_RG16:
|
||||
case GPU_R8UI:
|
||||
case GPU_R8I:
|
||||
case GPU_R8:
|
||||
case GPU_R32UI:
|
||||
case GPU_R32I:
|
||||
return VK_FORMAT_R32G32_SFLOAT;
|
||||
case GPU_R32F:
|
||||
case GPU_R16UI:
|
||||
case GPU_R16I:
|
||||
return VK_FORMAT_R32_SFLOAT;
|
||||
case GPU_RGBA16F:
|
||||
return VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
case GPU_RG16F:
|
||||
return VK_FORMAT_R16G16_SFLOAT;
|
||||
case GPU_R16F:
|
||||
return VK_FORMAT_R16_SFLOAT;
|
||||
case GPU_RGBA16:
|
||||
return VK_FORMAT_R16G16B16A16_UNORM;
|
||||
case GPU_RG16:
|
||||
return VK_FORMAT_R16G16_UNORM;
|
||||
case GPU_R16:
|
||||
return VK_FORMAT_R16_UNORM;
|
||||
case GPU_RGBA8:
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case GPU_RG8:
|
||||
return VK_FORMAT_R8G8_UNORM;
|
||||
case GPU_R8:
|
||||
return VK_FORMAT_R8_UNORM;
|
||||
|
||||
/* Special formats texture & render-buffer */
|
||||
case GPU_RGB10_A2:
|
||||
return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
|
||||
case GPU_RGB10_A2UI:
|
||||
return VK_FORMAT_A2B10G10R10_UINT_PACK32;
|
||||
case GPU_R11F_G11F_B10F:
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return VK_FORMAT_B10G11R11_UFLOAT_PACK32;
|
||||
case GPU_SRGB8_A8:
|
||||
return VK_FORMAT_R8G8B8A8_SRGB;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
case GPU_DEPTH24_STENCIL8:
|
||||
return VK_FORMAT_D24_UNORM_S8_UINT;
|
||||
|
||||
/* Texture only format */
|
||||
case GPU_RGB16F:
|
||||
|
||||
/* Special formats texture only */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
case GPU_RGBA8_DXT1:
|
||||
case GPU_RGBA8_DXT3:
|
||||
case GPU_RGBA8_DXT5:
|
||||
|
||||
/* Depth Formats */
|
||||
/* Depth Formats. */
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
return VK_FORMAT_D32_SFLOAT;
|
||||
case GPU_DEPTH_COMPONENT24:
|
||||
return VK_FORMAT_X8_D24_UNORM_PACK32;
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
BLI_assert_unreachable();
|
||||
return VK_FORMAT_D16_UNORM;
|
||||
|
||||
/* Texture only formats. */
|
||||
case GPU_RGB32UI:
|
||||
return VK_FORMAT_R32G32B32_UINT;
|
||||
case GPU_RGB16UI:
|
||||
return VK_FORMAT_R16G16B16_UINT;
|
||||
case GPU_RGB8UI:
|
||||
return VK_FORMAT_R8G8B8_UINT;
|
||||
case GPU_RGB32I:
|
||||
return VK_FORMAT_R32G32B32_SINT;
|
||||
case GPU_RGB16I:
|
||||
return VK_FORMAT_R16G16B16_SINT;
|
||||
case GPU_RGB8I:
|
||||
return VK_FORMAT_R8G8B8_SINT;
|
||||
case GPU_RGB16:
|
||||
return VK_FORMAT_R16G16B16_UNORM;
|
||||
case GPU_RGB8:
|
||||
return VK_FORMAT_R8G8B8_UNORM;
|
||||
case GPU_RGBA16_SNORM:
|
||||
return VK_FORMAT_R16G16B16A16_SNORM;
|
||||
case GPU_RGB16_SNORM:
|
||||
return VK_FORMAT_R16G16B16_SNORM;
|
||||
case GPU_RG16_SNORM:
|
||||
return VK_FORMAT_R16G16_SNORM;
|
||||
case GPU_R16_SNORM:
|
||||
return VK_FORMAT_R16_SNORM;
|
||||
case GPU_RGBA8_SNORM:
|
||||
return VK_FORMAT_R8G8B8A8_SNORM;
|
||||
case GPU_RGB8_SNORM:
|
||||
return VK_FORMAT_R8G8B8_SNORM;
|
||||
case GPU_RG8_SNORM:
|
||||
return VK_FORMAT_R8G8_SNORM;
|
||||
case GPU_R8_SNORM:
|
||||
return VK_FORMAT_R8_SNORM;
|
||||
case GPU_RGB32F:
|
||||
return VK_FORMAT_R32G32B32_SFLOAT;
|
||||
case GPU_RGB16F:
|
||||
return VK_FORMAT_R16G16B16_SFLOAT;
|
||||
|
||||
/* Special formats, texture only. */
|
||||
case GPU_SRGB8_A8_DXT1:
|
||||
return VK_FORMAT_BC1_RGBA_SRGB_BLOCK;
|
||||
case GPU_SRGB8_A8_DXT3:
|
||||
return VK_FORMAT_BC2_SRGB_BLOCK;
|
||||
case GPU_SRGB8_A8_DXT5:
|
||||
return VK_FORMAT_BC3_SRGB_BLOCK;
|
||||
case GPU_RGBA8_DXT1:
|
||||
return VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
|
||||
case GPU_RGBA8_DXT3:
|
||||
return VK_FORMAT_BC2_UNORM_BLOCK;
|
||||
case GPU_RGBA8_DXT5:
|
||||
return VK_FORMAT_BC3_UNORM_BLOCK;
|
||||
case GPU_SRGB8:
|
||||
return VK_FORMAT_R8G8B8_SRGB;
|
||||
case GPU_RGB9_E5:
|
||||
return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32;
|
||||
}
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
|
|
|
@ -252,25 +252,24 @@ GPUTexture *IMB_touch_gpu_texture(const char *name,
|
|||
|
||||
GPUTexture *tex;
|
||||
if (layers > 0) {
|
||||
tex = GPU_texture_create_2d_array_ex(name,
|
||||
w,
|
||||
h,
|
||||
layers,
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
tex = GPU_texture_create_2d_array(name,
|
||||
w,
|
||||
h,
|
||||
layers,
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_2d_ex(name,
|
||||
w,
|
||||
h,
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
tex = GPU_texture_create_2d(name,
|
||||
w,
|
||||
h,
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GPU_texture_swizzle_set(tex, imb_gpu_get_swizzle(ibuf));
|
||||
|
@ -345,6 +344,7 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
|
|||
ibuf->y,
|
||||
ibuf->dds_data.nummipmaps,
|
||||
compressed_format,
|
||||
GPU_TEXTURE_USAGE_GENERAL,
|
||||
ibuf->dds_data.data);
|
||||
|
||||
if (tex != NULL) {
|
||||
|
@ -365,23 +365,21 @@ GPUTexture *IMB_create_gpu_texture(const char *name,
|
|||
bool freebuf = false;
|
||||
|
||||
/* Create Texture. */
|
||||
tex = GPU_texture_create_2d_ex(name,
|
||||
UNPACK2(size),
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
tex = GPU_texture_create_2d(name,
|
||||
UNPACK2(size),
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
if (tex == NULL) {
|
||||
size[0] = max_ii(1, size[0] / 2);
|
||||
size[1] = max_ii(1, size[1] / 2);
|
||||
tex = GPU_texture_create_2d_ex(name,
|
||||
UNPACK2(size),
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
tex = GPU_texture_create_2d(name,
|
||||
UNPACK2(size),
|
||||
9999,
|
||||
tex_format,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
NULL);
|
||||
do_rescale = true;
|
||||
}
|
||||
BLI_assert(tex != NULL);
|
||||
|
|
|
@ -194,7 +194,8 @@ void USDMeshReader::read_object_data(Main *bmain, const double motionSampleTime)
|
|||
Mesh *mesh = (Mesh *)object_->data;
|
||||
|
||||
is_initial_load_ = true;
|
||||
const USDMeshReadParams params = create_mesh_read_params(motionSampleTime, import_params_.mesh_read_flag);
|
||||
const USDMeshReadParams params = create_mesh_read_params(motionSampleTime,
|
||||
import_params_.mesh_read_flag);
|
||||
|
||||
Mesh *read_mesh = this->read_mesh(mesh, params, nullptr);
|
||||
|
||||
|
@ -850,7 +851,8 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
|
|||
}
|
||||
}
|
||||
|
||||
read_mesh_sample(&settings, active_mesh, params.motion_sample_time, new_mesh || is_initial_load_);
|
||||
read_mesh_sample(
|
||||
&settings, active_mesh, params.motion_sample_time, new_mesh || is_initial_load_);
|
||||
|
||||
if (new_mesh) {
|
||||
/* Here we assume that the number of materials doesn't change, i.e. that
|
||||
|
@ -862,7 +864,8 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
|
|||
bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write();
|
||||
bke::SpanAttributeWriter<int> material_indices =
|
||||
attributes.lookup_or_add_for_write_span<int>("material_index", ATTR_DOMAIN_FACE);
|
||||
assign_facesets_to_material_indices(params.motion_sample_time, material_indices.span, &mat_map);
|
||||
assign_facesets_to_material_indices(
|
||||
params.motion_sample_time, material_indices.span, &mat_map);
|
||||
material_indices.finish();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1143,8 +1143,65 @@ static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, bool value)
|
|||
/* vertex_color_layers */
|
||||
|
||||
DEFINE_CUSTOMDATA_LAYER_COLLECTION(vertex_color, ldata, CD_PROP_BYTE_COLOR)
|
||||
DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(
|
||||
vertex_color, ldata, CD_PROP_BYTE_COLOR, active, MeshLoopColorLayer)
|
||||
|
||||
static PointerRNA rna_Mesh_vertex_color_active_get(PointerRNA *ptr)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_color_get(&mesh->id);
|
||||
|
||||
if (!layer || layer->type != CD_PROP_BYTE_COLOR ||
|
||||
BKE_id_attribute_domain(&mesh->id, layer) != ATTR_DOMAIN_CORNER) {
|
||||
return PointerRNA_NULL;
|
||||
}
|
||||
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_MeshLoopColorLayer, layer);
|
||||
}
|
||||
|
||||
static void rna_Mesh_vertex_color_active_set(PointerRNA *ptr,
|
||||
const PointerRNA value,
|
||||
ReportList *reports)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
CustomDataLayer *layer = (CustomDataLayer *)value.data;
|
||||
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
|
||||
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
||||
}
|
||||
|
||||
static int rna_Mesh_vertex_color_active_index_get(PointerRNA *ptr)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_color_get(&mesh->id);
|
||||
|
||||
if (!layer || layer->type != CD_PROP_BYTE_COLOR ||
|
||||
BKE_id_attribute_domain(&mesh->id, layer) != ATTR_DOMAIN_CORNER) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CustomData *ldata = rna_mesh_ldata(ptr);
|
||||
return layer - ldata->layers + CustomData_get_layer_index(ldata, CD_PROP_BYTE_COLOR);
|
||||
}
|
||||
|
||||
static void rna_Mesh_vertex_color_active_index_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
CustomData *ldata = rna_mesh_ldata(ptr);
|
||||
|
||||
if (value < 0 || value >= CustomData_number_of_layers(ldata, CD_PROP_BYTE_COLOR)) {
|
||||
fprintf(stderr, "Invalid loop byte attribute index %d\n", value);
|
||||
return;
|
||||
}
|
||||
|
||||
CustomDataLayer *layer = ldata->layers + CustomData_get_layer_index(ldata, CD_PROP_BYTE_COLOR) +
|
||||
value;
|
||||
|
||||
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
||||
}
|
||||
|
||||
static void rna_MeshLoopColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
|
@ -1160,35 +1217,98 @@ static int rna_MeshLoopColorLayer_data_length(PointerRNA *ptr)
|
|||
return (me->edit_mesh) ? 0 : me->totloop;
|
||||
}
|
||||
|
||||
static bool rna_MeshLoopColorLayer_active_render_get(PointerRNA *ptr)
|
||||
static bool rna_mesh_color_active_render_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
|
||||
return mesh->default_color_attribute && STREQ(mesh->default_color_attribute, layer->name);
|
||||
}
|
||||
|
||||
static bool rna_MeshLoopColorLayer_active_get(PointerRNA *ptr)
|
||||
static bool rna_mesh_color_active_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
|
||||
return mesh->active_color_attribute && STREQ(mesh->active_color_attribute, layer->name);
|
||||
}
|
||||
|
||||
static void rna_MeshLoopColorLayer_active_render_set(PointerRNA *ptr, bool value)
|
||||
static void rna_mesh_color_active_render_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_PROP_BYTE_COLOR, 1);
|
||||
Mesh *mesh = (Mesh *)ptr->owner_id;
|
||||
CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
|
||||
|
||||
BKE_id_attributes_default_color_set(&mesh->id, layer->name);
|
||||
}
|
||||
|
||||
static void rna_MeshLoopColorLayer_active_set(PointerRNA *ptr, bool value)
|
||||
static void rna_mesh_color_active_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
rna_CustomDataLayer_active_set(ptr, rna_mesh_ldata(ptr), value, CD_PROP_BYTE_COLOR, 0);
|
||||
Mesh *mesh = (Mesh *)ptr->owner_id;
|
||||
CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
|
||||
|
||||
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
||||
}
|
||||
|
||||
/* sculpt_vertex_color_layers */
|
||||
|
||||
DEFINE_CUSTOMDATA_LAYER_COLLECTION(sculpt_vertex_color, vdata, CD_PROP_COLOR)
|
||||
DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(
|
||||
sculpt_vertex_color, vdata, CD_PROP_COLOR, active, MeshVertColorLayer)
|
||||
|
||||
static PointerRNA rna_Mesh_sculpt_vertex_color_active_get(PointerRNA *ptr)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_color_get(&mesh->id);
|
||||
|
||||
if (!layer || layer->type != CD_PROP_COLOR ||
|
||||
BKE_id_attribute_domain(&mesh->id, layer) != ATTR_DOMAIN_POINT) {
|
||||
return PointerRNA_NULL;
|
||||
}
|
||||
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_MeshVertColorLayer, layer);
|
||||
}
|
||||
|
||||
static void rna_Mesh_sculpt_vertex_color_active_set(PointerRNA *ptr,
|
||||
const PointerRNA value,
|
||||
ReportList *reports)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
CustomDataLayer *layer = (CustomDataLayer *)value.data;
|
||||
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
|
||||
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
||||
}
|
||||
|
||||
static int rna_Mesh_sculpt_vertex_color_active_index_get(PointerRNA *ptr)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_color_get(&mesh->id);
|
||||
CustomData *vdata = rna_mesh_vdata(ptr);
|
||||
|
||||
if (!layer || layer->type != CD_PROP_COLOR ||
|
||||
BKE_id_attribute_domain(&mesh->id, layer) != ATTR_DOMAIN_POINT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return layer - vdata->layers + CustomData_get_layer_index(vdata, CD_PROP_COLOR);
|
||||
}
|
||||
|
||||
static void rna_Mesh_sculpt_vertex_color_active_index_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ptr->data;
|
||||
CustomData *vdata = rna_mesh_vdata(ptr);
|
||||
|
||||
if (value < 0 || value >= CustomData_number_of_layers(vdata, CD_PROP_COLOR)) {
|
||||
fprintf(stderr, "Invalid loop byte attribute index %d\n", value);
|
||||
return;
|
||||
}
|
||||
|
||||
CustomDataLayer *layer = vdata->layers + CustomData_get_layer_index(vdata, CD_PROP_COLOR) +
|
||||
value;
|
||||
|
||||
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
||||
}
|
||||
|
||||
static void rna_MeshVertColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
|
@ -1204,30 +1324,6 @@ static int rna_MeshVertColorLayer_data_length(PointerRNA *ptr)
|
|||
return (me->edit_mesh) ? 0 : me->totvert;
|
||||
}
|
||||
|
||||
static bool rna_MeshVertColorLayer_active_render_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
|
||||
return mesh->default_color_attribute && STREQ(mesh->default_color_attribute, layer->name);
|
||||
}
|
||||
|
||||
static bool rna_MeshVertColorLayer_active_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
|
||||
return mesh->active_color_attribute && STREQ(mesh->active_color_attribute, layer->name);
|
||||
}
|
||||
|
||||
static void rna_MeshVertColorLayer_active_render_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
rna_CustomDataLayer_active_set(ptr, rna_mesh_vdata(ptr), value, CD_PROP_COLOR, 1);
|
||||
}
|
||||
|
||||
static void rna_MeshVertColorLayer_active_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
rna_CustomDataLayer_active_set(ptr, rna_mesh_vdata(ptr), value, CD_PROP_COLOR, 0);
|
||||
}
|
||||
|
||||
static int rna_float_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
|
||||
{
|
||||
CustomDataLayer *layer = (CustomDataLayer *)data;
|
||||
|
@ -3019,16 +3115,14 @@ static void rna_def_mloopcol(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
||||
|
||||
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_funcs(
|
||||
prop, "rna_MeshLoopColorLayer_active_get", "rna_MeshLoopColorLayer_active_set");
|
||||
RNA_def_property_boolean_funcs(prop, "rna_mesh_color_active_get", "rna_mesh_color_active_set");
|
||||
RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing");
|
||||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
||||
|
||||
prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
|
||||
RNA_def_property_boolean_funcs(prop,
|
||||
"rna_MeshLoopColorLayer_active_render_get",
|
||||
"rna_MeshLoopColorLayer_active_render_set");
|
||||
RNA_def_property_boolean_funcs(
|
||||
prop, "rna_mesh_color_active_render_get", "rna_mesh_color_active_render_set");
|
||||
RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering");
|
||||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
||||
|
||||
|
@ -3080,17 +3174,15 @@ static void rna_def_MPropCol(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
||||
|
||||
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_funcs(
|
||||
prop, "rna_MeshVertColorLayer_active_get", "rna_MeshVertColorLayer_active_set");
|
||||
RNA_def_property_boolean_funcs(prop, "rna_mesh_color_active_get", "rna_mesh_color_active_set");
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Active", "Sets the sculpt vertex color layer as active for display and editing");
|
||||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
||||
|
||||
prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
|
||||
RNA_def_property_boolean_funcs(prop,
|
||||
"rna_MeshVertColorLayer_active_render_get",
|
||||
"rna_MeshVertColorLayer_active_render_set");
|
||||
RNA_def_property_boolean_funcs(
|
||||
prop, "rna_mesh_color_active_render_get", "rna_mesh_color_active_render_set");
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Active Render", "Sets the sculpt vertex color layer as active for rendering");
|
||||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "NOD_add_node_search.hh"
|
||||
#include "NOD_common.h"
|
||||
#include "NOD_node_declaration.hh"
|
||||
#include "NOD_register.hh"
|
||||
|
@ -264,6 +265,7 @@ void register_node_type_frame()
|
|||
|
||||
node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT);
|
||||
ntype->initfunc = node_frame_init;
|
||||
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
|
||||
node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage);
|
||||
node_type_size(ntype, 150, 100, 0);
|
||||
ntype->flag |= NODE_BACKGROUND;
|
||||
|
@ -294,6 +296,7 @@ void register_node_type_reroute()
|
|||
|
||||
node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT);
|
||||
ntype->initfunc = node_reroute_init;
|
||||
ntype->gather_add_node_search_ops = blender::nodes::search_node_add_ops_for_basic_node;
|
||||
|
||||
nodeRegisterType(ntype);
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
|||
if (!pygpu_framebuffer_new_parse_arg(depth_attachment, &config[0])) {
|
||||
return NULL;
|
||||
}
|
||||
if (config[0].tex && !GPU_texture_depth(config[0].tex)) {
|
||||
if (config[0].tex && !GPU_texture_has_depth_format(config[0].tex)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Depth texture with incompatible format");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -204,41 +204,37 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg
|
|||
}
|
||||
else {
|
||||
const char *name = "python_texture";
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
|
||||
if (is_cubemap) {
|
||||
if (layers) {
|
||||
tex = GPU_texture_create_cube_array(
|
||||
name, size[0], layers, 1, pygpu_textureformat.value_found, data);
|
||||
name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_cube(name, size[0], 1, pygpu_textureformat.value_found, data);
|
||||
tex = GPU_texture_create_cube(
|
||||
name, size[0], 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
}
|
||||
else if (layers) {
|
||||
if (len == 2) {
|
||||
tex = GPU_texture_create_2d_array(
|
||||
name, size[0], size[1], layers, 1, pygpu_textureformat.value_found, data);
|
||||
name, size[0], size[1], layers, 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_1d_array(
|
||||
name, size[0], layers, 1, pygpu_textureformat.value_found, data);
|
||||
name, size[0], layers, 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
}
|
||||
else if (len == 3) {
|
||||
tex = GPU_texture_create_3d(name,
|
||||
size[0],
|
||||
size[1],
|
||||
size[2],
|
||||
1,
|
||||
pygpu_textureformat.value_found,
|
||||
GPU_DATA_FLOAT,
|
||||
data);
|
||||
tex = GPU_texture_create_3d(
|
||||
name, size[0], size[1], size[2], 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
else if (len == 2) {
|
||||
tex = GPU_texture_create_2d(
|
||||
name, size[0], size[1], 1, pygpu_textureformat.value_found, data);
|
||||
name, size[0], size[1], 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
else {
|
||||
tex = GPU_texture_create_1d(name, size[0], 1, pygpu_textureformat.value_found, data);
|
||||
tex = GPU_texture_create_1d(name, size[0], 1, pygpu_textureformat.value_found, usage, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,8 +231,9 @@ static void wm_software_cursor_draw_bitmap(const int event_xy[2],
|
|||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
float gl_matrix[4][4];
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
|
||||
GPUTexture *texture = GPU_texture_create_2d(
|
||||
"softeare_cursor", bitmap->data_size[0], bitmap->data_size[1], 1, GPU_RGBA8, 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_filter_mode(texture, false);
|
||||
|
||||
|
|
|
@ -2306,14 +2306,14 @@ static void radial_control_set_tex(RadialControl *rc)
|
|||
rc->use_secondary_tex,
|
||||
!ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) {
|
||||
|
||||
rc->texture = GPU_texture_create_2d_ex("radial_control",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_R8,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
ibuf->rect_float);
|
||||
rc->texture = GPU_texture_create_2d("radial_control",
|
||||
ibuf->x,
|
||||
ibuf->y,
|
||||
1,
|
||||
GPU_R8,
|
||||
GPU_TEXTURE_USAGE_SHADER_READ |
|
||||
GPU_TEXTURE_USAGE_MIP_SWIZZLE_VIEW,
|
||||
ibuf->rect_float);
|
||||
|
||||
GPU_texture_filter_mode(rc->texture, true);
|
||||
GPU_texture_swizzle_set(rc->texture, "111r");
|
||||
|
|
|
@ -477,7 +477,7 @@ static void draw_display_buffer(PlayState *ps, ImBuf *ibuf)
|
|||
void *buffer_cache_handle = NULL;
|
||||
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);
|
||||
GPU_texture_update(texture, data, display_buffer);
|
||||
GPU_texture_filter_mode(texture, false);
|
||||
|
|
Loading…
Reference in New Issue