remove GFXVertexSemantic

This commit is contained in:
jerrywwl
2019-01-02 18:03:51 +08:00
parent 80d0339869
commit 9ec52a9dda
6 changed files with 51 additions and 112 deletions
+36 -46
View File
@@ -22,27 +22,16 @@ export const GFX_MAX_VERTEX_ATTRIBUTES: number = 8;
export const GFX_MAX_TEXTURE_UNITS: number = 16;
export const GFX_MAX_ATTACHMENTS: number = 4;
export const GFX_ATTRIBUTE_POSITION = "a_position";
export const GFX_ATTRIBUTE_POSITION1 = "a_position1";
export const GFX_ATTRIBUTE_POSITION2 = "a_position2";
export const GFX_ATTRIBUTE_POSITION3 = "a_position3";
export const GFX_ATTRIBUTE_COLOR = "a_color";
export const GFX_ATTRIBUTE_COLOR1 = "a_color1";
export const GFX_ATTRIBUTE_COLOR2 = "a_color2";
export const GFX_ATTRIBUTE_COLOR3 = "a_color3";
export const GFX_ATTRIBUTE_NORMAL = "a_normal";
export const GFX_ATTRIBUTE_NORMAL1 = "a_normal1";
export const GFX_ATTRIBUTE_NORMAL2 = "a_normal2";
export const GFX_ATTRIBUTE_NORMAL3 = "a_normal3";
export const GFX_ATTRIBUTE_TANGENT = "a_tangent";
export const GFX_ATTRIBUTE_BINORMAL = "a_binormal";
export const GFX_ATTRIBUTE_TEXCOORD = "a_texCoord";
export const GFX_ATTRIBUTE_TEXCOORD1 = "a_texCoord1";
export const GFX_ATTRIBUTE_TEXCOORD2 = "a_texCoord2";
export const GFX_ATTRIBUTE_TEXCOORD3 = "a_texCoord3";
export const GFX_ATTRIBUTE_JOINTS = "a_joints";
export const GFX_ATTRIBUTE_WEIGHTS = "a_weights";
export const GFX_ATTRIBUTE_SV_INSTANCE_ID = "sv_instanceID";
export const GFX_ATTRIBUTE_POSITION = "a_position"; // 0
export const GFX_ATTRIBUTE_COLOR = "a_color"; // 1
export const GFX_ATTRIBUTE_COLOR1 = "a_color1"; // 2
export const GFX_ATTRIBUTE_NORMAL = "a_normal"; // 3
export const GFX_ATTRIBUTE_TANGENT = "a_tangent"; // 4
export const GFX_ATTRIBUTE_BINORMAL = "a_binormal"; // 5
export const GFX_ATTRIBUTE_TEXCOORD = "a_texCoord"; // 6
export const GFX_ATTRIBUTE_TEXCOORD1 = "a_texCoord1"; // 7
export const GFX_ATTRIBUTE_JOINTS = "a_joints"; // 8
export const GFX_ATTRIBUTE_WEIGHTS = "a_weights"; // 9
export enum GFXType {
UNKNOWN,
@@ -202,31 +191,6 @@ export enum GFXFormat {
PVRTC2_4BPP,
};
export enum GFXVertexSemantic {
UNKNOWN,
POSITION,
POSITION1,
POSITION2,
POSITION3,
COLOR,
COLOR1,
COLOR2,
COLOR3,
NORMAL,
NORMAL1,
NORMAL2,
NORMAL3,
TANGENT,
BINORMAL,
TEXCOORD,
TEXCOORD1,
TEXCOORD2,
TEXCOORD3,
JOINTS,
WEIGHTS,
SV_INSTANCE_ID,
};
export enum GFXBufferUsageBit {
NONE = 0,
TRANSFER_SRC = 0x1,
@@ -730,3 +694,29 @@ export function GFXGetTypeSize(type: GFXType): number {
}
}
}
export function GFXGetAttributeBinding(name: string) : number {
if (name === GFX_ATTRIBUTE_POSITION) {
return 20;
} else if (name === GFX_ATTRIBUTE_COLOR) {
return 21;
} else if (name === GFX_ATTRIBUTE_COLOR1) {
return 22;
} else if (name === GFX_ATTRIBUTE_NORMAL) {
return 23;
} else if (name === GFX_ATTRIBUTE_TANGENT) {
return 24;
} else if (name === GFX_ATTRIBUTE_BINORMAL) {
return 25;
} else if (name === GFX_ATTRIBUTE_TEXCOORD) {
return 26;
} else if (name === GFX_ATTRIBUTE_TEXCOORD1) {
return 27;
} else if (name === GFX_ATTRIBUTE_JOINTS) {
return 28;
} else if (name === GFX_ATTRIBUTE_WEIGHTS) {
return 29;
} else {
return -1;
}
}
+2 -2
View File
@@ -1,10 +1,10 @@
import { GFXDevice } from './device';
import { GFXFormat, GFXVertexSemantic } from './gfx-define';
import { GFXFormat } from './gfx-define';
import { GFXBuffer } from './buffer';
export interface GFXInputAttribute {
binding?: number;
name: string;
semantic: GFXVertexSemantic;
format: GFXFormat;
stream?: number;
isInstanced?: boolean;
+7 -58
View File
@@ -1,6 +1,6 @@
import { WebGLGPUBuffer, WebGLGPUTexture, WebGLGPUInputAssembler, WebGLGPUFramebuffer, WebGLGPUShader, WebGLGPUInput, WebGLAttrib, WebGLGPUPipelineState, WebGLGPUUniformBlock, WebGLGPUBindingLayout, WebGLGPUUniform, WebGLGPUUniformSampler } from "./webgl-gpu-objects";
import { WebGLGFXDevice } from "./webgl-device";
import { GFXFormatInfos, GFXFormat, WebGLEXT, GFXType, GFX_MAX_VERTEX_ATTRIBUTES, GFXFormatSize, GFXColor, GFXViewport, GFXRect, GFXBindingType, GFXBufferTextureCopy, GFXColorMask, GFXCullMode, GFXShaderType, GFXTextureViewType, GFXTextureLayout, GFXLoadOp, GFXTextureFlagBit, GFXMemoryUsageBit, GFXBufferUsageBit, GFX_ATTRIBUTE_POSITION, GFXVertexSemantic, GFX_ATTRIBUTE_POSITION1, GFX_ATTRIBUTE_POSITION2, GFX_ATTRIBUTE_POSITION3, GFX_ATTRIBUTE_COLOR, GFX_ATTRIBUTE_COLOR1, GFX_ATTRIBUTE_COLOR2, GFX_ATTRIBUTE_COLOR3, GFX_ATTRIBUTE_NORMAL, GFX_ATTRIBUTE_NORMAL1, GFX_ATTRIBUTE_NORMAL2, GFX_ATTRIBUTE_NORMAL3, GFX_ATTRIBUTE_TEXCOORD, GFX_ATTRIBUTE_TEXCOORD1, GFX_ATTRIBUTE_TEXCOORD2, GFX_ATTRIBUTE_TEXCOORD3, GFX_ATTRIBUTE_JOINTS, GFX_ATTRIBUTE_WEIGHTS, GFX_ATTRIBUTE_SV_INSTANCE_ID, GFX_ATTRIBUTE_TANGENT, GFX_ATTRIBUTE_BINORMAL } from "../gfx-define";
import { GFXFormatInfos, GFXFormat, WebGLEXT, GFXType, GFX_MAX_VERTEX_ATTRIBUTES, GFXFormatSize, GFXColor, GFXRect, GFXBindingType, GFXBufferTextureCopy, GFXColorMask, GFXCullMode, GFXShaderType, GFXTextureViewType, GFXTextureLayout, GFXLoadOp, GFXTextureFlagBit, GFXMemoryUsageBit, GFXBufferUsageBit, GFXGetAttributeBinding } from "../gfx-define";
import { WebGLGFXCommandAllocator } from "./webgl-command-allocator";
import { WebGLTexUnit } from "./webgl-state-cache";
@@ -818,75 +818,24 @@ export function WebGLCmdFuncCreateShader(device: WebGLGFXDevice, gpuShader: WebG
varName = info.name;
}
let semantic = GFXVertexSemantic.UNKNOWN;
let glLoc = -1;
let glLoc = GFXGetAttributeBinding(varName);
if (varName === GFX_ATTRIBUTE_POSITION) {
semantic = GFXVertexSemantic.POSITION;
} else if (varName === GFX_ATTRIBUTE_POSITION1) {
semantic = GFXVertexSemantic.POSITION1;
} else if (varName === GFX_ATTRIBUTE_POSITION2) {
semantic = GFXVertexSemantic.POSITION2;
} else if (varName === GFX_ATTRIBUTE_POSITION3) {
semantic = GFXVertexSemantic.POSITION3;
} else if (varName === GFX_ATTRIBUTE_COLOR) {
semantic = GFXVertexSemantic.COLOR;
} else if (varName === GFX_ATTRIBUTE_COLOR1) {
semantic = GFXVertexSemantic.COLOR1;
} else if (varName === GFX_ATTRIBUTE_COLOR2) {
semantic = GFXVertexSemantic.COLOR2;
} else if (varName === GFX_ATTRIBUTE_COLOR3) {
semantic = GFXVertexSemantic.COLOR3;
} else if (varName === GFX_ATTRIBUTE_NORMAL) {
semantic = GFXVertexSemantic.NORMAL;
} else if (varName === GFX_ATTRIBUTE_NORMAL1) {
semantic = GFXVertexSemantic.NORMAL1;
} else if (varName === GFX_ATTRIBUTE_NORMAL2) {
semantic = GFXVertexSemantic.NORMAL2;
} else if (varName === GFX_ATTRIBUTE_NORMAL3) {
semantic = GFXVertexSemantic.NORMAL3;
} else if (varName === GFX_ATTRIBUTE_TANGENT) {
semantic = GFXVertexSemantic.TANGENT;
} else if (varName === GFX_ATTRIBUTE_BINORMAL) {
semantic = GFXVertexSemantic.BINORMAL;
} else if (varName === GFX_ATTRIBUTE_TEXCOORD) {
semantic = GFXVertexSemantic.TEXCOORD;
} else if (varName === GFX_ATTRIBUTE_TEXCOORD1) {
semantic = GFXVertexSemantic.TEXCOORD1;
} else if (varName === GFX_ATTRIBUTE_TEXCOORD2) {
semantic = GFXVertexSemantic.TEXCOORD2;
} else if (varName === GFX_ATTRIBUTE_TEXCOORD3) {
semantic = GFXVertexSemantic.TEXCOORD3;
} else if (varName === GFX_ATTRIBUTE_JOINTS) {
semantic = GFXVertexSemantic.JOINTS;
} else if (varName === GFX_ATTRIBUTE_WEIGHTS) {
semantic = GFXVertexSemantic.WEIGHTS;
} else if (varName === GFX_ATTRIBUTE_SV_INSTANCE_ID) {
semantic = GFXVertexSemantic.SV_INSTANCE_ID;
} else {
console.error("Unsupported vertex attribute semantic.");
}
if(semantic !== GFXVertexSemantic.UNKNOWN) {
glLoc = semantic;
if(glLoc >= 0) {
gl.bindAttribLocation(gpuShader.glProgram, glLoc, varName);
} else {
glLoc = -1;
}/* else {
//glLoc = gl.getAttribLocation(gpuShader.glProgram, info.name);
}
}*/
let type = WebGLTypeToGFXType(info.type);
let stride = WebGLGetTypeSize(info.type);
gpuShader.glInputs[i] = {
binding: -1,
binding: glLoc,
name: varName,
type: type,
stride: stride,
count: info.size,
size: stride * info.size,
semantic: semantic,
glType: info.type,
glLoc: glLoc,
@@ -1063,7 +1012,7 @@ export function WebGLCmdFuncCreateInputAssember(device: WebGLGFXDevice, gpuInput
gpuInputAssembler.glAttribs[i] = {
glBuffer: gpuBuffer.glBuffer,
glLoc: attrib.semantic,
glLoc: attrib.binding? attrib.binding : -1,
glType: glType,
size: size,
count: GFXFormatInfos[attrib.format].count,
+1 -2
View File
@@ -1,4 +1,4 @@
import { GFXFormat, GFXType, GFXTextureType, GFXTextureUsage, GFXTextureUsageBit, GFXTextureFlags, GFXTextureFlagBit, GFXShaderType, GFXBindingType, GFXTextureViewType, GFXBufferUsageBit, GFXMemoryUsageBit, GFXMemoryUsage, GFXBufferUsage, GFXVertexSemantic } from "../gfx-define";
import { GFXFormat, GFXType, GFXTextureType, GFXTextureUsage, GFXTextureUsageBit, GFXTextureFlags, GFXTextureFlagBit, GFXShaderType, GFXBindingType, GFXTextureViewType, GFXBufferUsageBit, GFXMemoryUsageBit, GFXMemoryUsage, GFXBufferUsage } from "../gfx-define";
import { GFXColorAttachment, GFXDepthStencilAttachment } from "../render-pass";
import { GFXRasterizerState, GFXDepthStencilState, GFXBlendState } from "../pipeline-state";
import { GFXInputAttribute } from "../input-assembler";
@@ -126,7 +126,6 @@ export class WebGLGPUInput {
stride: number = 0;
count: number = 0;
size: number = 0;
semantic: GFXVertexSemantic = GFXVertexSemantic.UNKNOWN;
glType: GLenum = 0;
glLoc: GLint = 0;
+1
View File
@@ -0,0 +1 @@
import "./render-view";
+4 -4
View File
@@ -1,11 +1,11 @@
import { RenderView } from "./render-view";
import { RenderFlow, RenderFlowInfo } from "./render-flow";
import { Root } from "../core/root";
import { GFXRenderPass, GFXRenderPassInfo } from "../gfx/render-pass";
import { GFXRenderPass } from "../gfx/render-pass";
import { GFXDevice } from "../gfx/device";
import { GFXBuffer } from "../gfx/buffer";
import { GFXInputAssembler, GFXInputAttribute } from "../gfx/input-assembler";
import { GFXBufferUsageBit, GFXMemoryUsageBit, GFXVertexSemantic, GFXFormat } from "../gfx/gfx-define";
import { GFXBufferUsageBit, GFXMemoryUsageBit, GFXFormat } from "../gfx/gfx-define";
export enum RenderPassStage {
FORWARD = 0,
@@ -147,8 +147,8 @@ export abstract class RenderPipeline {
// create input assembler
let attributes: GFXInputAttribute[] = [
{name: "a_position", semantic: GFXVertexSemantic.POSITION, format: GFXFormat.RG32F},
{name: "a_texCoord", semantic: GFXVertexSemantic.TEXCOORD, format: GFXFormat.RG32F},
{name: "a_position", format: GFXFormat.RG32F},
{name: "a_texCoord", format: GFXFormat.RG32F},
];
this._quadIA = this._device.createInputAssembler({