mirror of
https://github.com/trudnai/Steve2.git
synced 2025-01-14 07:29:50 +00:00
80 lines
2.3 KiB
Metal
80 lines
2.3 KiB
Metal
//
|
|
// Shaders.metal
|
|
// Steve ][
|
|
//
|
|
// Created by Tamas Rudnai on 9/27/19.
|
|
// Copyright © 2019, 2020 Tamas Rudnai. All rights reserved.
|
|
//
|
|
// This file is part of Steve ][ -- The Apple ][ Emulator.
|
|
//
|
|
// Steve ][ is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Steve ][ is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Steve ][. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
#include <metal_stdlib>
|
|
using namespace metal;
|
|
|
|
|
|
// triangles
|
|
vertex float4 basic_vertex( // 1
|
|
const device packed_float3* vertex_array [[ buffer(0) ]], // 2
|
|
unsigned int vid [[ vertex_id ]] // 3
|
|
){
|
|
return float4(vertex_array[vid], 1.0); // 4
|
|
}
|
|
|
|
//struct Vertex {
|
|
// float4 position;
|
|
// float4 color;
|
|
//};
|
|
//
|
|
//struct VertexOut {
|
|
// float4 position [[position]];
|
|
// float4 color;
|
|
//};
|
|
//
|
|
//vertex VertexOut myVertexOut (
|
|
// const Vertex* vertexArray [[ buffer(0) ]],
|
|
// unsigned int vid [[ vertex_id ]]
|
|
//){
|
|
// VSO
|
|
//}
|
|
|
|
|
|
// color of triangles
|
|
fragment half4 basic_fragment() { // 1
|
|
return half4( 255.0/255.0, 127.0/255.0, 255.0/255.0, 1.0); // half4(1.0); // 2
|
|
}
|
|
|
|
|
|
kernel void add_arrays(device const float* inA,
|
|
device const float* inB,
|
|
device float* result,
|
|
uint index [[thread_position_in_grid]])
|
|
{
|
|
// the for-loop is replaced with a collection of threads, each of which
|
|
// calls this function.
|
|
result[index] = inA[index] + inB[index] + 1;
|
|
}
|
|
|
|
//vertex float4 basic_vertex( // 1
|
|
// const device packed_float3* vertex_array [[ buffer(0) ]], // 2
|
|
// unsigned int vid [[ vertex_id ]]) { // 3
|
|
// return float4(vertex_array[vid], 1.0); // 4
|
|
//}
|
|
//
|
|
//fragment half4 basic_fragment() { // 1
|
|
// return half4(1.0); // 2
|
|
//}
|
|
|