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

Transformation idea: vector access like .x to [0] #958

Open
paulthomson opened this issue Apr 14, 2020 · 13 comments
Open

Transformation idea: vector access like .x to [0] #958

paulthomson opened this issue Apr 14, 2020 · 13 comments
Labels
component:generator The shader generator good first issue Good for newcomers

Comments

@paulthomson
Copy link
Collaborator

No description provided.

@paulthomson paulthomson added the component:generator The shader generator label Apr 14, 2020
@afd afd added the good first issue Good for newcomers label Mar 9, 2021
@shubhav99
Copy link

Hi
i want to solve this good first issue
please guide me through

@afd
Copy link
Contributor

afd commented Mar 17, 2021

Sure.

OpaqueExpressionGenerator.java has a field:

private final List expressionIdentities;

An ExpressionIdentity is a class that knows how to turn an expression e into an equivalent expression e'. In this case we want to turn "v.x", where "v" is a vector, into "v[0]" (and similarly for other components).

Lines 72 onwards in OpaqueExpressionGenerator feature statements like:

    expressionIdentities.add(new IdentityAddSubZero());
    expressionIdentities.add(new IdentityMulDivOne());
    expressionIdentities.add(new IdentityAndTrue());
    expressionIdentities.add(new IdentityOrFalse());
    expressionIdentities.add(new IdentityLogicalNotNot());
    expressionIdentities.add(new IdentityTernary());

You would want to add something like:

    expressionIdentities.add(new IdentityVectorComponent());

Then, lower in the class, you would need to write the IdentityVectorComponent class.

Have a look at other classes in the file, such as IdentityOrFalse, for inspiration.

In your case you will need to override preconditionHolds to check that the expression being considered for transformation is a MemberLookupExpr. Then, in apply, you'll need to inspect which field of the vector is being accessed, and replace the expression with an ArrayIndexExpr that uses the appropriate index.

Hope this helps you get started.

@Shivani0701
Copy link

Hey,
I read this code
May, I contribute?

@shubhav99
Copy link

shivani please let me work on this code .....
this is my first time ever
a little experience will help me :))

@Shivani0701
Copy link

shivani please let me work on this code .....
this is my first time ever
a little experience will help me :))

Okay , No problem 🙂

@shubhav99
Copy link

hi there ...
i was setting up this project via setup process given in the repository and i am stuck at the step---
activating the virtual environment
please help me on this step

@shubhav99
Copy link

how to proceed from start ??
please help

@afd
Copy link
Contributor

afd commented Mar 21, 2021

@shubhav99 Can you explain in detail what the problem is that you are facing? What did you try and what error messages are you getting?

@KishkinJ10
Copy link

sir i want to work on this issue , from where can i start?

@KishkinJ10
Copy link

sir i am stuck in the return statement of this issue , can you help me out?

@KishkinJ10
Copy link

sir in the return statement i need to return ArrayIndexExpr ?? like this
return ArrayIndexExpr(Expr array, Expr index) {

    // vec2 v;
    // v[0]; // fine
    // v + vec2(0.0)[0]; // not fine - the following was probably intended:
    // (v + vec2(0.0))[0]; // fine

    if (array instanceof BinaryExpr) {
      throw new IllegalArgumentException("Array index into binary expression "
          + array.getText() + " not allowed.");
    }
    this.array = array;
    this.index = index;
  }    

@Anupam0202
Copy link

Hello sir, Can I work on this issue?

@nived1967
Copy link

hello i am a beginner in this issue,could you please tell me how to get started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:generator The shader generator good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants