GLES2Dbg: more tests and minor fixes/improvements

Change-Id: I55c360372623c019da0c1ba2eebbc68f73f0f211
Signed-off-by: David Li <davidxli@google.com>
This commit is contained in:
David Li
2011-04-22 18:18:30 -07:00
parent 38c48e57fb
commit a130006227
10 changed files with 253 additions and 68 deletions

View File

@@ -359,9 +359,12 @@ class ContextViewProvider extends LabelProvider implements ITreeContentProvider,
case glTexImage2D:
case glTexSubImage2D:
case glCopyTexImage2D:
case glCopyTexSubImage2D:
return entry.image = new MessageData(Display.getCurrent(), msg, null)
.getImage();
case glCopyTexSubImage2D: {
entry.image = new MessageData(Display.getCurrent(), msg, null).getImage();
if (entry.image == null)
return null;
return new Image(Display.getCurrent(), entry.image.getImageData().scaledTo(96, 96));
}
default:
return null;
}

View File

@@ -75,7 +75,8 @@ class GLTexture implements Cloneable {
@Override
public String toString() {
return target.name() + " " + contentChanges.size() + " content change(s)";
return String.format("%s %s %d*%d %d change(s)", target, format, width, height,
contentChanges.size());
}
}

View File

@@ -521,6 +521,8 @@ public class GLServerVertex implements Cloneable {
}
void glVertexAttrib4f(int indx, float x, float y, float z, float w) {
if (indx < 0 || indx >= defaultAttribs.length)
return;
defaultAttribs[indx][0] = x;
defaultAttribs[indx][1] = y;
defaultAttribs[indx][2] = z;

View File

@@ -31,16 +31,21 @@ public abstract class MessageParser {
String[] getList()
{
assert args.charAt(0) == '{';
String arg = args;
args = args.substring(args.lastIndexOf('}') + 1);
int comma = args.indexOf(',');
final int comma = args.indexOf(',');
if (comma >= 0)
args = args.substring(comma + 1).trim();
else
args = null;
final int comment = arg.indexOf('=');
if (comment >= 0)
arg = arg.substring(comment + 1);
arg = arg.trim();
assert arg.charAt(0) == '{';
arg = arg.substring(1, arg.lastIndexOf('}')).trim();
return arg.split(",");
return arg.split("\\s*,\\s*");
}
ByteString parseFloats(int count) {
@@ -74,7 +79,7 @@ public abstract class MessageParser {
}
ByteString parseMatrix(int columns, int count) {
return parseFloats(columns * count);
return parseFloats(columns * columns * count);
}
ByteString parseString() {
@@ -91,21 +96,22 @@ public abstract class MessageParser {
String getArgument()
{
int comma = args.indexOf(",");
final int comma = args.indexOf(',');
String arg = null;
if (comma >= 0)
{
arg = args.substring(0, comma).trim();
args = args.substring(comma + 1).trim();
arg = args.substring(0, comma);
args = args.substring(comma + 1);
}
else
{
arg = args;
args = null;
}
if (arg.indexOf("=") >= 0)
arg = arg.substring(arg.indexOf("=") + 1);
return arg;
final int comment = arg.indexOf('=');
if (comment >= 0)
arg = arg.substring(comment + 1);
return arg.trim();
}
int parseArgument()
@@ -634,19 +640,19 @@ public abstract class MessageParser {
builder.setArg0(parseArgument()); // GLint location
builder.setArg1(parseArgument()); // GLsizei count
builder.setArg2(parseArgument()); // GLboolean transpose
builder.setData(parseMatrix(2, 4 * builder.getArg1())); // GLfloat value
builder.setData(parseMatrix(2, builder.getArg1())); // GLfloat value
break;
case glUniformMatrix3fv:
builder.setArg0(parseArgument()); // GLint location
builder.setArg1(parseArgument()); // GLsizei count
builder.setArg2(parseArgument()); // GLboolean transpose
builder.setData(parseMatrix(3, 9 * builder.getArg1())); // GLfloat value
builder.setData(parseMatrix(3, builder.getArg1())); // GLfloat value
break;
case glUniformMatrix4fv:
builder.setArg0(parseArgument()); // GLint location
builder.setArg1(parseArgument()); // GLsizei count
builder.setArg2(parseArgument()); // GLboolean transpose
builder.setData(parseMatrix(4, 16 * builder.getArg1())); // GLfloat value
builder.setData(parseMatrix(4, builder.getArg1())); // GLfloat value
break;
case glUseProgram:
builder.setArg0(parseArgument()); // GLuint program

View File

@@ -192,12 +192,7 @@ public class SampleView extends ViewPart implements Runnable, SelectionListener
}
public SampleView() {
MessageParserEx messageParserEx = new MessageParserEx();
Message.Builder builder = Message.newBuilder();
messageParserEx.parse(builder, "glUniform4fv(1,2,{0,1,2,3,4,5,6,7})");
messageParserEx
.parse(builder,
"void glShaderSource(shader=4, count=1, string=\"dksjafhskjahourehghskjg\", length=0x0)");
}
public void createLeftPane(Composite parent) {

View File

@@ -146,43 +146,45 @@ public class ShaderEditor extends Composite implements SelectionListener, Extend
void uploadShader() {
current.source = styledText.getText();
try {
File file = File.createTempFile("shader",
current.type == GLEnum.GL_VERTEX_SHADER ? ".vert" : ".frag");
FileWriter fileWriter = new FileWriter(file, false);
fileWriter.write(current.source);
fileWriter.close();
// optional syntax check by glsl_compiler, built from external/mesa3d
if (new File("./glsl_compiler").exists())
try {
File file = File.createTempFile("shader",
current.type == GLEnum.GL_VERTEX_SHADER ? ".vert" : ".frag");
FileWriter fileWriter = new FileWriter(file, false);
fileWriter.write(current.source);
fileWriter.close();
ProcessBuilder processBuilder = new ProcessBuilder(
"./glsl_compiler", "--glsl-es", file.getAbsolutePath());
final Process process = processBuilder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
String infolog = "";
ProcessBuilder processBuilder = new ProcessBuilder(
"./glsl_compiler", "--glsl-es", file.getAbsolutePath());
final Process process = processBuilder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
String infolog = "";
styledText.setLineBackground(0, styledText.getLineCount(), null);
styledText.setLineBackground(0, styledText.getLineCount(), null);
while ((line = br.readLine()) != null) {
infolog += line;
if (!line.startsWith("0:"))
continue;
String[] details = line.split(":|\\(|\\)");
final int ln = Integer.parseInt(details[1]);
if (ln > 0) // usually line 0 means errors other than syntax
styledText.setLineBackground(ln - 1, 1,
new Color(Display.getCurrent(), 255, 230, 230));
while ((line = br.readLine()) != null) {
infolog += line;
if (!line.startsWith("0:"))
continue;
String[] details = line.split(":|\\(|\\)");
final int ln = Integer.parseInt(details[1]);
if (ln > 0) // usually line 0 means errors other than syntax
styledText.setLineBackground(ln - 1, 1,
new Color(Display.getCurrent(), 255, 230, 230));
}
file.delete();
if (infolog.length() > 0) {
if (!MessageDialog.openConfirm(getShell(),
"Shader Syntax Error, Continue?", infolog))
return;
}
} catch (IOException e) {
sampleView.showError(e);
}
file.delete();
if (infolog.length() > 0) {
if (!MessageDialog.openConfirm(getShell(),
"Shader Syntax Error, Continue?", infolog))
return;
}
} catch (IOException e) {
sampleView.showError(e);
}
// add the initial command, which when read by server will set
// expectResponse for the message loop and go into message exchange