graphicsfuzz icon indicating copy to clipboard operation
graphicsfuzz copied to clipboard

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

Open paulthomson opened this issue 4 years ago • 13 comments

paulthomson avatar Apr 14 '20 15:04 paulthomson

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

shubhav99 avatar Mar 17 '21 09:03 shubhav99

Sure.

OpaqueExpressionGenerator.java has a field:

private final List<ExpressionIdentity> 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.

afd avatar Mar 17 '21 10:03 afd

Hey, I read this code May, I contribute?

Shivani0701 avatar Mar 17 '21 10:03 Shivani0701

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

shubhav99 avatar Mar 17 '21 12:03 shubhav99

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

Okay , No problem 🙂

Shivani0701 avatar Mar 17 '21 12:03 Shivani0701

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 avatar Mar 17 '21 17:03 shubhav99

how to proceed from start ?? please help

shubhav99 avatar Mar 21 '21 04:03 shubhav99

@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?

afd avatar Mar 21 '21 17:03 afd

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

KishkinJ10 avatar Mar 24 '21 13:03 KishkinJ10

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

KishkinJ10 avatar Mar 24 '21 13:03 KishkinJ10

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;
  }    

KishkinJ10 avatar Mar 25 '21 13:03 KishkinJ10

Hello sir, Can I work on this issue?

Anupam0202 avatar Apr 04 '21 08:04 Anupam0202

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

nived1967 avatar May 13 '21 20:05 nived1967