|
@@ -2064,7 +2064,7 @@ typedef struct sg_image_data {
|
|
|
The default configuration is:
|
|
|
|
|
|
.type: SG_IMAGETYPE_2D
|
|
|
- .render_attachment: false
|
|
|
+ .render_target: false
|
|
|
.width 0 (must be set to >0)
|
|
|
.height 0 (must be set to >0)
|
|
|
.num_slices 1 (3D textures: depth; array textures: number of layers)
|
|
@@ -2123,7 +2123,7 @@ typedef struct sg_image_data {
|
|
|
typedef struct sg_image_desc {
|
|
|
uint32_t _start_canary;
|
|
|
sg_image_type type;
|
|
|
- bool render_attachment;
|
|
|
+ bool render_target;
|
|
|
int width;
|
|
|
int height;
|
|
|
int num_slices;
|
|
@@ -2404,7 +2404,7 @@ typedef struct sg_pipeline_desc {
|
|
|
Pass images must fulfill the following requirements:
|
|
|
|
|
|
All images must have:
|
|
|
- - been created as render attachment (sg_image_desc.render_attachment = true)
|
|
|
+ - been created as render attachment (sg_image_desc.render_target = true)
|
|
|
- the same size
|
|
|
- the same sample count
|
|
|
- when the color attachment image has a sample_count > 1, the
|
|
@@ -2699,7 +2699,7 @@ typedef struct sg_pass_info {
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_FACE, "pass attachment image is cubemap, but face index is too big") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_LAYER, "pass attachment image is array texture, but layer index is too big") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_SLICE, "pass attachment image is 3d texture, but slice value is too big") \
|
|
|
- _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_IMAGE_NO_RT, "pass attachment image must be have render_attachment=true") \
|
|
|
+ _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_IMAGE_NO_RT, "pass attachment image must be have render_target=true") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_COLOR_INV_PIXELFORMAT, "pass color-attachment images must have a renderable pixel format") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_INV_PIXELFORMAT, "pass depth-attachment image must have depth pixel format") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_IMAGE_SIZES, "all pass attachments must have the same size") \
|
|
@@ -2711,7 +2711,7 @@ typedef struct sg_pass_info {
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_FACE, "pass resolve attachment is cubemap, but face index is too big") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_LAYER, "pass resolve attachment is array texture, but layer index is too big") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_SLICE, "pass resolve attachment is 3d texture, but slice value is too big") \
|
|
|
- _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_IMAGE_NO_RT, "pass resolve attachment image must have render_attachment=true") \
|
|
|
+ _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_IMAGE_NO_RT, "pass resolve attachment image must have render_target=true") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_IMAGE_SIZES, "pass resolve attachment size must match color attachment image size") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_RESOLVE_IMAGE_FORMAT, "pass resolve attachment pixel format must match color attachment pixel format") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_IMAGE, "pass depth attachment image is not valid") \
|
|
@@ -2719,7 +2719,7 @@ typedef struct sg_pass_info {
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_FACE, "pass depth attachment image is cubemap, but face index is too big") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_LAYER, "pass depth attachment image is array texture, but layer index is too big") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_SLICE, "pass depth attachment image is 3d texture, but slice value is too big") \
|
|
|
- _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_IMAGE_NO_RT, "pass depth attachment image must be have render_attachment=true") \
|
|
|
+ _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_IMAGE_NO_RT, "pass depth attachment image must be have render_target=true") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_IMAGE_SIZES, "pass depth attachment image size must match color attachment image size") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_DEPTH_IMAGE_SAMPLE_COUNTS, "pass depth attachment sample count must match color attachment sample count") \
|
|
|
_SG_LOGITEM_XMACRO(VALIDATE_BEGINPASS_PASS, "sg_begin_pass: pass must be valid") \
|
|
@@ -3745,7 +3745,7 @@ typedef struct {
|
|
|
int num_slots;
|
|
|
int active_slot;
|
|
|
sg_image_type type;
|
|
|
- bool render_attachment;
|
|
|
+ bool render_target;
|
|
|
int width;
|
|
|
int height;
|
|
|
int num_slices;
|
|
@@ -3769,7 +3769,7 @@ _SOKOL_PRIVATE void _sg_image_common_init(_sg_image_common_t* cmn, const sg_imag
|
|
|
cmn->num_slots = (desc->usage == SG_USAGE_IMMUTABLE) ? 1 : SG_NUM_INFLIGHT_FRAMES;
|
|
|
cmn->active_slot = 0;
|
|
|
cmn->type = desc->type;
|
|
|
- cmn->render_attachment = desc->render_attachment;
|
|
|
+ cmn->render_target = desc->render_target;
|
|
|
cmn->width = desc->width;
|
|
|
cmn->height = desc->height;
|
|
|
cmn->num_slices = desc->num_slices;
|
|
@@ -6786,7 +6786,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_image(_sg_image_t* img, const sg_
|
|
|
|
|
|
// if this is a MSAA render target, a render buffer object will be created instead of a regulat texture
|
|
|
// (since GLES3 has no multisampled texture objects)
|
|
|
- if (img->cmn.render_attachment && (img->cmn.sample_count > 1)) {
|
|
|
+ if (img->cmn.render_target && (img->cmn.sample_count > 1)) {
|
|
|
glGenRenderbuffers(1, &img->gl.msaa_render_buffer);
|
|
|
glBindRenderbuffer(GL_RENDERBUFFER, img->gl.msaa_render_buffer);
|
|
|
glRenderbufferStorageMultisample(GL_RENDERBUFFER, img->cmn.sample_count, gl_internal_format, img->cmn.width, img->cmn.height);
|
|
@@ -8802,7 +8802,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
|
|
|
// prepare initial content pointers
|
|
|
D3D11_SUBRESOURCE_DATA* init_data = 0;
|
|
|
- if (!injected && (img->cmn.usage == SG_USAGE_IMMUTABLE) && !img->cmn.render_attachment) {
|
|
|
+ if (!injected && (img->cmn.usage == SG_USAGE_IMMUTABLE) && !img->cmn.render_target) {
|
|
|
_sg_d3d11_fill_subres_data(img, &desc->data);
|
|
|
init_data = _sg.d3d11.subres_data;
|
|
|
}
|
|
@@ -8839,7 +8839,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
default: d3d11_tex_desc.ArraySize = 1; break;
|
|
|
}
|
|
|
d3d11_tex_desc.Format = img->d3d11.format;
|
|
|
- if (img->cmn.render_attachment) {
|
|
|
+ if (img->cmn.render_target) {
|
|
|
d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
if (_sg_is_depth_or_depth_stencil_format(img->cmn.pixel_format)) {
|
|
|
d3d11_tex_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
|
@@ -8923,7 +8923,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_d3d11_create_image(_sg_image_t* img, const
|
|
|
d3d11_tex_desc.Depth = (UINT)img->cmn.num_slices;
|
|
|
d3d11_tex_desc.MipLevels = (UINT)img->cmn.num_mipmaps;
|
|
|
d3d11_tex_desc.Format = img->d3d11.format;
|
|
|
- if (img->cmn.render_attachment) {
|
|
|
+ if (img->cmn.render_target) {
|
|
|
d3d11_tex_desc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
d3d11_tex_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
|
|
|
d3d11_tex_desc.CPUAccessFlags = 0;
|
|
@@ -10760,7 +10760,7 @@ _SOKOL_PRIVATE bool _sg_mtl_init_texdesc_common(MTLTextureDescriptor* mtl_desc,
|
|
|
|
|
|
/* initialize MTLTextureDescritor with rendertarget attributes */
|
|
|
_SOKOL_PRIVATE void _sg_mtl_init_texdesc_rt(MTLTextureDescriptor* mtl_desc, _sg_image_t* img) {
|
|
|
- SOKOL_ASSERT(img->cmn.render_attachment);
|
|
|
+ SOKOL_ASSERT(img->cmn.render_target);
|
|
|
_SOKOL_UNUSED(img);
|
|
|
mtl_desc.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
|
|
|
mtl_desc.resourceOptions = MTLResourceStorageModePrivate;
|
|
@@ -10792,7 +10792,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_mtl_create_image(_sg_image_t* img, const sg
|
|
|
_SG_OBJC_RELEASE(mtl_desc);
|
|
|
return SG_RESOURCESTATE_FAILED;
|
|
|
}
|
|
|
- if (img->cmn.render_attachment) {
|
|
|
+ if (img->cmn.render_target) {
|
|
|
if (img->cmn.sample_count > 1) {
|
|
|
_sg_mtl_init_texdesc_rt_msaa(mtl_desc, img);
|
|
|
} else {
|
|
@@ -10806,7 +10806,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_mtl_create_image(_sg_image_t* img, const sg
|
|
|
tex = (__bridge id<MTLTexture>) desc->mtl_textures[slot];
|
|
|
} else {
|
|
|
tex = [_sg.mtl.device newTextureWithDescriptor:mtl_desc];
|
|
|
- if ((img->cmn.usage == SG_USAGE_IMMUTABLE) && !img->cmn.render_attachment) {
|
|
|
+ if ((img->cmn.usage == SG_USAGE_IMMUTABLE) && !img->cmn.render_target) {
|
|
|
_sg_mtl_copy_image_data(img, tex, &desc->data);
|
|
|
}
|
|
|
}
|
|
@@ -12575,7 +12575,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_image(_sg_image_t* img, const s
|
|
|
_sg_clear(&wgpu_tex_desc, sizeof(wgpu_tex_desc));
|
|
|
_sg_wgpu_init_texdesc_common(&wgpu_tex_desc, desc);
|
|
|
if (_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format)) {
|
|
|
- SOKOL_ASSERT(img->cmn.render_attachment);
|
|
|
+ SOKOL_ASSERT(img->cmn.render_target);
|
|
|
SOKOL_ASSERT(img->cmn.type == SG_IMAGETYPE_2D);
|
|
|
SOKOL_ASSERT(img->cmn.num_mipmaps == 1);
|
|
|
SOKOL_ASSERT(!injected);
|
|
@@ -12596,14 +12596,14 @@ _SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_image(_sg_image_t* img, const s
|
|
|
/* NOTE: in the MSAA-rendertarget case, both the MSAA texture *and*
|
|
|
the resolve texture need OutputAttachment usage
|
|
|
*/
|
|
|
- if (img->cmn.render_attachment) {
|
|
|
+ if (img->cmn.render_target) {
|
|
|
wgpu_tex_desc.usage = WGPUTextureUsage_Sampled|WGPUTextureUsage_OutputAttachment;
|
|
|
}
|
|
|
img->wgpu.tex = wgpuDeviceCreateTexture(_sg.wgpu.dev, &wgpu_tex_desc);
|
|
|
SOKOL_ASSERT(img->wgpu.tex);
|
|
|
|
|
|
/* copy content into texture via a throw-away staging buffer */
|
|
|
- if (desc->usage == SG_USAGE_IMMUTABLE && !desc->render_attachment) {
|
|
|
+ if (desc->usage == SG_USAGE_IMMUTABLE && !desc->render_target) {
|
|
|
WGPUBufferDescriptor wgpu_buf_desc;
|
|
|
_sg_clear(&wgpu_buf_desc, sizeof(wgpu_buf_desc));
|
|
|
wgpu_buf_desc.size = _sg_wgpu_image_data_buffer_size(img);
|
|
@@ -12628,7 +12628,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_wgpu_create_image(_sg_image_t* img, const s
|
|
|
which will be resolved into the regular texture at the end of the
|
|
|
offscreen-render pass
|
|
|
*/
|
|
|
- if (desc->render_attachment && is_msaa) {
|
|
|
+ if (desc->render_target && is_msaa) {
|
|
|
wgpu_tex_desc.dimension = WGPUTextureDimension_2D;
|
|
|
wgpu_tex_desc.size.depth = 1;
|
|
|
wgpu_tex_desc.arrayLayerCount = 1;
|
|
@@ -14268,7 +14268,7 @@ _SOKOL_PRIVATE bool _sg_validate_image_desc(const sg_image_desc* desc) {
|
|
|
if (_sg_is_depth_or_depth_stencil_format(fmt)) {
|
|
|
_SG_VALIDATE(desc->type != SG_IMAGETYPE_3D, VALIDATE_IMAGEDESC_DEPTH_3D_IMAGE);
|
|
|
}
|
|
|
- if (desc->render_attachment) {
|
|
|
+ if (desc->render_target) {
|
|
|
SOKOL_ASSERT(((int)fmt >= 0) && ((int)fmt < _SG_PIXELFORMAT_NUM));
|
|
|
_SG_VALIDATE(_sg.formats[fmt].render, VALIDATE_IMAGEDESC_RT_PIXELFORMAT);
|
|
|
_SG_VALIDATE(usage == SG_USAGE_IMMUTABLE, VALIDATE_IMAGEDESC_RT_IMMUTABLE);
|
|
@@ -14494,7 +14494,7 @@ _SOKOL_PRIVATE bool _sg_validate_pass_desc(const sg_pass_desc* desc) {
|
|
|
_SG_VALIDATE(img, VALIDATE_PASSDESC_IMAGE);
|
|
|
if (0 != img) {
|
|
|
_SG_VALIDATE(img->slot.state == SG_RESOURCESTATE_VALID, VALIDATE_PASSDESC_IMAGE);
|
|
|
- _SG_VALIDATE(img->cmn.render_attachment, VALIDATE_PASSDESC_IMAGE_NO_RT);
|
|
|
+ _SG_VALIDATE(img->cmn.render_target, VALIDATE_PASSDESC_IMAGE_NO_RT);
|
|
|
_SG_VALIDATE(att->mip_level < img->cmn.num_mipmaps, VALIDATE_PASSDESC_MIPLEVEL);
|
|
|
if (img->cmn.type == SG_IMAGETYPE_CUBE) {
|
|
|
_SG_VALIDATE(att->slice < 6, VALIDATE_PASSDESC_FACE);
|
|
@@ -14526,7 +14526,7 @@ _SOKOL_PRIVATE bool _sg_validate_pass_desc(const sg_pass_desc* desc) {
|
|
|
_SG_VALIDATE(res_img, VALIDATE_PASSDESC_RESOLVE_IMAGE);
|
|
|
if (res_img != 0) {
|
|
|
_SG_VALIDATE(res_img->slot.state == SG_RESOURCESTATE_VALID, VALIDATE_PASSDESC_RESOLVE_IMAGE);
|
|
|
- _SG_VALIDATE(res_img->cmn.render_attachment, VALIDATE_PASSDESC_RESOLVE_IMAGE_NO_RT);
|
|
|
+ _SG_VALIDATE(res_img->cmn.render_target, VALIDATE_PASSDESC_RESOLVE_IMAGE_NO_RT);
|
|
|
_SG_VALIDATE(res_img->cmn.sample_count == 1, VALIDATE_PASSDESC_RESOLVE_SAMPLE_COUNT);
|
|
|
_SG_VALIDATE(res_att->mip_level < res_img->cmn.num_mipmaps, VALIDATE_PASSDESC_RESOLVE_MIPLEVEL);
|
|
|
if (res_img->cmn.type == SG_IMAGETYPE_CUBE) {
|
|
@@ -14560,7 +14560,7 @@ _SOKOL_PRIVATE bool _sg_validate_pass_desc(const sg_pass_desc* desc) {
|
|
|
else if (img->cmn.type == SG_IMAGETYPE_3D) {
|
|
|
_SG_VALIDATE(att->slice < img->cmn.num_slices, VALIDATE_PASSDESC_DEPTH_SLICE);
|
|
|
}
|
|
|
- _SG_VALIDATE(img->cmn.render_attachment, VALIDATE_PASSDESC_DEPTH_IMAGE_NO_RT);
|
|
|
+ _SG_VALIDATE(img->cmn.render_target, VALIDATE_PASSDESC_DEPTH_IMAGE_NO_RT);
|
|
|
_SG_VALIDATE(width == img->cmn.width >> att->mip_level, VALIDATE_PASSDESC_DEPTH_IMAGE_SIZES);
|
|
|
_SG_VALIDATE(height == img->cmn.height >> att->mip_level, VALIDATE_PASSDESC_DEPTH_IMAGE_SIZES);
|
|
|
_SG_VALIDATE(sample_count == img->cmn.sample_count, VALIDATE_PASSDESC_DEPTH_IMAGE_SAMPLE_COUNTS);
|
|
@@ -14863,7 +14863,7 @@ _SOKOL_PRIVATE sg_image_desc _sg_image_desc_defaults(const sg_image_desc* desc)
|
|
|
def.num_slices = _sg_def(def.num_slices, 1);
|
|
|
def.num_mipmaps = _sg_def(def.num_mipmaps, 1);
|
|
|
def.usage = _sg_def(def.usage, SG_USAGE_IMMUTABLE);
|
|
|
- if (desc->render_attachment) {
|
|
|
+ if (desc->render_target) {
|
|
|
def.pixel_format = _sg_def(def.pixel_format, _sg.desc.context.color_format);
|
|
|
def.sample_count = _sg_def(def.sample_count, _sg.desc.context.sample_count);
|
|
|
}
|
|
@@ -16486,7 +16486,7 @@ SOKOL_API_IMPL sg_image_desc sg_query_image_desc(sg_image img_id) {
|
|
|
const _sg_image_t* img = _sg_lookup_image(&_sg.pools, img_id.id);
|
|
|
if (img) {
|
|
|
desc.type = img->cmn.type;
|
|
|
- desc.render_attachment = img->cmn.render_attachment;
|
|
|
+ desc.render_target = img->cmn.render_target;
|
|
|
desc.width = img->cmn.width;
|
|
|
desc.height = img->cmn.height;
|
|
|
desc.num_slices = img->cmn.num_slices;
|