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

BaseVulkanApp.VulkanMode() not returning VulkanPresent #6

Closed
floatingmountain opened this issue Sep 11, 2019 · 2 comments · Fixed by #7
Closed

BaseVulkanApp.VulkanMode() not returning VulkanPresent #6

floatingmountain opened this issue Sep 11, 2019 · 2 comments · Fixed by #7

Comments

@floatingmountain
Copy link

Hey,

the vulkancube demo returned a nullpointer reference error. So I backtracked the error a bit and it seems that the BaseVulkanApp.VulkanMode() does not return VulkanPresent by default. So either the Method has to be overwritten by the vulkancube demo for it to work or the default method has to be changed.

Great work btw!

@xlab
Copy link
Member

xlab commented Sep 11, 2019

Thank you! :)

There was an issue with bit flags - they didn't work as expected from the beginning
#4

But the fix leads to issues with presentation now:
#5

I didn't have a chance to test and debug it, I'll be grateful for any help.

@floatingmountain
Copy link
Author

floatingmountain commented Sep 11, 2019

TLDR VulkanMode() was not addressed in #4. It does not return the intended default behavior. It has to be (application.go line 98-100):

func (app *BaseVulkanApp) VulkanMode() VulkanMode {
	return DefaultVulkanMode
}

/TLDR

I had to read up on this. The following code describes the current behavior of VulkanMode.

package main

import "fmt"

type VulkanMode uint8

const (
	VulkanNone VulkanMode = (1 << iota) >> 1
	VulkanCompute
	VulkanGraphics
	VulkanPresent
)

func (v VulkanMode) Has(mode VulkanMode) bool {
	return v&mode != 0
}

var modes = []VulkanMode{
	VulkanNone,
	VulkanCompute,
	VulkanGraphics,
	VulkanPresent,
}

func main() {
	for _, flag1 := range modes {
		for _, flag2 := range modes {
			fmt.Println(flag1, flag2, (flag1).Has(flag2))
		}
	}
}

and this is the output:

0 0 false
0 1 false
0 2 false
0 4 false

1 0 false
1 1 true
1 2 false
1 4 false

2 0 false
2 1 false
2 2 true
2 4 false

4 0 false
4 1 false
4 2 false
4 4 true

I played around some more with it.
So now I know how to use multiflags in go :)
It seems the VulkanMode() method is supposed to return the DefaultVulkanMode. I suggest the following change to fix all apparent issues:
application.go line 98-100

func (app *BaseVulkanApp) VulkanMode() VulkanMode {
	return DefaultVulkanMode
}

So by default it will return true for all VulkanModes except VulkanNone.

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 a pull request may close this issue.

2 participants