-
Notifications
You must be signed in to change notification settings - Fork 35
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
Android support for BigWheels #46
Conversation
5178bdc
to
76165d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to check in all the XML files? Does grade/cmake not generate them during project generation or build time?
# Add game-activity for ANDROID | ||
# ------------------------------------------------------------------------------ | ||
if (PPX_ANDROID) | ||
find_package(game-activity REQUIRED CONFIG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this come from the NDK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
76165d1
to
5c0408b
Compare
So the NDK template's .gitignore specifically does not include the specific xml files in the .idea folder that I pushed. |
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.example.bigwheels", appContext.getPackageName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe com.google.bigwheels
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
project("bigwheels") | ||
|
||
add_subdirectory("../../../../.." "../../../../../app/build") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a variable instead of this .../.../.../.../.../../../../../../
? like $PPX_DIR or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So no, none of those variables exist. For the Android builds, this CMakeLists.txt file is the first one that cmake encounters, so none of those $PPX_* variables have been setup yet.
I cleaned it up a bit to make it a little more explicit, but it's still ugly relative paths. Not sure what we can do about that. I'm open to suggestions!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any/all of these relative path resolve to similar or the same locations? It might be easier to have a variable that starts a root and then appends the relative paths on. While add_subdirectory
implies the current path - it's a little difficult to understand past like 3 relative paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what my cleanup does.
However, Keenuts is working on a subsequent PR that will completely clean up the directory structure and make all this relative path nonsense a thing of the past.
# You can define multiple libraries, and CMake builds them for you. | ||
# Gradle automatically packages shared libraries with your APK. | ||
|
||
add_library( # Sets the name of the library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file format seems odd? clang-format created those newlines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. What's odd about the file format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new lines between each part of the
add_library\n#comment\n\nbigwheels\n\n#comment\n\nSHARED\n\n#comment\nmaain.cpp
Just unique
compared to the other CMakelist.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. The cmake was generated by android studio, so I kept it as unmodified as possible. They added newlines so they can add comments, I guess. Do you feel strongly about cleaning it up?
I was following a "as little change as possible to the template" policy in general. But it's not a strict requirement.
@@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All those webp & SVG icons could be replaced by a single xml with like 1 square/shape?
like this one (res/drawable/icon.xml
)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#FF0000"/>
</shape>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, Keenuts is working on a subsequent PR that will clean all this nonsense up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed most of the files in the res/ folder, which should reduce the overall size of this PR by about 40KB.
@@ -30,6 +31,36 @@ | |||
# define GLFW_INCLUDE_NONE | |||
#endif | |||
#include <GLFW/glfw3.h> | |||
|
|||
#if defined(PPX_ANDROID) | |||
#define SETUP_APPLICATION(AppType) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really don't like this part.
What about doing the following:
- we provide the
main
function. - we have a desktop_main.cc, or android_main.cc, which is compiled depending on the target.
- this function calls an
application_main
with argv and the app object. - our samples/benchmarks only implements the
application_main
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be a little more involved but definitely cleaner.
In the interest of expediting this PR and getting more people working on Android sooner, I'm going to treat this as a cleanup to be done in a later PR. Ok with you?
projects/fishtornado/Flocking.cpp
Outdated
pFlockingData->resY = static_cast<int>(mResY); | ||
|
||
// For some reason, reading the velocity texture in the vertex shader at the full 128x128 causes a GPU crash on Pixel 6 Pro. | ||
// Also note that when the Pixel Shader is modified to be a solid-color shader, the crash goes away. This even |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be caused by a cross-stage optimization?
if you replace the FS by a solid color, it means you don't read normal/tangent, etc.
So those are dead inputs, meaning VS has dead outputs, so all the instructions generating those can be removed across the whole pipeline, meaning no more texture load?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't explain why reducing the size makes it automagically work...
In any case, I'm going to leave this as an exercise for someone else to solve. It's enough for the purposes of this PR that fishtornado runs on Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funnily enough, now fishtornado is broken again even with this fix. I have to disable the flocking shadow pass before it works again. There's definitely something wrong somewhere.
It runs on Quest2 though, although there's minor graphical artifacts.
src/ppx/application.cpp
Outdated
int value = glfwWindowShouldClose(static_cast<GLFWwindow*>(mWindow)); | ||
bool isRunning = (value == 0); | ||
return isRunning; | ||
#else | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK this is determined by android_app->destroyRequested
.
struct android_app*
is provided at the android_main
entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
febd635
to
d979ab5
Compare
projects/fishtornado/Flocking.cpp
Outdated
// happens when the FlockingVelocity compute job is disabled and the velocity values are hardcoded to a | ||
// unit vector. Can't make sense of it right now, and it's possible it has to do with SPIR-V code generation, | ||
// since DXC isn't guaranteed to work with mobile. | ||
pFlockingData->resY = 100; //static_cast<int>(mResY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in FlockingRender.hlsl, there is a line in vsmain
:
uint2 xy = uint2((instanceId % Flocking.resX), (instanceId / Flocking.resY));
instanceId is in the range of [0, 128x128-1]
when you make Flocking.resY smaller than 128, the y
would be larger than 128 which might cause problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok you're right. Checking in a fix that magically works is probably not a good idea.
I have reverted this hack and made it a TODO to fix fishtornado.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I also made the gbuffer sample the default one
eba66ea
to
5303032
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for me, except need to propagate the sample fixes to the 3 new samples.
|
||
return res; | ||
} | ||
SETUP_APPLICATION(ProjApp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 new samples have been added:
- 28_gltf
- oit
- benchmark fork of 28_gltf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added SETUP_APPLICATION to all 3 of these new samples!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added to fluid simulation sample
5303032
to
34f58f8
Compare
The folder is auto-generated by Android Studio, so it doesn't seem necessary to check-in
34f58f8
to
18b980f
Compare
Added a few issues to keep track of the missing work. Assigned some to you, some left for grabs. Feel free to update assignees. |
This is a rough "as-little-change-as-possible" change to enable BigWheels to run on Android. It has been tested with the gbuffer and fishtornado samples successfully (Note: Fishtornado works on Quest2 but fails on Pixel 6. We will have to re-visit fishtornado as a separate task). Among some of the things changed to support Android:
Todo: