MacOS: Enable support for EDR rendering #105662
|
@ -675,28 +675,56 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect
|
|||
newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty);
|
||||
|
||||
if (rres.rectx && rres.recty) {
|
||||
uchar *rect_byte = static_cast<uchar *>(
|
||||
MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect"));
|
||||
float fx = rect->xmin + offx;
|
||||
float fy = rect->ymin;
|
||||
|
||||
/* material preview only needs monoscopy (view 0) */
|
||||
RE_AcquiredResultGet32(re, &rres, (uint *)rect_byte, 0);
|
||||
/* High dynamic range preview. */
|
||||
if (U.gpu_flag & USER_GPU_FLAG_HDR_ENABLED) {
|
||||
brecht marked this conversation as resolved
Outdated
|
||||
float *rect_float = static_cast<float *>(MEM_mallocN(
|
||||
rres.rectx * rres.recty * sizeof(float) * 4, "ed_preview_draw_rect_float"));
|
||||
float fx = rect->xmin + offx;
|
||||
float fy = rect->ymin;
|
||||
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
|
||||
immDrawPixelsTexTiled(&state,
|
||||
fx,
|
||||
fy,
|
||||
rres.rectx,
|
||||
rres.recty,
|
||||
GPU_RGBA8,
|
||||
false,
|
||||
rect_byte,
|
||||
1.0f,
|
||||
1.0f,
|
||||
nullptr);
|
||||
/* material preview only needs monoscopy (view 0) */
|
||||
RE_AcquiredResultGetFloat(re, &rres, rect_float, 0);
|
||||
|
||||
MEM_freeN(rect_byte);
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
|
||||
immDrawPixelsTexTiled(&state,
|
||||
fx,
|
||||
fy,
|
||||
rres.rectx,
|
||||
rres.recty,
|
||||
GPU_RGBA16F,
|
||||
false,
|
||||
rect_float,
|
||||
1.0f,
|
||||
1.0f,
|
||||
nullptr);
|
||||
|
||||
MEM_freeN(rect_float);
|
||||
}
|
||||
else {
|
||||
uchar *rect_byte = static_cast<uchar *>(
|
||||
MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect"));
|
||||
float fx = rect->xmin + offx;
|
||||
float fy = rect->ymin;
|
||||
|
||||
/* material preview only needs monoscopy (view 0) */
|
||||
RE_AcquiredResultGet32(re, &rres, (uint *)rect_byte, 0);
|
||||
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
|
||||
immDrawPixelsTexTiled(&state,
|
||||
fx,
|
||||
fy,
|
||||
rres.rectx,
|
||||
rres.recty,
|
||||
GPU_RGBA8,
|
||||
false,
|
||||
rect_byte,
|
||||
1.0f,
|
||||
1.0f,
|
||||
nullptr);
|
||||
|
||||
MEM_freeN(rect_byte);
|
||||
}
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
|
|
@ -297,6 +297,15 @@ void IMB_display_buffer_transform_apply(unsigned char *display_buffer,
|
|||
const struct ColorManagedViewSettings *view_settings,
|
||||
const struct ColorManagedDisplaySettings *display_settings,
|
||||
bool predivide);
|
||||
void IMB_display_buffer_transform_apply_float(
|
||||
float *float_display_buffer,
|
||||
float *linear_buffer,
|
||||
int width,
|
||||
int height,
|
||||
int channels,
|
||||
const struct ColorManagedViewSettings *view_settings,
|
||||
const struct ColorManagedDisplaySettings *display_settings,
|
||||
bool predivide);
|
||||
|
||||
void IMB_display_buffer_release(void *cache_handle);
|
||||
|
||||
|
|
|
@ -2784,6 +2784,31 @@ void IMB_display_buffer_transform_apply(uchar *display_buffer,
|
|||
MEM_freeN(buffer);
|
||||
}
|
||||
|
||||
void IMB_display_buffer_transform_apply_float(float *float_display_buffer,
|
||||
float *linear_buffer,
|
||||
int width,
|
||||
int height,
|
||||
int channels,
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings,
|
||||
bool predivide)
|
||||
{
|
||||
float *buffer;
|
||||
ColormanageProcessor *cm_processor = IMB_colormanagement_display_processor_new(view_settings,
|
||||
display_settings);
|
||||
|
||||
buffer = static_cast<float *>(MEM_mallocN(size_t(channels) * width * height * sizeof(float),
|
||||
"display transform temp buffer"));
|
||||
memcpy(buffer, linear_buffer, size_t(channels) * width * height * sizeof(float));
|
||||
|
||||
IMB_colormanagement_processor_apply(cm_processor, buffer, width, height, channels, predivide);
|
||||
|
||||
IMB_colormanagement_processor_free(cm_processor);
|
||||
|
||||
memcpy(float_display_buffer, buffer, size_t(channels) * width * height * sizeof(float));
|
||||
MEM_freeN(buffer);
|
||||
}
|
||||
|
||||
void IMB_display_buffer_release(void *cache_handle)
|
||||
{
|
||||
if (cache_handle) {
|
||||
|
|
|
@ -261,6 +261,10 @@ void RE_AcquiredResultGet32(struct Render *re,
|
|||
struct RenderResult *result,
|
||||
unsigned int *rect,
|
||||
int view_id);
|
||||
void RE_AcquiredResultGetFloat(struct Render *re,
|
||||
struct RenderResult *result,
|
||||
float *rect,
|
||||
const int view_id);
|
||||
|
||||
void RE_render_result_full_channel_name(char *fullname,
|
||||
const char *layname,
|
||||
|
|
|
@ -516,6 +516,17 @@ void RE_AcquiredResultGet32(Render *re, RenderResult *result, uint *rect, const
|
|||
view_id);
|
||||
}
|
||||
|
||||
void RE_AcquiredResultGetFloat(Render *re, RenderResult *result, float *rect, const int view_id)
|
||||
{
|
||||
render_result_rect_get_pixels_float(result,
|
||||
rect,
|
||||
re->rectx,
|
||||
re->recty,
|
||||
&re->scene->view_settings,
|
||||
&re->scene->display_settings,
|
||||
view_id);
|
||||
}
|
||||
|
||||
RenderStats *RE_GetStats(Render *re)
|
||||
{
|
||||
return &re->i;
|
||||
|
|
|
@ -1046,6 +1046,32 @@ void render_result_rect_get_pixels(RenderResult *rr,
|
|||
}
|
||||
}
|
||||
|
||||
void render_result_rect_get_pixels_float(RenderResult *rr,
|
||||
float *rect,
|
||||
int rectx,
|
||||
int recty,
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings,
|
||||
const int view_id)
|
||||
{
|
||||
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
||||
|
||||
if (rv && rv->combined_buffer.data) {
|
||||
IMB_display_buffer_transform_apply_float(rect,
|
||||
rv->combined_buffer.data,
|
||||
rr->rectx,
|
||||
rr->recty,
|
||||
4,
|
||||
view_settings,
|
||||
display_settings,
|
||||
true);
|
||||
}
|
||||
else {
|
||||
/* else fill with black */
|
||||
memset(rect, 0, sizeof(int) * rectx * recty);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************** multiview functions *****************************/
|
||||
|
||||
bool RE_HasCombinedLayer(const RenderResult *result)
|
||||
|
|
|
@ -121,6 +121,14 @@ void render_result_rect_get_pixels(struct RenderResult *rr,
|
|||
const struct ColorManagedViewSettings *view_settings,
|
||||
const struct ColorManagedDisplaySettings *display_settings,
|
||||
int view_id);
|
||||
void render_result_rect_get_pixels_float(
|
||||
struct RenderResult *rr,
|
||||
float *rect,
|
||||
int rectx,
|
||||
int recty,
|
||||
const struct ColorManagedViewSettings *view_settings,
|
||||
const struct ColorManagedDisplaySettings *display_settings,
|
||||
int view_id);
|
||||
|
||||
/**
|
||||
* Create a new views #ListBase in rr without duplicating the memory pointers.
|
||||
|
|
Loading…
Reference in New Issue
In main it now always draws a float buffer, so this change can be removed.