forked from blender/blender
main sync #3
@ -62,11 +62,24 @@ template<> uint denormalize<uint>(float val)
|
|||||||
return uint(float(DEPTH_SCALE_FACTOR) * val);
|
return uint(float(DEPTH_SCALE_FACTOR) * val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Float to other type case. */
|
||||||
template<typename T> T convert_type(float type)
|
template<typename T> T convert_type(float type)
|
||||||
{
|
{
|
||||||
return T(type);
|
return T(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Uint to other types. */
|
||||||
|
template<typename T> T convert_type(uint type)
|
||||||
|
{
|
||||||
|
return T(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Int to other types. */
|
||||||
|
template<typename T> T convert_type(int type)
|
||||||
|
{
|
||||||
|
return T(type);
|
||||||
|
}
|
||||||
|
|
||||||
template<> uchar convert_type<uchar>(float val)
|
template<> uchar convert_type<uchar>(float val)
|
||||||
{
|
{
|
||||||
return uchar(val * float(0xFF));
|
return uchar(val * float(0xFF));
|
||||||
@ -141,8 +154,8 @@ kernel void compute_texture_read(constant TextureReadParams ¶ms [[buffer(0)]
|
|||||||
uint xx = position[0];
|
uint xx = position[0];
|
||||||
uint yy = position[1];
|
uint yy = position[1];
|
||||||
uint zz = position[2];
|
uint zz = position[2];
|
||||||
int index = (zz * (params.extent[0] * params.extent[1]) + yy * params.extnt[0] + xx) *
|
int index = (zz * (params.extent[0] * params.extent[1]) + yy * params.extent[0] + xx) *
|
||||||
COMPONENT_COUNT_INPUT;
|
COMPONENT_COUNT_OUTPUT;
|
||||||
read_colour = read_tex.read(uint3(params.offset[0], params.offset[1], params.offset[2]) +
|
read_colour = read_tex.read(uint3(params.offset[0], params.offset[1], params.offset[2]) +
|
||||||
uint3(xx, yy, zz));
|
uint3(xx, yy, zz));
|
||||||
|
|
||||||
@ -163,7 +176,7 @@ kernel void compute_texture_read(constant TextureReadParams ¶ms [[buffer(0)]
|
|||||||
uint yy = position[1];
|
uint yy = position[1];
|
||||||
uint layer = position[2];
|
uint layer = position[2];
|
||||||
int index = (layer * (params.extent[0] * params.extent[1]) + yy * params.extent[0] + xx) *
|
int index = (layer * (params.extent[0] * params.extent[1]) + yy * params.extent[0] + xx) *
|
||||||
COMPONENT_COUNT_INPUT;
|
COMPONENT_COUNT_OUTPUT;
|
||||||
|
|
||||||
/* Read data */
|
/* Read data */
|
||||||
# if IS_DEPTH_FORMAT == 1
|
# if IS_DEPTH_FORMAT == 1
|
||||||
|
@ -606,17 +606,6 @@ void MTLFrameBuffer::update_attachments(bool update_viewport)
|
|||||||
if (!dirty_attachments_) {
|
if (!dirty_attachments_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cache viewport and scissor (If we have existing attachments). */
|
|
||||||
int t_viewport[4], t_scissor[4];
|
|
||||||
update_viewport = update_viewport &&
|
|
||||||
(this->get_attachment_count() > 0 && this->has_depth_attachment() &&
|
|
||||||
this->has_stencil_attachment());
|
|
||||||
if (update_viewport) {
|
|
||||||
this->viewport_get(t_viewport);
|
|
||||||
this->scissor_get(t_scissor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear current attachments state. */
|
/* Clear current attachments state. */
|
||||||
this->remove_all_attachments();
|
this->remove_all_attachments();
|
||||||
|
|
||||||
@ -738,22 +727,25 @@ void MTLFrameBuffer::update_attachments(bool update_viewport)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether the first attachment is SRGB. */
|
/* Extract attachment size and determine if framebuffer is SRGB. */
|
||||||
if (first_attachment != GPU_FB_MAX_ATTACHMENT) {
|
if (first_attachment != GPU_FB_MAX_ATTACHMENT) {
|
||||||
srgb_ = (first_attachment_mtl.texture->format_get() == GPU_SRGB8_A8);
|
/* Ensure size is correctly assigned. */
|
||||||
}
|
GPUAttachment &attach = attachments_[first_attachment];
|
||||||
|
int size[3];
|
||||||
/* Reset viewport and Scissor (If viewport is smaller or equal to the framebuffer size). */
|
GPU_texture_get_mipmap_size(attach.tex, attach.mip, size);
|
||||||
if (update_viewport && t_viewport[2] <= width_ && t_viewport[3] <= height_) {
|
this->size_set(size[0], size[1]);
|
||||||
|
srgb_ = (GPU_texture_format(attach.tex) == GPU_SRGB8_A8);
|
||||||
this->viewport_set(t_viewport);
|
|
||||||
this->scissor_set(t_viewport);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->viewport_reset();
|
/* Empty frame-buffer. */
|
||||||
this->scissor_reset();
|
width_ = 0;
|
||||||
|
height_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset viewport and Scissor. */
|
||||||
|
this->viewport_reset();
|
||||||
|
this->scissor_reset();
|
||||||
|
|
||||||
/* We have now updated our internal structures. */
|
/* We have now updated our internal structures. */
|
||||||
dirty_attachments_ = false;
|
dirty_attachments_ = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user