Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: Fix wrong descriptor set indices when binding descriptor sets #2191

Merged
merged 2 commits into from
Sep 13, 2018

Conversation

Qining
Copy link
Contributor

@Qining Qining commented Sep 11, 2018

This fixes the wrong calculation of descriptor set indices when binding
descriptor sets.

Also, for multi-layer maps (e.g. map!(u32, map!(u32...), we need to
explicitly assign the child map back to the parent map. This is because
the generated go/c++ code will not assign the child map back to the
parent map automactically (go: Get(), c++: findOrZero) when write
api file like: parent[parent_key][child_key] = child_content.

TODO: Similar bugs for other mutlti-layer maps

This fixes the wrong calculation of descriptor set indices when binding
descriptor sets.

Also, for multi-layer maps (e.g. `map!(u32, map!(u32...`), we need to
explicitly assign the child map back to the parent map. This is because
the generated go/c++ code will not assign the child map back to the
parent map automactically (go: `Get()`, c++: `findOrZero`) when write
api file like: `parent[parent_key][child_key] = child_content`.

TODO: Similar bugs for other mutlti-layer maps
@@ -171,8 +171,10 @@ func (v *ReferenceValue) Clone() Value {
func (v *ReferenceValue) field(s *scope, name string) Value {
candidates := make([]Value, 0, len(v.Assignments))
for a := range v.Assignments {
field := s.getInstance(a).(fieldHolder).field(s, name)
candidates = append(candidates, field)
if fh, ok := s.getInstance(a).(fieldHolder); ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changed because of build failure with the original code.

The build fails with the original code if we drop the line 721 to line 745 in gapis/api/vulkan/api/descriptor.api, without any other changes. This is weird.

The build does not happen before at commit: 7915ae3, which is the last commit that drops the line 721 to line 745 in gapis/api/vulkan/api/descriptor.api

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to try and reproduce this error - I don't think there should be a type panic here...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, after much beard scratching, I think I know what's going on here. See my comment below.

@@ -184,7 +186,9 @@ func (v *ReferenceValue) field(s *scope, name string) Value {
// in the scope's instances map.
func (v *ReferenceValue) setField(s *scope, name string, val Value) Value {
for a := range v.Assignments {
s.instances[a] = s.getInstance(a).(fieldHolder).setField(s, name, val)
if fh, ok := s.getInstance(a).(fieldHolder); ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem as above

Copy link
Contributor

@ben-clayton ben-clayton Sep 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your fix is likely fine, however please add the below comment so that some poor bugger doesn't have to work this out again.

I suggest adding this new utility function, and using it in the two places you've changed:

func (v *ReferenceValue) fhAssignments() []fieldHolder {
	out := make([]fieldHolder, 0, len(v.Assignments))
	for a := range v.Assignments {
		// Check the assignment has an instance. No instance can happen when the 
		// assignment took place in a sibling block which has not been merged 
		// into the common scope yet.
		// In this particular case, the instance is inaccessible to this block, 
		// so skipping it is the correct thing to do.
		if fh, ok := s.getInstance(a).(fieldHolder); ok {
			out = append(out, fh)
		}
	}
	return out
}

@@ -171,8 +171,10 @@ func (v *ReferenceValue) Clone() Value {
func (v *ReferenceValue) field(s *scope, name string) Value {
candidates := make([]Value, 0, len(v.Assignments))
for a := range v.Assignments {
field := s.getInstance(a).(fieldHolder).field(s, name)
candidates = append(candidates, field)
if fh, ok := s.getInstance(a).(fieldHolder); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, after much beard scratching, I think I know what's going on here. See my comment below.

@@ -184,7 +186,9 @@ func (v *ReferenceValue) field(s *scope, name string) Value {
// in the scope's instances map.
func (v *ReferenceValue) setField(s *scope, name string, val Value) Value {
for a := range v.Assignments {
s.instances[a] = s.getInstance(a).(fieldHolder).setField(s, name, val)
if fh, ok := s.getInstance(a).(fieldHolder); ok {
Copy link
Contributor

@ben-clayton ben-clayton Sep 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your fix is likely fine, however please add the below comment so that some poor bugger doesn't have to work this out again.

I suggest adding this new utility function, and using it in the two places you've changed:

func (v *ReferenceValue) fhAssignments() []fieldHolder {
	out := make([]fieldHolder, 0, len(v.Assignments))
	for a := range v.Assignments {
		// Check the assignment has an instance. No instance can happen when the 
		// assignment took place in a sibling block which has not been merged 
		// into the common scope yet.
		// In this particular case, the instance is inaccessible to this block, 
		// so skipping it is the correct thing to do.
		if fh, ok := s.getInstance(a).(fieldHolder); ok {
			out = append(out, fh)
		}
	}
	return out
}

@Qining Qining merged commit ac65ff9 into google:master Sep 13, 2018
AWoloszyn added a commit to AWoloszyn/gapid that referenced this pull request Sep 14, 2018
AWoloszyn added a commit that referenced this pull request Sep 14, 2018
Qining added a commit to Qining/gapid that referenced this pull request Sep 17, 2018
This re-fixes the wrong calculation of descriptor set indices when binding
descriptor sets. The fix was reverted as google#2191 get reverted.

Also, for multi-layer maps (e.g. `map!(u32, map!(u32...`), we need to
explicitly assign the child map back to the parent map. This is because
the generated go/c++ code will not assign the child map back to the
parent map automactically (go: `Get()`, c++: `findOrZero`) when write
api file like: `parent[parent_key][child_key] = child_content`.

TODO: Similar bugs for other mutlti-layer maps
Qining added a commit that referenced this pull request Sep 18, 2018
…ets (#2224)

This re-fixes the wrong calculation of descriptor set indices when binding
descriptor sets. The fix was reverted as #2191 get reverted.

Also, for multi-layer maps (e.g. `map!(u32, map!(u32...`), we need to
explicitly assign the child map back to the parent map. This is because
the generated go/c++ code will not assign the child map back to the
parent map automactically (go: `Get()`, c++: `findOrZero`) when write
api file like: `parent[parent_key][child_key] = child_content`.

TODO: Similar bugs for other mutlti-layer maps
@Qining Qining deleted the fix-dyn-offset branch October 23, 2018 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants