@@ -6527,8 +6527,6 @@ typedef struct {
65276527// resolved pass attachments struct
65286528typedef struct {
65296529 bool empty;
6530- bool alive;
6531- _sg_dimi_t dim;
65326530 int num_color_views;
65336531 _sg_view_t* color_views[SG_MAX_COLOR_ATTACHMENTS];
65346532 _sg_view_t* resolve_views[SG_MAX_COLOR_ATTACHMENTS];
@@ -7298,52 +7296,50 @@ _SOKOL_PRIVATE _sg_attachments_ptrs_t _sg_attachments_ptrs(const sg_attachments*
72987296 SOKOL_ASSERT(atts);
72997297 _sg_attachments_ptrs_t res;
73007298 _sg_clear(&res, sizeof(res));
7301- res.alive = true;
73027299 res.empty = true;
7303- for (size_t i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
7300+ for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) {
73047301 if (atts->colors[i].id != SG_INVALID_ID) {
73057302 res.empty = false;
7306- _sg_view_t* view = _sg_lookup_view(atts->colors[i].id);
7307- res.color_views[i] = view;
7308- if (_sg_image_view_alive(view)) {
7309- res.num_color_views += 1;
7310- const _sg_dimi_t dim = _sg_image_view_dim(view);
7311- if (res.dim.width == 0) {
7312- res.dim = dim;
7313- }
7314- SOKOL_ASSERT((res.dim.width == dim.width) && (res.dim.height == dim.height));
7315- } else {
7316- res.alive = false;
7317- }
7303+ res.num_color_views += 1;
7304+ res.color_views[i] = _sg_lookup_view(atts->colors[i].id);
73187305 }
73197306 if (atts->resolves[i].id != SG_INVALID_ID) {
73207307 SOKOL_ASSERT(atts->colors[i].id != SG_INVALID_ID);
73217308 res.empty = false;
7322- _sg_view_t* view = _sg_lookup_view(atts->resolves[i].id);
7323- res.resolve_views[i] = view;
7324- if (_sg_image_view_alive(view)) {
7325- const _sg_dimi_t dim = _sg_image_view_dim(view);
7326- SOKOL_ASSERT((res.dim.width == dim.width) && (res.dim.height == dim.height));
7327- }
7309+ res.resolve_views[i] = _sg_lookup_view(atts->resolves[i].id);
73287310 }
73297311 }
73307312 if (atts->depth_stencil.id != SG_INVALID_ID) {
73317313 res.empty = false;
7332- _sg_view_t* view = _sg_lookup_view(atts->depth_stencil.id);
7333- res.ds_view = view;
7334- if (_sg_image_view_alive(view)) {
7335- const _sg_dimi_t dim = _sg_image_view_dim(view);
7336- if (res.dim.width == 0) {
7337- res.dim = dim;
7338- }
7339- SOKOL_ASSERT((res.dim.width == dim.width) && (res.dim.height == dim.height));
7340- } else {
7341- res.alive = false;
7342- }
7314+ res.ds_view = _sg_lookup_view(atts->depth_stencil.id);
73437315 }
73447316 return res;
73457317}
73467318
7319+ _SOKOL_PRIVATE _sg_dimi_t _sg_attachments_dim(const _sg_attachments_ptrs_t* atts_ptrs) {
7320+ if (atts_ptrs->ds_view) {
7321+ return _sg_image_view_dim(atts_ptrs->ds_view);
7322+ } else {
7323+ SOKOL_ASSERT(atts_ptrs->color_views[0]);
7324+ return _sg_image_view_dim(atts_ptrs->color_views[0]);
7325+ }
7326+ }
7327+
7328+ _SOKOL_PRIVATE bool _sg_attachments_alive(const _sg_attachments_ptrs_t* atts_ptrs) {
7329+ for (int i = 0; i < atts_ptrs->num_color_views; i++) {
7330+ if (!_sg_image_view_alive(atts_ptrs->color_views[i])) {
7331+ return false;
7332+ }
7333+ if (atts_ptrs->resolve_views[i] && !_sg_image_view_alive(atts_ptrs->resolve_views[i])) {
7334+ return false;
7335+ }
7336+ }
7337+ if (atts_ptrs->ds_view && !_sg_image_view_alive(atts_ptrs->ds_view)) {
7338+ return false;
7339+ }
7340+ return true;
7341+ }
7342+
73477343_SOKOL_PRIVATE void _sg_buffer_common_init(_sg_buffer_common_t* cmn, const sg_buffer_desc* desc) {
73487344 cmn->size = (int)desc->size;
73497345 cmn->append_pos = 0;
@@ -19263,7 +19259,6 @@ _SOKOL_PRIVATE bool _sg_validate_begin_pass(const sg_pass* pass) {
1926319259 _SG_VALIDATE(color_width == _sg_image_view_dim(view).width, VALIDATE_BEGINPASS_RESOLVEATTACHMENTVIEW_SIZES);
1926419260 _SG_VALIDATE(color_height == _sg_image_view_dim(view).height, VALIDATE_BEGINPASS_RESOLVEATTACHMENTVIEW_SIZES);
1926519261 }
19266-
1926719262 }
1926819263 }
1926919264 // check depth-stencil view
@@ -19283,7 +19278,7 @@ _SOKOL_PRIVATE bool _sg_validate_begin_pass(const sg_pass* pass) {
1928319278 if (img) {
1928419279 _SG_VALIDATE(img->slot.state == SG_RESOURCESTATE_VALID, VALIDATE_BEGINPASS_DEPTHSTENCILATTACHMENTVIEW_IMAGE_VALID);
1928519280 _SG_VALIDATE(color_width == _sg_image_view_dim(view).width, VALIDATE_BEGINPASS_DEPTHSTENCILATTACHMENTVIEW_SIZES);
19286- _SG_VALIDATE(color_height == _sg_image_view_dim(view).width , VALIDATE_BEGINPASS_DEPTHSTENCILATTACHMENTVIEW_SIZES);
19281+ _SG_VALIDATE(color_height == _sg_image_view_dim(view).height , VALIDATE_BEGINPASS_DEPTHSTENCILATTACHMENTVIEW_SIZES);
1928719282 _SG_VALIDATE(color_sample_count == img->cmn.sample_count, VALIDATE_BEGINPASS_DEPTHSTENCILATTACHMENTVIEW_SAMPLECOUNT);
1928819283 }
1928919284 }
@@ -19395,8 +19390,9 @@ _SOKOL_PRIVATE bool _sg_validate_apply_pipeline(sg_pipeline pip_id) {
1939519390 } else {
1939619391 // an offscreen render pass check that pipeline attributes match current pass attachment attributes
1939719392 const _sg_attachments_ptrs_t atts_ptrs = _sg_attachments_ptrs(&_sg.cur_pass.atts);
19398- _SG_VALIDATE(atts_ptrs.alive, VALIDATE_APIP_ATTACHMENTS_ALIVE);
19399- if (atts_ptrs.alive) {
19393+ const bool alive = _sg_attachments_alive(&atts_ptrs);
19394+ _SG_VALIDATE(alive, VALIDATE_APIP_ATTACHMENTS_ALIVE);
19395+ if (alive) {
1940019396 _SG_VALIDATE(pip->cmn.color_count == atts_ptrs.num_color_views, VALIDATE_APIP_COLORATTACHMENTS_COUNT);
1940119397 for (int i = 0; i < pip->cmn.color_count; i++) {
1940219398 const _sg_view_t* clr_view = atts_ptrs.color_views[i];
@@ -19521,7 +19517,7 @@ _SOKOL_PRIVATE bool _sg_validate_apply_bindings(const sg_bindings* bindings) {
1952119517 }
1952219518 }
1952319519
19524- // has expected images
19520+ // has expected texture bindings
1952519521 for (size_t i = 0; i < SG_MAX_TEXTURE_BINDSLOTS; i++) {
1952619522 if (shd->cmn.textures[i].stage != SG_SHADERSTAGE_NONE) {
1952719523 _SG_VALIDATE(bindings->textures[i].id != SG_INVALID_ID, VALIDATE_ABND_EXPECTED_TEXTURE_BINDING);
@@ -19587,7 +19583,7 @@ _SOKOL_PRIVATE bool _sg_validate_apply_bindings(const sg_bindings* bindings) {
1958719583 }
1958819584 }
1958919585
19590- // has expected storage buffers
19586+ // has expected storage buffer bindings
1959119587 for (size_t i = 0; i < SG_MAX_STORAGEBUFFER_BINDSLOTS; i++) {
1959219588 if (shd->cmn.storage_buffers[i].stage != SG_SHADERSTAGE_NONE) {
1959319589 _SG_VALIDATE(bindings->storage_buffers[i].id != SG_INVALID_ID, VALIDATE_ABND_EXPECTED_SBVIEW);
@@ -20176,8 +20172,11 @@ _SOKOL_PRIVATE void _sg_init_view(_sg_view_t* view, const sg_view_desc* desc) {
2017620172 SOKOL_ASSERT(desc);
2017720173 if (_sg_validate_view_desc(desc)) {
2017820174 _sg_view_common_init(&view->cmn, desc);
20179- if (_sg_view_resource_state(view) == SG_RESOURCESTATE_VALID) {
20175+ sg_resource_state res_state = _sg_view_resource_state(view);
20176+ if (res_state == SG_RESOURCESTATE_VALID) {
2018020177 view->slot.state = _sg_create_view(view);
20178+ } else {
20179+ view->slot.state = SG_RESOURCESTATE_FAILED;
2018120180 }
2018220181 } else {
2018320182 view->slot.state = SG_RESOURCESTATE_FAILED;
@@ -20219,8 +20218,7 @@ _SOKOL_PRIVATE void _sg_uninit_pipeline(_sg_pipeline_t* pip) {
2021920218
2022020219_SOKOL_PRIVATE void _sg_uninit_view(_sg_view_t* view) {
2022120220 SOKOL_ASSERT(view && ((view->slot.state == SG_RESOURCESTATE_VALID) || (view->slot.state == SG_RESOURCESTATE_FAILED)));
20222- // FIXME FIXME FIXME
20223- // _sg_discard_view(view);
20221+ _sg_discard_view(view);
2022420222 _sg_reset_view_to_alloc_state(view);
2022520223}
2022620224
@@ -21138,14 +21136,14 @@ SOKOL_API_IMPL void sg_begin_pass(const sg_pass* pass) {
2113821136 if (!_sg_validate_begin_pass(&pass_def)) {
2113921137 return;
2114021138 }
21141- const _sg_attachments_ptrs_t atts_ptrs = _sg_attachments_ptrs(&pass-> attachments);
21139+ const _sg_attachments_ptrs_t atts_ptrs = _sg_attachments_ptrs(&pass_def. attachments);
2114221140 if (!atts_ptrs.empty) {
21143- if (!atts_ptrs.alive ) {
21141+ if (!_sg_attachments_alive(& atts_ptrs) ) {
2114421142 _SG_ERROR(BEGINPASS_ATTACHMENTS_ALIVE);
2114521143 return;
2114621144 }
2114721145 _sg.cur_pass.atts = pass->attachments;
21148- _sg.cur_pass.dim = atts_ptrs.dim ;
21146+ _sg.cur_pass.dim = _sg_attachments_dim(& atts_ptrs) ;
2114921147 } else if (!pass_def.compute) {
2115021148 // a swapchain pass
2115121149 SOKOL_ASSERT(pass_def.swapchain.width > 0);
0 commit comments